From 53b894c46c8b2c28dfd7f1eccd23ad7e59bf02f0 Mon Sep 17 00:00:00 2001 From: bernard Date: Wed, 28 Aug 2024 22:43:46 +0800 Subject: [PATCH] [tools] fix the SDK path issue in env script. --- tools/env_utility.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/env_utility.py b/tools/env_utility.py index dc6425464a..608ef4fa15 100644 --- a/tools/env_utility.py +++ b/tools/env_utility.py @@ -41,13 +41,22 @@ def GetPkgPath(): else: return None - -def GetSDKPath(name): +def GetSDKPackagePath(): env = GetEnvPath() if env: - # read packages.json under env/tools/packages - with open(os.path.join(env, 'tools', 'packages', 'pkgs.json'), 'r', encoding='utf-8') as f: + return os.path.join(env, "tools", "scripts", "packages") + + return None + +# get SDK path based on name +# for example, GetSDKPath('arm-none-eabi') = '.env/tools/scripts/packages/arm-none-eabi-gcc-v10.3' +def GetSDKPath(name): + sdk_pkgs = GetSDKPackagePath() + + if sdk_pkgs: + # read packages.json under env/tools/scripts/packages + with open(os.path.join(sdk_pkgs, 'pkgs.json'), 'r', encoding='utf-8') as f: # packages_json = f.read() packages = json.load(f) @@ -59,12 +68,11 @@ def GetSDKPath(name): package = json.load(f) if package['name'] == name: - return os.path.join(env, 'tools', 'packages', package['name'] + '-' + item['ver']) + return os.path.join(sdk_pkgs, package['name'] + '-' + item['ver']) # not found named package return None - def help_info(): print( "**********************************************************************************\n"