feat: prepare pinned card workspace sources

This commit is contained in:
user
2026-07-17 08:26:53 +02:00
parent aa5335aca0
commit 45257057df
2 changed files with 35 additions and 0 deletions
+27
View File
@@ -3771,6 +3771,26 @@ def run_env(config: WorkspaceConfig, args: argparse.Namespace) -> None:
if args.env_command == "sync":
print_key_values(sync_env_tool(config, dry_run=args.dry_run))
return
if args.env_command == "sources":
series_name, card_name = resolve_selector(config, args.series, args.card)
card_path = resolve_workspace_card_path(config, series_name, card_name)
env_script = ensure_env_tool(config)
preparer = env_script.parent / "scripts" / "prepare-workspace-sources.py"
if not preparer.is_file():
raise SystemExit(
f"Environment tool does not provide pinned workspace sources: {preparer}. "
"Run: ./stemctl env sync"
)
mode = "check" if args.check else "prepare"
command = [str(preparer), mode, str(card_path)]
if args.dry_run:
print(f"series\t{series_name}")
print(f"card\t{card_name}")
print(f"workspace\t{card_path}")
print(f"command\t{shlex.join(command)}")
return
subprocess.run(command, check=True)
return
if args.env_command == "build":
profile = normalize_env_profile(args.profile)
env_script = ensure_env_tool(config)
@@ -4453,6 +4473,13 @@ def build_parser() -> argparse.ArgumentParser:
env_subparsers.add_parser("list", help="List supported environment profiles.")
env_sync_parser = env_subparsers.add_parser("sync", help="Clone or update rv32i-hazard3-student-env into tools/.")
env_sync_parser.add_argument("--dry-run", action="store_true", help="Print plan without cloning or pulling.")
env_sources_parser = env_subparsers.add_parser(
"sources", help="Prepare or verify pinned Hazard3 sources in one host card workspace."
)
env_sources_parser.add_argument("series", nargs="?", help="Series id; defaults to workspace.json.")
env_sources_parser.add_argument("card", nargs="?", help="Card id; defaults to workspace.json.")
env_sources_parser.add_argument("--check", action="store_true", help="Verify without changing the workspace.")
env_sources_parser.add_argument("--dry-run", action="store_true", help="Print the preparation command only.")
env_build_parser = env_subparsers.add_parser("build", help="Build one container profile.")
env_build_parser.add_argument("profile", choices=ENV_PROFILE_CHOICES, help="Environment profile.")
env_build_parser.add_argument("--dry-run", action="store_true", help="Print command without building.")