Skip to content

Commit b12284e

Browse files
committed
[tools] fix the SDK path issue in env script.
1 parent 66738d7 commit b12284e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tools/env_utility.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,22 @@ def GetPkgPath():
4141
else:
4242
return None
4343

44-
45-
def GetSDKPath(name):
44+
def GetSDKPackagePath():
4645
env = GetEnvPath()
4746

4847
if env:
49-
# read packages.json under env/tools/packages
50-
with open(os.path.join(env, 'tools', 'packages', 'pkgs.json'), 'r', encoding='utf-8') as f:
48+
return os.path.join(env, "tools", "scripts", "packages")
49+
50+
return None
51+
52+
# get SDK path based on name
53+
# for example, GetSDKPath('arm-none-eabi') = '.env/tools/scripts/packages/arm-none-eabi-gcc-v10.3'
54+
def GetSDKPath(name):
55+
sdk_pkgs = GetSDKPackagePath()
56+
57+
if sdk_pkgs:
58+
# read packages.json under env/tools/scripts/packages
59+
with open(os.path.join(sdk_pkgs, 'pkgs.json'), 'r', encoding='utf-8') as f:
5160
# packages_json = f.read()
5261
packages = json.load(f)
5362

@@ -59,12 +68,11 @@ def GetSDKPath(name):
5968
package = json.load(f)
6069

6170
if package['name'] == name:
62-
return os.path.join(env, 'tools', 'packages', package['name'] + '-' + item['ver'])
71+
return os.path.join(sdk_pkgs, package['name'] + '-' + item['ver'])
6372

6473
# not found named package
6574
return None
6675

67-
6876
def help_info():
6977
print(
7078
"**********************************************************************************\n"

0 commit comments

Comments
 (0)