vivado: resolve install path from ~/skills_env.md instead of hardcoding D:\Xilinx
The Vivado install root differs per machine (C:\Xilinx here, D:\Xilinx on the box these skills were written on), so every hardcoded path was already wrong on this machine. - new fpga_flash/scripts/vivado_env.py: resolves --vivado-dir > env var > VIVADO_ROOT (falling back to VIVADO_PATH) from ~/skills_env.md - gen_mcs / program_flash / check_flash_csv: --vivado-dir now optional - fpga_update/gen_update_mcs.py: same precedence for --vivado - fpga_flash / smod_atsc_dev / vivado-prj-create SKILL.md: document the lookup instead of naming a drive letter - skills_env template: VIVADO_ROOT/VIVADO_PATH are now blanks to fill in, so a new machine can't inherit a wrong default Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
fbfa060b67
commit
88f96fa5fa
@@ -34,7 +34,41 @@ IMPL = os.path.join(REPO, "my_exciter.runs", "impl_1")
|
||||
POST_BITSTREAM = os.path.join(TCL_DIR, "post_bitstream.tcl")
|
||||
GEN_RU = os.path.join(TCL_DIR, "runScript_GenRu.tcl")
|
||||
PERL_SCRIPT = os.path.join(TCL_DIR, "MakeSpiFlashProgrammerMcsFiles_backup.pl")
|
||||
DEFAULT_VIVADO = r"D:\Xilinx\Vivado\2018.1\bin\vivado.bat"
|
||||
|
||||
|
||||
def _env_lookup(key, default=None):
|
||||
"""Machine-local values (paths, IPs) live in ~/skills_env.md, never in git.
|
||||
An OS environment variable of the same name overrides the file."""
|
||||
v = os.environ.get(key)
|
||||
if v:
|
||||
return v
|
||||
path = os.path.join(os.path.expanduser("~"), "skills_env.md")
|
||||
try:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
for line in f:
|
||||
m = re.match(rf"\s*{re.escape(key)}\s*=\s*(.+?)\s*(?:#.*)?$", line)
|
||||
if m:
|
||||
val = m.group(1).strip()
|
||||
if val and not val.startswith("<"):
|
||||
return val
|
||||
except OSError:
|
||||
pass
|
||||
return default
|
||||
|
||||
|
||||
def resolve_vivado():
|
||||
"""Vivado's install path differs per machine -- never hardcode it."""
|
||||
exe = _env_lookup("VIVADO_PATH")
|
||||
if exe:
|
||||
return exe
|
||||
root = _env_lookup("VIVADO_ROOT")
|
||||
if root:
|
||||
return os.path.join(root, "bin", "vivado.bat")
|
||||
sys.exit(
|
||||
"Vivado path not configured. Add `VIVADO_PATH = <...>/bin/vivado.bat` to "
|
||||
"~/skills_env.md, set it as an env var, or pass --vivado."
|
||||
)
|
||||
|
||||
|
||||
# runScript_GenRu.tcl hardcodes this name.
|
||||
BASE_MCS = "atsc_exciter.mcs"
|
||||
@@ -66,10 +100,12 @@ def first_ela(path):
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
ap.add_argument("--vivado", default=DEFAULT_VIVADO)
|
||||
ap.add_argument("--vivado", default=None,
|
||||
help="path to vivado.bat; defaults to VIVADO_PATH from ~/skills_env.md")
|
||||
ap.add_argument("--tag", help="rename the result to <tag>_update.mcs so it survives the next run")
|
||||
ap.add_argument("--keep-byproducts", action="store_true")
|
||||
args = ap.parse_args()
|
||||
args.vivado = args.vivado or resolve_vivado()
|
||||
|
||||
for path, what in ((args.vivado, "vivado"), (POST_BITSTREAM, "post_bitstream.tcl"),
|
||||
(GEN_RU, "runScript_GenRu.tcl"), (PERL_SCRIPT, "perl script")):
|
||||
|
||||
Reference in New Issue
Block a user