build.plat: allow selecting a specific UNIX shell interpreter.
Mostly because vendor tools have bashisms.
This commit is contained in:
parent
34a97b2751
commit
5eb4e2ee51
|
@ -221,11 +221,13 @@ class TemplatedPlatform(Platform):
|
||||||
toolchain = abstractproperty()
|
toolchain = abstractproperty()
|
||||||
file_templates = abstractproperty()
|
file_templates = abstractproperty()
|
||||||
command_templates = abstractproperty()
|
command_templates = abstractproperty()
|
||||||
|
unix_interpreter = "sh"
|
||||||
|
|
||||||
build_script_templates = {
|
build_script_templates = {
|
||||||
"build_{{name}}.sh": """
|
"build_{{name}}.sh": """
|
||||||
# {{autogenerated}}
|
# {{autogenerated}}
|
||||||
set -e{{verbose("x")}}
|
set -e{{verbose("x")}}
|
||||||
|
{{emit_unix_interpreter()}}
|
||||||
[ -n "$NMIGEN_{{platform.toolchain}}_env" ] && . "$NMIGEN_{{platform.toolchain}}_env"
|
[ -n "$NMIGEN_{{platform.toolchain}}_env" ] && . "$NMIGEN_{{platform.toolchain}}_env"
|
||||||
{{emit_commands("sh")}}
|
{{emit_commands("sh")}}
|
||||||
""",
|
""",
|
||||||
|
@ -242,6 +244,13 @@ class TemplatedPlatform(Platform):
|
||||||
# and to incorporate the nMigen version into generated code.
|
# and to incorporate the nMigen version into generated code.
|
||||||
autogenerated = "Automatically generated by nMigen {}. Do not edit.".format(__version__)
|
autogenerated = "Automatically generated by nMigen {}. Do not edit.".format(__version__)
|
||||||
|
|
||||||
|
def emit_unix_interpreter():
|
||||||
|
if self.unix_interpreter == "sh":
|
||||||
|
return "# runs on any POSIX sh"
|
||||||
|
if self.unix_interpreter == "bash":
|
||||||
|
return """if [ -z "$BASH" ] ; then exec /bin/bash "$0" "$@"; fi"""
|
||||||
|
assert False
|
||||||
|
|
||||||
def emit_design(backend):
|
def emit_design(backend):
|
||||||
return {"rtlil": rtlil, "verilog": verilog}[backend].convert(fragment, name=name,
|
return {"rtlil": rtlil, "verilog": verilog}[backend].convert(fragment, name=name,
|
||||||
ports=list(self.iter_ports()), missing_domain=lambda name: None)
|
ports=list(self.iter_ports()), missing_domain=lambda name: None)
|
||||||
|
@ -308,6 +317,7 @@ class TemplatedPlatform(Platform):
|
||||||
return compiled.render({
|
return compiled.render({
|
||||||
"name": name,
|
"name": name,
|
||||||
"platform": self,
|
"platform": self,
|
||||||
|
"emit_unix_interpreter": emit_unix_interpreter,
|
||||||
"emit_design": emit_design,
|
"emit_design": emit_design,
|
||||||
"emit_commands": emit_commands,
|
"emit_commands": emit_commands,
|
||||||
"get_tool": get_tool,
|
"get_tool": get_tool,
|
||||||
|
|
Loading…
Reference in a new issue