From: Jeppe Johansen Date: Wed, 8 May 2019 14:56:33 +0000 (+0200) Subject: Add support for expanding environment variables. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=57276995b64b87bfa79d5102d2e8101b9b616fbc;p=SymbiYosys.git Add support for expanding environment variables. Signed-off-by: Jeppe Johansen --- diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index a66ea14..54e6c17 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -37,6 +37,14 @@ if os.name == "posix": signal.signal(signal.SIGINT, force_shutdown) signal.signal(signal.SIGTERM, force_shutdown) +def process_filename(filename): + if filename.startswith("~/"): + filename = os.environ['HOME'] + filename[1:] + + filename = os.path.expandvars(filename) + + return filename + class SbyTask: def __init__(self, job, info, deps, cmdline, logfile=None, logstderr=True): self.running = False @@ -290,8 +298,7 @@ class SbyJob: self.error("destination filename must be a relative path without /../: %s" % dstfile) dstfile = self.workdir + "/src/" + dstfile - if srcfile.startswith("~/"): - srcfile = os.environ['HOME'] + srcfile[1:] + srcfile = process_filename(srcfile) basedir = os.path.dirname(dstfile) if basedir != "" and not os.path.exists(basedir):