Support host profile in tmux containers
This commit is contained in:
@@ -3357,9 +3357,12 @@ def build_container_command(
|
|||||||
selector: str,
|
selector: str,
|
||||||
card_path: Path,
|
card_path: Path,
|
||||||
instance: str,
|
instance: str,
|
||||||
|
profile: str,
|
||||||
session_name: str,
|
session_name: str,
|
||||||
window_name: str,
|
window_name: str,
|
||||||
) -> str:
|
) -> str:
|
||||||
|
profile = normalize_env_profile(profile)
|
||||||
|
service = ENV_PROFILES[profile]["service"]
|
||||||
tool_root = config.tools_root
|
tool_root = config.tools_root
|
||||||
compose_file = tool_root / "docker-compose.yml"
|
compose_file = tool_root / "docker-compose.yml"
|
||||||
if not (tool_root / "rv").is_file():
|
if not (tool_root / "rv").is_file():
|
||||||
@@ -3370,11 +3373,13 @@ def build_container_command(
|
|||||||
|
|
||||||
home_dir = Path(os.environ.get("HOME") or str(Path.home()))
|
home_dir = Path(os.environ.get("HOME") or str(Path.home()))
|
||||||
card_path_text = str(card_path)
|
card_path_text = str(card_path)
|
||||||
profile = "rv32i"
|
|
||||||
user_name = current_user_slug()
|
user_name = current_user_slug()
|
||||||
session_slug = slug_value(session_name, "tmux session name")
|
session_slug = slug_value(session_name, "tmux session name")
|
||||||
instance_name = slug_value(instance, "container instance")
|
instance_name = slug_value(instance, "container instance")
|
||||||
container_name_parts = [user_name, session_slug, profile, instance_name]
|
container_name_parts = [user_name, session_slug]
|
||||||
|
if profile not in session_slug.split("-"):
|
||||||
|
container_name_parts.append(profile)
|
||||||
|
container_name_parts.append(instance_name)
|
||||||
container_name = "-".join(container_name_parts)
|
container_name = "-".join(container_name_parts)
|
||||||
env_parts = [
|
env_parts = [
|
||||||
f"WORKSPACE_ROOT={shlex.quote(str(config.workspace_root))}",
|
f"WORKSPACE_ROOT={shlex.quote(str(config.workspace_root))}",
|
||||||
@@ -3420,7 +3425,7 @@ def build_container_command(
|
|||||||
"RV_CODEX=0",
|
"RV_CODEX=0",
|
||||||
"-v",
|
"-v",
|
||||||
f"{card_path_text}:{card_path_text}",
|
f"{card_path_text}:{card_path_text}",
|
||||||
"env",
|
service,
|
||||||
"shell",
|
"shell",
|
||||||
]
|
]
|
||||||
return " && ".join(
|
return " && ".join(
|
||||||
@@ -3436,8 +3441,9 @@ def run_tmux_container(config: WorkspaceConfig, args: argparse.Namespace) -> Non
|
|||||||
selector = f"{series_name}/{card_name}"
|
selector = f"{series_name}/{card_name}"
|
||||||
card_path = resolve_card_path(config, series_name, card_name)
|
card_path = resolve_card_path(config, series_name, card_name)
|
||||||
|
|
||||||
|
profile = normalize_env_profile(args.profile)
|
||||||
user_name = current_user_slug()
|
user_name = current_user_slug()
|
||||||
default_session_name = f"rv-{user_name}-{slug_value(selector.replace('/', '-'), 'card selector')}"
|
default_session_name = f"rv-{user_name}-{slug_value(selector.replace('/', '-'), 'card selector')}-{profile}"
|
||||||
session_name = args.session or default_session_name
|
session_name = args.session or default_session_name
|
||||||
window_name = args.window or config.defaults.get("tmux_window", "rv")
|
window_name = args.window or config.defaults.get("tmux_window", "rv")
|
||||||
instance = args.instance or config.defaults.get("instance", "shell")
|
instance = args.instance or config.defaults.get("instance", "shell")
|
||||||
@@ -3448,7 +3454,7 @@ def run_tmux_container(config: WorkspaceConfig, args: argparse.Namespace) -> Non
|
|||||||
"Use another --session name or remove the existing session first."
|
"Use another --session name or remove the existing session first."
|
||||||
)
|
)
|
||||||
|
|
||||||
shell_command = build_container_command(config, selector, card_path, instance, session_name, window_name)
|
shell_command = build_container_command(config, selector, card_path, instance, profile, session_name, window_name)
|
||||||
tmux_command = [
|
tmux_command = [
|
||||||
"tmux",
|
"tmux",
|
||||||
"new-session",
|
"new-session",
|
||||||
@@ -4157,6 +4163,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|||||||
)
|
)
|
||||||
tmux_parser.add_argument("series", nargs="?", help="Series id or full selector like 'inf/bss'.")
|
tmux_parser.add_argument("series", nargs="?", help="Series id or full selector like 'inf/bss'.")
|
||||||
tmux_parser.add_argument("card", nargs="?", help="Card id or unique fragment, for example 'bss'.")
|
tmux_parser.add_argument("card", nargs="?", help="Card id or unique fragment, for example 'bss'.")
|
||||||
|
tmux_parser.add_argument("--profile", choices=sorted(ENV_PROFILES), default="rv32i", help="Container profile: rv32i or host.")
|
||||||
tmux_parser.add_argument("--session", help="tmux session name.")
|
tmux_parser.add_argument("--session", help="tmux session name.")
|
||||||
tmux_parser.add_argument("--window", help="tmux window name.")
|
tmux_parser.add_argument("--window", help="tmux window name.")
|
||||||
tmux_parser.add_argument("--instance", help="RV_INSTANCE passed to the tool launcher.")
|
tmux_parser.add_argument("--instance", help="RV_INSTANCE passed to the tool launcher.")
|
||||||
|
|||||||
Reference in New Issue
Block a user