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

This commit is contained in:
Bernard Xiong 2025-01-12 10:20:25 +08:00 committed by GitHub
parent 123ed1be1b
commit c5a79de38e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 9 deletions

View File

@ -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 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)
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)

View File

@ -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()
@ -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