+8
-15
@@ -19,6 +19,7 @@ COMMANDS = (
|
||||
"test",
|
||||
"package",
|
||||
"lsp",
|
||||
"clangd",
|
||||
"run",
|
||||
)
|
||||
COMMON_DIR = pathlib.Path("build") / "build_common"
|
||||
@@ -60,6 +61,7 @@ def runtime_ready(root):
|
||||
return (
|
||||
(root / TOOLS_DIR / "configure.py").is_file()
|
||||
and (root / TOOLS_DIR / "lsp.py").is_file()
|
||||
and (root / TOOLS_DIR / "clangd.py").is_file()
|
||||
and (root / TOOLS_DIR / "run.py").is_file()
|
||||
and (root / RUNTIME_DIR / "modulus" / "cli.py").is_file()
|
||||
and (root / RUNTIME_DIR / "modulus" / "export.py").is_file()
|
||||
@@ -485,22 +487,14 @@ def run_package(argv):
|
||||
|
||||
def delegate(command, argv):
|
||||
root = repo_root()
|
||||
ensure_runtime(root)
|
||||
if command == "clangd":
|
||||
if not runtime_ready(root):
|
||||
print("Modulus clangd tooling is missing; run ./modulus.py configure first", file=sys.stderr)
|
||||
return 1
|
||||
else:
|
||||
ensure_runtime(root)
|
||||
sys.path.insert(0, str(root / RUNTIME_DIR))
|
||||
import modulus.cli
|
||||
original_image_available = modulus.cli.docker_image_available
|
||||
|
||||
def current_build_image(context):
|
||||
if not original_image_available(context):
|
||||
return False
|
||||
inspected = subprocess.run(
|
||||
["docker", "image", "inspect", context.docker_image, "--format",
|
||||
'{{index .Config.Labels "org.khodo.product-vamp.build-requirements"}}'],
|
||||
capture_output=True, text=True, check=False,
|
||||
)
|
||||
return inspected.returncode == 0 and inspected.stdout.strip() == build_requirements_digest()
|
||||
|
||||
modulus.cli.docker_image_available = current_build_image
|
||||
original_docker_run = modulus.cli.docker_run
|
||||
|
||||
def docker_run_with_host_socket(context, command, docker_args=None, env_overrides=None):
|
||||
@@ -521,7 +515,6 @@ def delegate(command, argv):
|
||||
try:
|
||||
return modulus.cli.main(command)
|
||||
finally:
|
||||
modulus.cli.docker_image_available = original_image_available
|
||||
modulus.cli.docker_run = original_docker_run
|
||||
os.chdir(previous_cwd)
|
||||
sys.argv = previous_argv
|
||||
|
||||
Reference in New Issue
Block a user