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.
This commit is contained in:
Catherine 2024-01-03 11:38:42 +00:00
parent 0849e1af0b
commit 5d9ad62f36
6 changed files with 6 additions and 0 deletions

View file

@ -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 %}

View file

@ -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

View file

@ -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

View file

@ -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 %}

View file

@ -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

View file

@ -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`_)