build.plat: fold emit_prelude() into emit_commands().
authorwhitequark <cz@m-labs.hk>
Sun, 13 Oct 2019 13:57:48 +0000 (13:57 +0000)
committerwhitequark <cz@m-labs.hk>
Sun, 13 Oct 2019 13:57:48 +0000 (13:57 +0000)
Commit a783e464 broke all toolchains using bash.

nmigen/build/plat.py

index 65d5401c7d2a620b146c5373d6df0f23424d6c73..b99715b1056e420aa5f897c7e25c5a426bdeac75 100644 (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,