diff --git a/tools/building.py b/tools/building.py index 5c8e3941984..c64c393ba00 100644 --- a/tools/building.py +++ b/tools/building.py @@ -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) diff --git a/tools/env_utility.py b/tools/env_utility.py index 608ef4fa156..d950d077334 100644 --- a/tools/env_utility.py +++ b/tools/env_utility.py @@ -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