#!/usr/bin/env python3
"""
Convenience wrapper for `cargo`.
Sets `CARGO_TARGET_DIR` to reuse `target` directory of the repo root to avoid
building dependencies twice.
"""

import os
import sys
from pathlib import Path

# Assume this script is in <root>/lib/edge/publish/.
REPO_ROOT = Path(__file__).parent.parent.parent.parent
"""Repo root, assuming this script lays in <root>/lib/edge/publish/."""

os.chdir(Path(__file__).parent)

env = os.environ.copy()
env.setdefault("CARGO_TARGET_DIR", str(REPO_ROOT / "target"))

os.execvpe("cargo", ["cargo"] + sys.argv[1:], env)
