Skip to content
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

[tools] Add sdk_cfg.json setting for env CC detection #9890

Merged
merged 11 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
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
19 changes: 10 additions & 9 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,16 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
envm = utils.ImportModule('env_utility')
# from env import GetSDKPath
exec_path = envm.GetSDKPath(rtconfig.CC)
if 'gcc' in rtconfig.CC:
exec_path = os.path.join(exec_path, 'bin')

if os.path.exists(exec_path):
Env['log'].debug('set CC to ' + exec_path)
rtconfig.EXEC_PATH = exec_path
os.environ['RTT_EXEC_PATH'] = exec_path
else:
Env['log'].debug('No Toolchain found in path(%s).' % exec_path)
if exec_path != None:
if 'gcc' in rtconfig.CC:
exec_path = os.path.join(exec_path, 'bin')

if os.path.exists(exec_path):
Env['log'].debug('set CC to ' + exec_path)
rtconfig.EXEC_PATH = exec_path
os.environ['RTT_EXEC_PATH'] = exec_path
else:
Env['log'].debug('No Toolchain found in path(%s).' % exec_path)
except Exception as e:
# detect failed, ignore
Env['log'].debug(e)
Expand Down
12 changes: 11 additions & 1 deletion tools/env_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ def GetSDKPath(name):
sdk_pkgs = GetSDKPackagePath()

if sdk_pkgs:
# read env/tools/scripts/sdk_cfg.json for curstomized SDK path
if os.path.exists(os.path.join(sdk_pkgs, '..', 'sdk_cfg.json')):
with open(os.path.join(sdk_pkgs, '..', 'sdk_cfg.json'), 'r', encoding='utf-8') as f:
sdk_cfg = json.load(f)
for item in sdk_cfg:
if item['name'] == name:
sdk = os.path.join(sdk_pkgs, item['path'])
return sdk

# 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()
Expand All @@ -68,7 +77,8 @@ def GetSDKPath(name):
package = json.load(f)

if package['name'] == name:
return os.path.join(sdk_pkgs, package['name'] + '-' + item['ver'])
sdk = os.path.join(sdk_pkgs, package['name'] + '-' + item['ver'])
return sdk

# not found named package
return None
Expand Down
Loading