Skip to content

Commit c5a79de

Browse files
authored
[tools] Add sdk_cfg.json setting for env CC detection
1 parent 123ed1b commit c5a79de

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

tools/building.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,16 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
210210
envm = utils.ImportModule('env_utility')
211211
# from env import GetSDKPath
212212
exec_path = envm.GetSDKPath(rtconfig.CC)
213-
if 'gcc' in rtconfig.CC:
214-
exec_path = os.path.join(exec_path, 'bin')
215-
216-
if os.path.exists(exec_path):
217-
Env['log'].debug('set CC to ' + exec_path)
218-
rtconfig.EXEC_PATH = exec_path
219-
os.environ['RTT_EXEC_PATH'] = exec_path
220-
else:
221-
Env['log'].debug('No Toolchain found in path(%s).' % exec_path)
213+
if exec_path != None:
214+
if 'gcc' in rtconfig.CC:
215+
exec_path = os.path.join(exec_path, 'bin')
216+
217+
if os.path.exists(exec_path):
218+
Env['log'].debug('set CC to ' + exec_path)
219+
rtconfig.EXEC_PATH = exec_path
220+
os.environ['RTT_EXEC_PATH'] = exec_path
221+
else:
222+
Env['log'].debug('No Toolchain found in path(%s).' % exec_path)
222223
except Exception as e:
223224
# detect failed, ignore
224225
Env['log'].debug(e)

tools/env_utility.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ def GetSDKPath(name):
5555
sdk_pkgs = GetSDKPackagePath()
5656

5757
if sdk_pkgs:
58+
# read env/tools/scripts/sdk_cfg.json for curstomized SDK path
59+
if os.path.exists(os.path.join(sdk_pkgs, '..', 'sdk_cfg.json')):
60+
with open(os.path.join(sdk_pkgs, '..', 'sdk_cfg.json'), 'r', encoding='utf-8') as f:
61+
sdk_cfg = json.load(f)
62+
for item in sdk_cfg:
63+
if item['name'] == name:
64+
sdk = os.path.join(sdk_pkgs, item['path'])
65+
return sdk
66+
5867
# read packages.json under env/tools/scripts/packages
5968
with open(os.path.join(sdk_pkgs, 'pkgs.json'), 'r', encoding='utf-8') as f:
6069
# packages_json = f.read()
@@ -68,7 +77,8 @@ def GetSDKPath(name):
6877
package = json.load(f)
6978

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

7383
# not found named package
7484
return None

0 commit comments

Comments
 (0)