Skip to content

Commit 4dd0e67

Browse files
authored
[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变量提前预载之后重载变量的问题
1 parent a64750e commit 4dd0e67

File tree

4 files changed

+42
-28
lines changed

4 files changed

+42
-28
lines changed

bsp/qemu-vexpress-a9/rtconfig.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ def get_mac_address():
3737
LINK_SCRIPT = 'link.lds'
3838

3939
if PLATFORM == 'gcc':
40-
# toolchains
41-
PREFIX = os.getenv('RTT_CC_PREFIX') or 'arm-none-eabi-'
40+
PREFIX = os.getenv('RTT_EXEC_PREFIX') or 'arm-none-eabi-'
4241
CC = PREFIX + 'gcc'
4342
CXX = PREFIX + 'g++'
4443
AS = PREFIX + 'gcc'
@@ -76,5 +75,4 @@ def get_mac_address():
7675
M_POST_ACTION = STRIP + ' -R .hash $TARGET\n' + SIZE + ' $TARGET \n'
7776

7877
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
79-
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' +\
80-
SIZE + ' $TARGET \n'
78+
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'

tools/building.py

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,27 +124,28 @@ def spawn(self, sh, escape, cmd, args, env):
124124
# generate cconfig.h file
125125
def GenCconfigFile(env, BuildOptions):
126126

127-
if rtconfig.PLATFORM in ['gcc']:
128-
contents = ''
129-
if not os.path.isfile('cconfig.h'):
130-
import gcc
131-
gcc.GenerateGCCConfig(rtconfig)
127+
# if rtconfig.PLATFORM in ['gcc']:
128+
# contents = ''
129+
# if not os.path.isfile('cconfig.h'):
130+
# import gcc
131+
# gcc.GenerateGCCConfig(rtconfig)
132132

133-
# try again
134-
if os.path.isfile('cconfig.h'):
135-
f = open('cconfig.h', 'r')
136-
if f:
137-
contents = f.read()
138-
f.close()
133+
# # try again
134+
# if os.path.isfile('cconfig.h'):
135+
# f = open('cconfig.h', 'r')
136+
# if f:
137+
# contents = f.read()
138+
# f.close()
139139

140-
prep = PatchedPreProcessor()
141-
prep.process_contents(contents)
142-
options = prep.cpp_namespace
140+
# prep = PatchedPreProcessor()
141+
# prep.process_contents(contents)
142+
# options = prep.cpp_namespace
143143

144-
BuildOptions.update(options)
144+
# BuildOptions.update(options)
145145

146-
# add HAVE_CCONFIG_H definition
147-
env.AppendUnique(CPPDEFINES = ['HAVE_CCONFIG_H'])
146+
# # add HAVE_CCONFIG_H definition
147+
# env.AppendUnique(CPPDEFINES = ['HAVE_CCONFIG_H'])
148+
pass
148149

149150
def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = []):
150151

@@ -202,22 +203,36 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
202203
rtconfig.CROSS_TOOL, rtconfig.PLATFORM = tgt_dict[tgt_name]
203204
# replace the 'RTT_CC' to 'CROSS_TOOL'
204205
os.environ['RTT_CC'] = rtconfig.CROSS_TOOL
205-
utils.ReloadModule(rtconfig)
206206
except KeyError:
207207
print('Unknow target: '+ tgt_name+'. Avaible targets: ' +', '.join(tgt_dict.keys()))
208208
sys.exit(1)
209209

210+
exec_prefix = GetOption('exec-prefix')
211+
if exec_prefix:
212+
os.environ['RTT_EXEC_PREFIX'] = exec_prefix
213+
210214
# auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed
211215
if not os.path.exists(rtconfig.EXEC_PATH):
212216
if 'RTT_EXEC_PATH' in os.environ:
213217
# del the 'RTT_EXEC_PATH' and using the 'EXEC_PATH' setting on rtconfig.py
214218
del os.environ['RTT_EXEC_PATH']
215-
utils.ReloadModule(rtconfig)
216219

217220
exec_path = GetOption('exec-path')
218221
if exec_path:
219222
os.environ['RTT_EXEC_PATH'] = exec_path
220-
utils.ReloadModule(rtconfig)
223+
224+
utils.ReloadModule(rtconfig) # update environment variables to rtconfig.py
225+
226+
# some env variables have loaded in SConsctruct Environment() before re-load rtconfig.py;
227+
# after update rtconfig.py's variables, those env variables need to synchronize
228+
if exec_prefix:
229+
env['CC'] = rtconfig.CC
230+
env['CXX'] = rtconfig.CXX
231+
env['AS'] = rtconfig.AS
232+
env['AR'] = rtconfig.AR
233+
env['LINK'] = rtconfig.LINK
234+
if exec_path:
235+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
221236

222237
# add compability with Keil MDK 4.6 which changes the directory of armcc.exe
223238
if rtconfig.PLATFORM in ['armcc', 'armclang']:
@@ -313,12 +328,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
313328

314329
if GetOption('pyconfig_silent'):
315330
from menuconfig import guiconfig_silent
316-
317331
guiconfig_silent(Rtt_Root)
318332
exit(0)
333+
319334
elif GetOption('pyconfig'):
320335
from menuconfig import guiconfig
321-
322336
guiconfig(Rtt_Root)
323337
exit(0)
324338

tools/options.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ def AddOptions():
8585
dest = 'target',
8686
type = 'string',
8787
help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake')
88+
AddOption('--exec-prefix',
89+
dest = 'exec-prefix',
90+
type = 'string',
91+
help = 'set RTT_EXEC_PREFIX temperately')
8892
AddOption('--exec-path',
8993
dest = 'exec-path',
9094
type = 'string',

tools/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,5 +291,3 @@ def ReloadModule(module):
291291
importlib.reload(module)
292292
else:
293293
reload(module)
294-
295-
return

0 commit comments

Comments
 (0)