From 5d9ad62f368d28122cd0ddc6b7fb459da6d180d8 Mon Sep 17 00:00:00 2001 From: Catherine Date: Wed, 3 Jan 2024 11:38:42 +0000 Subject: [PATCH] build.plat,vendor: start `build.sh` with `#!/bin/sh`. The build scripts generated by Amaranth are designed to be invoked by directly running them with any shell (some of them will re-invoke themselves with `bash` specifically, when it's a toolchain requirement), and they're not currently marked executable, so there's no shebang. Add a shebang line to improve compatibility with cases where they are treated as executables in their own right. --- amaranth/build/plat.py | 1 + amaranth/vendor/_intel.py | 1 + amaranth/vendor/_lattice_ecp5.py | 1 + amaranth/vendor/_lattice_ice40.py | 1 + amaranth/vendor/_xilinx.py | 1 + docs/changes.rst | 1 + 6 files changed, 6 insertions(+) diff --git a/amaranth/build/plat.py b/amaranth/build/plat.py index d132178..7b22735 100644 --- a/amaranth/build/plat.py +++ b/amaranth/build/plat.py @@ -276,6 +276,7 @@ class TemplatedPlatform(Platform): build_script_templates = { "build_{{name}}.sh": """ + #!/bin/sh # {{autogenerated}} set -e{{verbose("x")}} {% for var in platform._all_toolchain_env_vars %} diff --git a/amaranth/vendor/_intel.py b/amaranth/vendor/_intel.py index 8f2ecc2..58f07eb 100644 --- a/amaranth/vendor/_intel.py +++ b/amaranth/vendor/_intel.py @@ -80,6 +80,7 @@ class IntelPlatform(TemplatedPlatform): quartus_file_templates = { **TemplatedPlatform.build_script_templates, "build_{{name}}.sh": r""" + #!/bin/sh # {{autogenerated}} {% for var in platform._all_toolchain_env_vars %} if [ -n "${{var}}" ]; then diff --git a/amaranth/vendor/_lattice_ecp5.py b/amaranth/vendor/_lattice_ecp5.py index 261ccbe..d75f629 100644 --- a/amaranth/vendor/_lattice_ecp5.py +++ b/amaranth/vendor/_lattice_ecp5.py @@ -182,6 +182,7 @@ class LatticeECP5Platform(TemplatedPlatform): _diamond_file_templates = { **TemplatedPlatform.build_script_templates, "build_{{name}}.sh": r""" + #!/bin/sh # {{autogenerated}} set -e{{verbose("x")}} if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi diff --git a/amaranth/vendor/_lattice_ice40.py b/amaranth/vendor/_lattice_ice40.py index 34f2363..a4e1bc2 100644 --- a/amaranth/vendor/_lattice_ice40.py +++ b/amaranth/vendor/_lattice_ice40.py @@ -175,6 +175,7 @@ class LatticeICE40Platform(TemplatedPlatform): _icecube2_file_templates = { **TemplatedPlatform.build_script_templates, "build_{{name}}.sh": r""" + #!/bin/sh # {{autogenerated}} set -e{{verbose("x")}} {% for var in platform._all_toolchain_env_vars %} diff --git a/amaranth/vendor/_xilinx.py b/amaranth/vendor/_xilinx.py index e7c884b..0f033e2 100644 --- a/amaranth/vendor/_xilinx.py +++ b/amaranth/vendor/_xilinx.py @@ -139,6 +139,7 @@ class XilinxPlatform(TemplatedPlatform): _vivado_file_templates = { **TemplatedPlatform.build_script_templates, "build_{{name}}.sh": r""" + #!/bin/sh # {{autogenerated}} set -e{{verbose("x")}} if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi diff --git a/docs/changes.rst b/docs/changes.rst index 34a251c..8dbb71a 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -35,6 +35,7 @@ Platform integration changes .. currentmodule:: amaranth.vendor +* Added: ``build.sh`` begins with ``#!/bin/sh``. * Removed: (deprecated in 0.4) :mod:`vendor.intel`, :mod:`vendor.lattice_ecp5`, :mod:`vendor.lattice_ice40`, :mod:`vendor.lattice_machxo2_3l`, :mod:`vendor.quicklogic`, :mod:`vendor.xilinx`. (`RFC 18`_)