build.run: Ensure batch script returns proper error code.
authorWilliam D. Jones <thor0505@comcast.net>
Sun, 14 Jul 2019 17:28:19 +0000 (13:28 -0400)
committerwhitequark <whitequark@whitequark.org>
Sun, 14 Jul 2019 17:43:33 +0000 (17:43 +0000)
nmigen/build/run.py

index 31d04c8e1e97560d37763165b6470bc99f87d042..14409c9f9762d771f379fef7803285e276af9555 100644 (file)
@@ -71,7 +71,13 @@ class BuildPlan:
 
             if run_script:
                 if sys.platform.startswith("win32"):
-                    subprocess.check_call(["cmd", "/c", "{}.bat".format(self.script)])
+                    # Without "call", "cmd /c {}.bat" will return 0.
+                    # See https://stackoverflow.com/a/30736987 for a detailed
+                    # explanation of why, including disassembly/decompilation
+                    # of relevant code in cmd.exe.
+                    # Running the script manually from a command prompt is
+                    # unaffected- i.e. "call" is not required.
+                    subprocess.check_call(["cmd", "/c", "call {}.bat".format(self.script)])
                 else:
                     subprocess.check_call(["sh", "{}.sh".format(self.script)])