build.run: add BuildPlan.execute_docker()
One usecase for this is using amaranth with vivado on macOs.
This commit is contained in:
parent
3200a3961d
commit
b823a8ee9d
|
@ -115,6 +115,28 @@ class BuildPlan:
|
||||||
|
|
||||||
return LocalBuildProducts(build_dir)
|
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
|
||||||
|
build root directory ``root`` on the local filesystem. This directory is bind mounted to
|
||||||
|
``/build`` in a container and the script ``{script}.sh`` is executed inside it.
|
||||||
|
``docker_args`` is a list containing additional arguments to docker.
|
||||||
|
|
||||||
|
Returns :class:`LocalBuildProducts`.
|
||||||
|
"""
|
||||||
|
build_dir = self.extract(root)
|
||||||
|
subprocess.check_call([
|
||||||
|
"docker", "run", *docker_args,
|
||||||
|
"--rm", # remove the container after running
|
||||||
|
"--mount", f"type=bind,source={build_dir},target=/build",
|
||||||
|
"--workdir", "/build",
|
||||||
|
image,
|
||||||
|
"sh", f"{self.script}.sh",
|
||||||
|
])
|
||||||
|
return LocalBuildProducts(build_dir)
|
||||||
|
|
||||||
|
|
||||||
def execute_remote_ssh(self, *, connect_to={}, root, run_script=True):
|
def execute_remote_ssh(self, *, connect_to={}, root, run_script=True):
|
||||||
"""
|
"""
|
||||||
Execute build plan using the remote SSH strategy. Files from the build
|
Execute build plan using the remote SSH strategy. Files from the build
|
||||||
|
|
|
@ -35,6 +35,7 @@ Platform integration changes
|
||||||
|
|
||||||
.. currentmodule:: amaranth.vendor
|
.. currentmodule:: amaranth.vendor
|
||||||
|
|
||||||
|
* Added: :meth:`BuildPlan.execute_local_docker`.
|
||||||
* Added: :meth:`BuildPlan.extract`.
|
* Added: :meth:`BuildPlan.extract`.
|
||||||
* Added: ``build.sh`` begins with ``#!/bin/sh``.
|
* Added: ``build.sh`` begins with ``#!/bin/sh``.
|
||||||
* Removed: (deprecated in 0.4) :mod:`vendor.intel`, :mod:`vendor.lattice_ecp5`, :mod:`vendor.lattice_ice40`, :mod:`vendor.lattice_machxo2_3l`, :mod:`vendor.quicklogic`, :mod:`vendor.xilinx`. (`RFC 18`_)
|
* Removed: (deprecated in 0.4) :mod:`vendor.intel`, :mod:`vendor.lattice_ecp5`, :mod:`vendor.lattice_ice40`, :mod:`vendor.lattice_machxo2_3l`, :mod:`vendor.quicklogic`, :mod:`vendor.xilinx`. (`RFC 18`_)
|
||||||
|
|
Loading…
Reference in a new issue