Skip to content

[tools] fix the SDK path issue in env script. #9362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions tools/env_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"
Expand Down
Loading