diff options
| author | Man, Jianting (Meco) <[email protected]> | 2022-12-06 22:30:28 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-06 22:30:28 -0500 |
| commit | 4dd0e670565b9156b6481e421e76fe52a3294b85 (patch) | |
| tree | 0b54b4754323cf0919dc887811191f03fbd145a4 | |
| parent | a64750ebede641742d0e4d646169531000d8b2c2 (diff) | |
[tools][musl] add scons --exec-prefix= 用于设置编译工具的前缀 (#6646)
* [tools][musl] add scons --exec-prefix= 用于设置编译工具的前缀
可以通过如下命令在qemu直接调用musl工具链:
scons --exec-path=C:\xxx\arm-linux-musleabi_for_i686-w64-mingw32\bin --exec-prefix=arm-linux-musleabi-
* comment out GenCconfigFile
* 解决部分env变量提前预载之后重载变量的问题
| -rw-r--r-- | bsp/qemu-vexpress-a9/rtconfig.py | 6 | ||||
| -rw-r--r-- | tools/building.py | 58 | ||||
| -rw-r--r-- | tools/options.py | 4 | ||||
| -rw-r--r-- | tools/utils.py | 2 |
4 files changed, 42 insertions, 28 deletions
diff --git a/bsp/qemu-vexpress-a9/rtconfig.py b/bsp/qemu-vexpress-a9/rtconfig.py index 5d3b9842e8..5aa123823b 100644 --- a/bsp/qemu-vexpress-a9/rtconfig.py +++ b/bsp/qemu-vexpress-a9/rtconfig.py @@ -37,8 +37,7 @@ BUILD = 'debug' LINK_SCRIPT = 'link.lds' if PLATFORM == 'gcc': - # toolchains - PREFIX = os.getenv('RTT_CC_PREFIX') or 'arm-none-eabi-' + PREFIX = os.getenv('RTT_EXEC_PREFIX') or 'arm-none-eabi-' CC = PREFIX + 'gcc' CXX = PREFIX + 'g++' AS = PREFIX + 'gcc' @@ -76,5 +75,4 @@ if PLATFORM == 'gcc': M_POST_ACTION = STRIP + ' -R .hash $TARGET\n' + SIZE + ' $TARGET \n' DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n' - POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' +\ - SIZE + ' $TARGET \n' + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' diff --git a/tools/building.py b/tools/building.py index f471e3cb12..a8a24868ac 100644 --- a/tools/building.py +++ b/tools/building.py @@ -124,27 +124,28 @@ class Win32Spawn: # generate cconfig.h file def GenCconfigFile(env, BuildOptions): - if rtconfig.PLATFORM in ['gcc']: - contents = '' - if not os.path.isfile('cconfig.h'): - import gcc - gcc.GenerateGCCConfig(rtconfig) + # if rtconfig.PLATFORM in ['gcc']: + # contents = '' + # if not os.path.isfile('cconfig.h'): + # import gcc + # gcc.GenerateGCCConfig(rtconfig) - # try again - if os.path.isfile('cconfig.h'): - f = open('cconfig.h', 'r') - if f: - contents = f.read() - f.close() + # # try again + # if os.path.isfile('cconfig.h'): + # f = open('cconfig.h', 'r') + # if f: + # contents = f.read() + # f.close() - prep = PatchedPreProcessor() - prep.process_contents(contents) - options = prep.cpp_namespace + # prep = PatchedPreProcessor() + # prep.process_contents(contents) + # options = prep.cpp_namespace - BuildOptions.update(options) + # BuildOptions.update(options) - # add HAVE_CCONFIG_H definition - env.AppendUnique(CPPDEFINES = ['HAVE_CCONFIG_H']) + # # add HAVE_CCONFIG_H definition + # env.AppendUnique(CPPDEFINES = ['HAVE_CCONFIG_H']) + pass def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = []): @@ -202,22 +203,36 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ rtconfig.CROSS_TOOL, rtconfig.PLATFORM = tgt_dict[tgt_name] # replace the 'RTT_CC' to 'CROSS_TOOL' os.environ['RTT_CC'] = rtconfig.CROSS_TOOL - utils.ReloadModule(rtconfig) except KeyError: print('Unknow target: '+ tgt_name+'. Avaible targets: ' +', '.join(tgt_dict.keys())) sys.exit(1) + exec_prefix = GetOption('exec-prefix') + if exec_prefix: + os.environ['RTT_EXEC_PREFIX'] = exec_prefix + # auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed if not os.path.exists(rtconfig.EXEC_PATH): if 'RTT_EXEC_PATH' in os.environ: # del the 'RTT_EXEC_PATH' and using the 'EXEC_PATH' setting on rtconfig.py del os.environ['RTT_EXEC_PATH'] - utils.ReloadModule(rtconfig) exec_path = GetOption('exec-path') if exec_path: os.environ['RTT_EXEC_PATH'] = exec_path - utils.ReloadModule(rtconfig) + + utils.ReloadModule(rtconfig) # update environment variables to rtconfig.py + + # some env variables have loaded in SConsctruct Environment() before re-load rtconfig.py; + # after update rtconfig.py's variables, those env variables need to synchronize + if exec_prefix: + env['CC'] = rtconfig.CC + env['CXX'] = rtconfig.CXX + env['AS'] = rtconfig.AS + env['AR'] = rtconfig.AR + env['LINK'] = rtconfig.LINK + if exec_path: + env.PrependENVPath('PATH', rtconfig.EXEC_PATH) # add compability with Keil MDK 4.6 which changes the directory of armcc.exe if rtconfig.PLATFORM in ['armcc', 'armclang']: @@ -313,12 +328,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ if GetOption('pyconfig_silent'): from menuconfig import guiconfig_silent - guiconfig_silent(Rtt_Root) exit(0) + elif GetOption('pyconfig'): from menuconfig import guiconfig - guiconfig(Rtt_Root) exit(0) diff --git a/tools/options.py b/tools/options.py index db5f52f632..076f648ef8 100644 --- a/tools/options.py +++ b/tools/options.py @@ -85,6 +85,10 @@ def AddOptions(): dest = 'target', type = 'string', help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake') + AddOption('--exec-prefix', + dest = 'exec-prefix', + type = 'string', + help = 'set RTT_EXEC_PREFIX temperately') AddOption('--exec-path', dest = 'exec-path', type = 'string', diff --git a/tools/utils.py b/tools/utils.py index 0fa2aefcde..2d88176417 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -291,5 +291,3 @@ def ReloadModule(module): importlib.reload(module) else: reload(module) - - return |
