build.plat: fold emit_prelude() into emit_commands().

Commit a783e464 broke all toolchains using bash.
This commit is contained in:
whitequark 2019-10-13 13:57:48 +00:00
parent a783e4645d
commit b8b8e0ba0b

View file

@ -247,14 +247,12 @@ class TemplatedPlatform(Platform):
# {{autogenerated}}
set -e{{verbose("x")}}
[ -n "${{platform._toolchain_env_var}}" ] && . "${{platform._toolchain_env_var}}"
{{emit_prelude("sh")}}
{{emit_commands("sh")}}
""",
"build_{{name}}.bat": """
@rem {{autogenerated}}
{{quiet("@echo off")}}
if defined {{platform._toolchain_env_var}} call %{{platform._toolchain_env_var}}%
{{emit_prelude("bat")}}
{{emit_commands("bat")}}
""",
}
@ -288,8 +286,9 @@ class TemplatedPlatform(Platform):
return verilog._convert_rtlil_text(rtlil_text,
strip_internal_attrs=False, write_verilog_opts=opts)
def emit_prelude(syntax):
def emit_commands(syntax):
commands = []
for name in self.required_tools:
env_var = tool_env_var(name)
if syntax == "sh":
@ -301,10 +300,7 @@ class TemplatedPlatform(Platform):
else:
assert False
commands.append(template.format(env_var=env_var, name=name))
return "\n".join(commands)
def emit_commands(syntax):
commands = []
for index, command_tpl in enumerate(self.command_templates):
command = render(command_tpl, origin="<command#{}>".format(index + 1),
syntax=syntax)
@ -315,6 +311,7 @@ class TemplatedPlatform(Platform):
commands.append(command + " || exit /b")
else:
assert False
return "\n".join(commands)
def get_override(var):
@ -379,7 +376,6 @@ class TemplatedPlatform(Platform):
"emit_rtlil": emit_rtlil,
"emit_verilog": emit_verilog,
"emit_debug_verilog": emit_debug_verilog,
"emit_prelude": emit_prelude,
"emit_commands": emit_commands,
"syntax": syntax,
"invoke_tool": invoke_tool,