From 4ee25fc2d1703dfb6e380e886870cc90efdb89a2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 26 Jul 2021 17:01:24 +0800 Subject: [PATCH] artiq_flash: cleanup openocd handling, do not follow symlinks Not following symlinks allows files to be added to OpenOCD via nixpkgs buildEnv. --- artiq/frontend/artiq_flash.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/artiq/frontend/artiq_flash.py b/artiq/frontend/artiq_flash.py index 52a7972e6..cb4ef11ba 100755 --- a/artiq/frontend/artiq_flash.py +++ b/artiq/frontend/artiq_flash.py @@ -75,28 +75,22 @@ Prerequisites: help="actions to perform, default: %(default)s") return parser -def which_openocd(): +def openocd_root(): openocd = shutil.which("openocd") if not openocd: raise FileNotFoundError("OpenOCD is required but was not found in PATH. Is it installed?") - return openocd + return os.path.dirname(os.path.dirname(openocd)) + def scripts_path(): p = ["share", "openocd", "scripts"] if os.name == "nt": p.insert(0, "Library") - p = os.path.abspath(os.path.join( - os.path.dirname(os.path.realpath(which_openocd())), - "..", *p)) - return p + return os.path.abspath(os.path.join(openocd_root(), *p)) def proxy_path(): - p = ["share", "bscan-spi-bitstreams"] - p = os.path.abspath(os.path.join( - os.path.dirname(os.path.realpath(which_openocd())), - "..", *p)) - return p + return os.path.abspath(os.path.join(openocd_root(), "share", "bscan-spi-bitstreams")) def find_proxy_bitfile(filename):