From dafefa87a99f036ae322d44a03009125c7d8b72a Mon Sep 17 00:00:00 2001 From: Catherine Date: Mon, 30 Jan 2023 11:48:28 +0000 Subject: [PATCH] build.run: in BuildPlan.execute_local, always use LF line endings. This way the files are written identically on *nix and Windows. Fixes #732. --- amaranth/build/run.py | 5 +++-- docs/changes.rst | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/amaranth/build/run.py b/amaranth/build/run.py index cb40af6..1e42417 100644 --- a/amaranth/build/run.py +++ b/amaranth/build/run.py @@ -84,8 +84,9 @@ class BuildPlan: if dirname: os.makedirs(dirname, exist_ok=True) - mode = "wt" if isinstance(content, str) else "wb" - with open(filename, mode) as f: + if isinstance(content, str): + content = content.encode("utf-8") + with open(filename, "wb") as f: f.write(content) if run_script: diff --git a/docs/changes.rst b/docs/changes.rst index 3f0f825..9523a88 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -43,6 +43,7 @@ Toolchain changes .. currentmodule:: amaranth +* Changed: text files are written with LF line endings on Windows, like on other platforms. * Added: ``debug_verilog`` override in :class:`build.TemplatedPlatform`. * Deprecated: use of mixed-case toolchain environment variable names, such as ``NMIGEN_ENV_Diamond`` or ``AMARANTH_ENV_Diamond``; use upper-case environment variable names, such as ``AMARANTH_ENV_DIAMOND``. * Removed: (deprecated in 0.3) :meth:`sim.Simulator.step`.