Skip to content

Commit

Permalink
build.run: remove deprecated execute_local(run_script=) argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Sep 5, 2024
1 parent 0f27429 commit f20f042
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions amaranth/build/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def extract(self, root="build"):
finally:
os.chdir(cwd)

def execute_local(self, root="build", *, run_script=None, env=None):
def execute_local(self, root="build", *, env=None):
"""
Execute build plan using the local strategy. Files from the build plan are placed in
the build root directory ``root``, and, if ``run_script`` is ``True``, the script
Expand All @@ -107,25 +107,17 @@ def execute_local(self, root="build", *, run_script=None, env=None):
Returns :class:`LocalBuildProducts`.
"""
build_dir = self.extract(root)
if run_script is None or run_script:
if sys.platform.startswith("win32"):
# Without "call", "cmd /c {}.bat" will return 0.
# See https://stackoverflow.com/a/30736987 for a detailed explanation of why.
# Running the script manually from a command prompt is unaffected.
subprocess.check_call(["cmd", "/c", f"call {self.script}.bat"],
cwd=build_dir, env=os.environ if env is None else env)
else:
subprocess.check_call(["sh", f"{self.script}.sh"],
cwd=build_dir, env=os.environ if env is None else env)
# TODO(amaranth-0.6): remove
if run_script is not None:
warnings.warn("The `run_script` argument is deprecated. If you only want to "
"extract the files from the BuildPlan, use the .extract() method",
DeprecationWarning, stacklevel=2)

if sys.platform.startswith("win32"):
# Without "call", "cmd /c {}.bat" will return 0.
# See https://stackoverflow.com/a/30736987 for a detailed explanation of why.
# Running the script manually from a command prompt is unaffected.
subprocess.check_call(["cmd", "/c", f"call {self.script}.bat"],
cwd=build_dir, env=os.environ if env is None else env)
else:
subprocess.check_call(["sh", f"{self.script}.sh"],
cwd=build_dir, env=os.environ if env is None else env)
return LocalBuildProducts(build_dir)


def execute_local_docker(self, image, *, root="build", docker_args=[]):
"""
Execute build plan inside a Docker container. Files from the build plan are placed in the
Expand Down

0 comments on commit f20f042

Please sign in to comment.