building.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. import os
  2. import sys
  3. import string
  4. from SCons.Script import *
  5. from utils import _make_path_relative
  6. BuildOptions = {}
  7. Projects = []
  8. Rtt_Root = ''
  9. Env = None
  10. class Win32Spawn:
  11. def spawn(self, sh, escape, cmd, args, env):
  12. import subprocess
  13. newargs = string.join(args[1:], ' ')
  14. cmdline = cmd + " " + newargs
  15. startupinfo = subprocess.STARTUPINFO()
  16. proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
  17. stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False)
  18. data, err = proc.communicate()
  19. rv = proc.wait()
  20. if data:
  21. print data
  22. if err:
  23. print err
  24. if rv:
  25. return rv
  26. return 0
  27. def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = []):
  28. import SCons.cpp
  29. import rtconfig
  30. global BuildOptions
  31. global Projects
  32. global Env
  33. global Rtt_Root
  34. Env = env
  35. Rtt_Root = root_directory
  36. # add compability with Keil MDK 4.6 which changes the directory of armcc.exe
  37. if rtconfig.PLATFORM == 'armcc':
  38. if not os.path.isfile(os.path.join(rtconfig.EXEC_PATH, 'armcc.exe')):
  39. if rtconfig.EXEC_PATH.find('bin40') > 0:
  40. rtconfig.EXEC_PATH = rtconfig.EXEC_PATH.replace('bin40', 'armcc/bin')
  41. Env['LINKFLAGS']=Env['LINKFLAGS'].replace('RV31', 'armcc')
  42. # reset AR command flags
  43. env['ARCOM'] = '$AR --create $TARGET $SOURCES'
  44. env['LIBPREFIX'] = ''
  45. env['LIBSUFFIX'] = '.lib'
  46. env['LIBLINKPREFIX'] = ''
  47. env['LIBLINKSUFFIX'] = '.lib'
  48. env['LIBDIRPREFIX'] = '--userlibpath '
  49. # patch for win32 spawn
  50. if env['PLATFORM'] == 'win32' and rtconfig.PLATFORM == 'gcc':
  51. win32_spawn = Win32Spawn()
  52. win32_spawn.env = env
  53. env['SPAWN'] = win32_spawn.spawn
  54. if env['PLATFORM'] == 'win32':
  55. os.environ['PATH'] = rtconfig.EXEC_PATH + ";" + os.environ['PATH']
  56. else:
  57. os.environ['PATH'] = rtconfig.EXEC_PATH + ":" + os.environ['PATH']
  58. # add program path
  59. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  60. # add library build action
  61. act = SCons.Action.Action(BuildLibInstallAction, 'Install compiled library... $TARGET')
  62. bld = Builder(action = act)
  63. Env.Append(BUILDERS = {'BuildLib': bld})
  64. # parse rtconfig.h to get used component
  65. PreProcessor = SCons.cpp.PreProcessor()
  66. f = file('rtconfig.h', 'r')
  67. contents = f.read()
  68. f.close()
  69. PreProcessor.process_contents(contents)
  70. BuildOptions = PreProcessor.cpp_namespace
  71. # add copy option
  72. AddOption('--copy',
  73. dest='copy',
  74. action='store_true',
  75. default=False,
  76. help='copy rt-thread directory to local.')
  77. AddOption('--copy-header',
  78. dest='copy-header',
  79. action='store_true',
  80. default=False,
  81. help='copy header of rt-thread directory to local.')
  82. AddOption('--cscope',
  83. dest='cscope',
  84. action='store_true',
  85. default=False,
  86. help='Build Cscope cross reference database. Requires cscope installed.')
  87. AddOption('--clang-analyzer',
  88. dest='clang-analyzer',
  89. action='store_true',
  90. default=False,
  91. help='Perform static analyze with Clang-analyzer. '+\
  92. 'Requires Clang installed.\n'+\
  93. 'It is recommended to use with scan-build like this:\n'+\
  94. '`scan-build scons --clang-analyzer`\n'+\
  95. 'If things goes well, scan-build will instruct you to invoke scan-view.')
  96. if GetOption('clang-analyzer'):
  97. # perform what scan-build does
  98. env.Replace(
  99. CC = 'ccc-analyzer',
  100. CXX = 'c++-analyzer',
  101. # skip as and link
  102. LINK = 'true',
  103. AS = 'true',)
  104. env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_"))
  105. # only check, don't compile. ccc-analyzer use CCC_CC as the CC.
  106. # fsyntax-only will give us some additional warning messages
  107. env['ENV']['CCC_CC'] = 'clang'
  108. env.Append(CFLAGS=['-fsyntax-only', '-Wall', '-Wno-invalid-source-encoding'])
  109. env['ENV']['CCC_CXX'] = 'clang++'
  110. env.Append(CXXFLAGS=['-fsyntax-only', '-Wall', '-Wno-invalid-source-encoding'])
  111. # remove the POST_ACTION as it will cause meaningless errors(file not
  112. # found or something like that).
  113. rtconfig.POST_ACTION = ''
  114. # add build library option
  115. AddOption('--buildlib',
  116. dest='buildlib',
  117. type='string',
  118. help='building library of a component')
  119. AddOption('--cleanlib',
  120. dest='cleanlib',
  121. action='store_true',
  122. default=False,
  123. help='clean up the library by --buildlib')
  124. # add target option
  125. AddOption('--target',
  126. dest='target',
  127. type='string',
  128. help='set target project: mdk/iar/vs')
  129. #{target_name:(CROSS_TOOL, PLATFORM)}
  130. tgt_dict = {'mdk':('keil', 'armcc'),
  131. 'mdk4':('keil', 'armcc'),
  132. 'iar':('iar', 'iar'),
  133. 'vs':('msvc', 'cl'),
  134. 'vs2012':('msvc', 'cl'),
  135. 'cb':('keil', 'armcc')}
  136. tgt_name = GetOption('target')
  137. if tgt_name:
  138. # --target will change the toolchain settings which clang-analyzer is
  139. # depend on
  140. if GetOption('clang-analyzer'):
  141. print '--clang-analyzer cannot be used with --target'
  142. sys.exit(1)
  143. SetOption('no_exec', 1)
  144. try:
  145. rtconfig.CROSS_TOOL, rtconfig.PLATFORM = tgt_dict[tgt_name]
  146. except KeyError:
  147. print 'Unknow target: %s. Avaible targets: %s' % \
  148. (tgt_name, ', '.join(tgt_dict.keys()))
  149. sys.exit(1)
  150. elif (GetDepend('RT_USING_NEWLIB') == False and GetDepend('RT_USING_NOLIBC') == False) \
  151. and rtconfig.PLATFORM == 'gcc':
  152. AddDepend('RT_USING_MINILIBC')
  153. # add comstr option
  154. AddOption('--verbose',
  155. dest='verbose',
  156. action='store_true',
  157. default=False,
  158. help='print verbose information during build')
  159. if not GetOption('verbose'):
  160. # override the default verbose command string
  161. env.Replace(
  162. ARCOMSTR = 'AR $TARGET',
  163. ASCOMSTR = 'AS $TARGET',
  164. ASPPCOMSTR = 'AS $TARGET',
  165. CCCOMSTR = 'CC $TARGET',
  166. CXXCOMSTR = 'CXX $TARGET',
  167. LINKCOMSTR = 'LINK $TARGET'
  168. )
  169. # board build script
  170. objs = SConscript('SConscript', variant_dir='build', duplicate=0)
  171. Repository(Rtt_Root)
  172. # include kernel
  173. objs.extend(SConscript(Rtt_Root + '/src/SConscript', variant_dir='build/src', duplicate=0))
  174. # include libcpu
  175. if not has_libcpu:
  176. objs.extend(SConscript(Rtt_Root + '/libcpu/SConscript', variant_dir='build/libcpu', duplicate=0))
  177. # include components
  178. objs.extend(SConscript(Rtt_Root + '/components/SConscript',
  179. variant_dir='build/components',
  180. duplicate=0,
  181. exports='remove_components'))
  182. return objs
  183. def PrepareModuleBuilding(env, root_directory):
  184. import SCons.cpp
  185. import rtconfig
  186. global BuildOptions
  187. global Projects
  188. global Env
  189. global Rtt_Root
  190. Env = env
  191. Rtt_Root = root_directory
  192. # add program path
  193. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  194. def GetConfigValue(name):
  195. assert type(name) == str, 'GetConfigValue: only string parameter is valid'
  196. try:
  197. return BuildOptions[name]
  198. except:
  199. return ''
  200. def GetDepend(depend):
  201. building = True
  202. if type(depend) == type('str'):
  203. if not BuildOptions.has_key(depend) or BuildOptions[depend] == 0:
  204. building = False
  205. elif BuildOptions[depend] != '':
  206. return BuildOptions[depend]
  207. return building
  208. # for list type depend
  209. for item in depend:
  210. if item != '':
  211. if not BuildOptions.has_key(item) or BuildOptions[item] == 0:
  212. building = False
  213. return building
  214. def AddDepend(option):
  215. BuildOptions[option] = 1
  216. def MergeGroup(src_group, group):
  217. src_group['src'] = src_group['src'] + group['src']
  218. if group.has_key('CCFLAGS'):
  219. if src_group.has_key('CCFLAGS'):
  220. src_group['CCFLAGS'] = src_group['CCFLAGS'] + group['CCFLAGS']
  221. else:
  222. src_group['CCFLAGS'] = group['CCFLAGS']
  223. if group.has_key('CPPPATH'):
  224. if src_group.has_key('CPPPATH'):
  225. src_group['CPPPATH'] = src_group['CPPPATH'] + group['CPPPATH']
  226. else:
  227. src_group['CPPPATH'] = group['CPPPATH']
  228. if group.has_key('CPPDEFINES'):
  229. if src_group.has_key('CPPDEFINES'):
  230. src_group['CPPDEFINES'] = src_group['CPPDEFINES'] + group['CPPDEFINES']
  231. else:
  232. src_group['CPPDEFINES'] = group['CPPDEFINES']
  233. if group.has_key('LINKFLAGS'):
  234. if src_group.has_key('LINKFLAGS'):
  235. src_group['LINKFLAGS'] = src_group['LINKFLAGS'] + group['LINKFLAGS']
  236. else:
  237. src_group['LINKFLAGS'] = group['LINKFLAGS']
  238. if group.has_key('LIBS'):
  239. if src_group.has_key('LIBS'):
  240. src_group['LIBS'] = src_group['LIBS'] + group['LIBS']
  241. else:
  242. src_group['LIBS'] = group['LIBS']
  243. if group.has_key('LIBPATH'):
  244. if src_group.has_key('LIBPATH'):
  245. src_group['LIBPATH'] = src_group['LIBPATH'] + group['LIBPATH']
  246. else:
  247. src_group['LIBPATH'] = group['LIBPATH']
  248. if src_group.has_key('LIBS'):
  249. print src_group['LIBS']
  250. if src_group.has_key('LIBS'):
  251. print src_group['LIBPATH']
  252. def DefineGroup(name, src, depend, **parameters):
  253. global Env
  254. if not GetDepend(depend):
  255. return []
  256. # find exist group and get path of group
  257. group_path = ''
  258. for g in Projects:
  259. if g['name'] == name:
  260. group_path = g['path']
  261. if group_path == '':
  262. group_path = GetCurrentDir()
  263. group = parameters
  264. group['name'] = name
  265. group['path'] = group_path
  266. if type(src) == type(['src1']):
  267. group['src'] = File(src)
  268. else:
  269. group['src'] = src
  270. if group.has_key('CCFLAGS'):
  271. Env.Append(CCFLAGS = group['CCFLAGS'])
  272. if group.has_key('CPPPATH'):
  273. Env.Append(CPPPATH = group['CPPPATH'])
  274. if group.has_key('CPPDEFINES'):
  275. Env.Append(CPPDEFINES = group['CPPDEFINES'])
  276. if group.has_key('LINKFLAGS'):
  277. Env.Append(LINKFLAGS = group['LINKFLAGS'])
  278. # check whether to clean up library
  279. if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
  280. if group['src'] != []:
  281. print 'Remove library:', GroupLibFullName(name, Env)
  282. do_rm_file(os.path.join(group['path'], GroupLibFullName(name, Env)))
  283. # check whether exist group library
  284. if not GetOption('buildlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
  285. Env.Append(LIBS = [GroupLibName(name, Env)])
  286. group['src'] = []
  287. Env.Append(LIBPATH = [GetCurrentDir()])
  288. if group.has_key('LIBS'):
  289. Env.Append(LIBS = group['LIBS'])
  290. if group.has_key('LIBPATH'):
  291. Env.Append(LIBPATH = group['LIBPATH'])
  292. objs = Env.Object(group['src'])
  293. if group.has_key('LIBRARY'):
  294. objs = Env.Library(name, objs)
  295. # merge group
  296. for g in Projects:
  297. if g['name'] == name:
  298. # merge to this group
  299. MergeGroup(g, group)
  300. return objs
  301. # add a new group
  302. Projects.append(group)
  303. return objs
  304. def GetCurrentDir():
  305. conscript = File('SConscript')
  306. fn = conscript.rfile()
  307. name = fn.name
  308. path = os.path.dirname(fn.abspath)
  309. return path
  310. PREBUILDING = []
  311. def RegisterPreBuildingAction(act):
  312. global PREBUILDING
  313. assert callable(act), 'Could only register callable objects. %s received' % repr(act)
  314. PREBUILDING.append(act)
  315. def PreBuilding():
  316. global PREBUILDING
  317. for a in PREBUILDING:
  318. a()
  319. def GroupLibName(name, env):
  320. import rtconfig
  321. if rtconfig.PLATFORM == 'armcc':
  322. return name + '_rvds'
  323. elif rtconfig.PLATFORM == 'gcc':
  324. return name + '_gcc'
  325. return name
  326. def GroupLibFullName(name, env):
  327. return env['LIBPREFIX'] + GroupLibName(name, env) + env['LIBSUFFIX']
  328. def BuildLibInstallAction(target, source, env):
  329. lib_name = GetOption('buildlib')
  330. for Group in Projects:
  331. if Group['name'] == lib_name:
  332. lib_name = GroupLibFullName(Group['name'], env)
  333. dst_name = os.path.join(Group['path'], lib_name)
  334. print 'Copy %s => %s' % (lib_name, dst_name)
  335. do_copy_file(lib_name, dst_name)
  336. break
  337. def DoBuilding(target, objects):
  338. program = None
  339. # check whether special buildlib option
  340. lib_name = GetOption('buildlib')
  341. if lib_name:
  342. # build library with special component
  343. for Group in Projects:
  344. if Group['name'] == lib_name:
  345. lib_name = GroupLibName(Group['name'], Env)
  346. objects = Env.Object(Group['src'])
  347. program = Env.Library(lib_name, objects)
  348. # add library copy action
  349. Env.BuildLib(lib_name, program)
  350. break
  351. else:
  352. # merge the repeated items in the Env
  353. if Env.has_key('CPPPATH') : Env['CPPPATH'] = list(set(Env['CPPPATH']))
  354. if Env.has_key('CPPDEFINES'): Env['CPPDEFINES'] = list(set(Env['CPPDEFINES']))
  355. if Env.has_key('LIBPATH') : Env['LIBPATH'] = list(set(Env['LIBPATH']))
  356. if Env.has_key('LIBS') : Env['LIBS'] = list(set(Env['LIBS']))
  357. program = Env.Program(target, objects)
  358. EndBuilding(target, program)
  359. def EndBuilding(target, program = None):
  360. import rtconfig
  361. from keil import MDKProject
  362. from keil import MDK4Project
  363. from iar import IARProject
  364. from vs import VSProject
  365. from vs2012 import VS2012Project
  366. from codeblocks import CBProject
  367. Env.AddPostAction(target, rtconfig.POST_ACTION)
  368. if GetOption('target') == 'mdk':
  369. template = os.path.isfile('template.Uv2')
  370. if template:
  371. MDKProject('project.Uv2', Projects)
  372. else:
  373. template = os.path.isfile('template.uvproj')
  374. if template:
  375. MDK4Project('project.uvproj', Projects)
  376. else:
  377. print 'No template project file found.'
  378. if GetOption('target') == 'mdk4':
  379. MDK4Project('project.uvproj', Projects)
  380. if GetOption('target') == 'iar':
  381. IARProject('project.ewp', Projects)
  382. if GetOption('target') == 'vs':
  383. VSProject('project.vcproj', Projects, program)
  384. if GetOption('target') == 'vs2012':
  385. VS2012Project('project.vcxproj', Projects, program)
  386. if GetOption('target') == 'cb':
  387. CBProject('project.cbp', Projects, program)
  388. if GetOption('copy') and program != None:
  389. MakeCopy(program)
  390. if GetOption('copy-header') and program != None:
  391. MakeCopyHeader(program)
  392. if GetOption('cscope'):
  393. from cscope import CscopeDatabase
  394. CscopeDatabase(Projects)
  395. def SrcRemove(src, remove):
  396. if type(src[0]) == type('str'):
  397. for item in src:
  398. if os.path.basename(item) in remove:
  399. src.remove(item)
  400. return
  401. for item in src:
  402. if os.path.basename(item.rstr()) in remove:
  403. src.remove(item)
  404. def GetVersion():
  405. import SCons.cpp
  406. import string
  407. rtdef = os.path.join(Rtt_Root, 'include', 'rtdef.h')
  408. # parse rtdef.h to get RT-Thread version
  409. prepcessor = SCons.cpp.PreProcessor()
  410. f = file(rtdef, 'r')
  411. contents = f.read()
  412. f.close()
  413. prepcessor.process_contents(contents)
  414. def_ns = prepcessor.cpp_namespace
  415. version = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_VERSION']))
  416. subversion = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_SUBVERSION']))
  417. if def_ns.has_key('RT_REVISION'):
  418. revision = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_REVISION']))
  419. return '%d.%d.%d' % (version, subversion, revision)
  420. return '0.%d.%d' % (version, subversion)
  421. def GlobSubDir(sub_dir, ext_name):
  422. import os
  423. import glob
  424. def glob_source(sub_dir, ext_name):
  425. list = os.listdir(sub_dir)
  426. src = glob.glob(os.path.join(sub_dir, ext_name))
  427. for item in list:
  428. full_subdir = os.path.join(sub_dir, item)
  429. if os.path.isdir(full_subdir):
  430. src += glob_source(full_subdir, ext_name)
  431. return src
  432. dst = []
  433. src = glob_source(sub_dir, ext_name)
  434. for item in src:
  435. dst.append(os.path.relpath(item, sub_dir))
  436. return dst
  437. def file_path_exist(path, *args):
  438. return os.path.exists(os.path.join(path, *args))
  439. def do_rm_file(src):
  440. if os.path.exists(src):
  441. os.unlink(src)
  442. def do_copy_file(src, dst):
  443. import shutil
  444. # check source file
  445. if not os.path.exists(src):
  446. return
  447. path = os.path.dirname(dst)
  448. # mkdir if path not exist
  449. if not os.path.exists(path):
  450. os.makedirs(path)
  451. shutil.copy2(src, dst)
  452. def do_copy_folder(src_dir, dst_dir):
  453. import shutil
  454. # check source directory
  455. if not os.path.exists(src_dir):
  456. return
  457. if os.path.exists(dst_dir):
  458. shutil.rmtree(dst_dir)
  459. shutil.copytree(src_dir, dst_dir)
  460. source_ext = ["c", "h", "s", "S", "cpp", "xpm"]
  461. source_list = []
  462. def walk_children(child):
  463. global source_list
  464. global source_ext
  465. # print child
  466. full_path = child.rfile().abspath
  467. file_type = full_path.rsplit('.',1)[1]
  468. #print file_type
  469. if file_type in source_ext:
  470. if full_path not in source_list:
  471. source_list.append(full_path)
  472. children = child.all_children()
  473. if children != []:
  474. for item in children:
  475. walk_children(item)
  476. def MakeCopy(program):
  477. global source_list
  478. global Rtt_Root
  479. global Env
  480. target_path = os.path.join(Dir('#').abspath, 'rt-thread')
  481. if Env['PLATFORM'] == 'win32':
  482. RTT_ROOT = Rtt_Root.lower()
  483. else:
  484. RTT_ROOT = Rtt_Root
  485. if target_path.startswith(RTT_ROOT):
  486. return
  487. for item in program:
  488. walk_children(item)
  489. source_list.sort()
  490. # filte source file in RT-Thread
  491. target_list = []
  492. for src in source_list:
  493. if Env['PLATFORM'] == 'win32':
  494. src = src.lower()
  495. if src.startswith(RTT_ROOT):
  496. target_list.append(src)
  497. source_list = target_list
  498. # get source path
  499. src_dir = []
  500. for src in source_list:
  501. src = src.replace(RTT_ROOT, '')
  502. if src[0] == os.sep or src[0] == '/':
  503. src = src[1:]
  504. path = os.path.dirname(src)
  505. sub_path = path.split(os.sep)
  506. full_path = RTT_ROOT
  507. for item in sub_path:
  508. full_path = os.path.join(full_path, item)
  509. if full_path not in src_dir:
  510. src_dir.append(full_path)
  511. for item in src_dir:
  512. source_list.append(os.path.join(item, 'SConscript'))
  513. for src in source_list:
  514. dst = src.replace(RTT_ROOT, '')
  515. if dst[0] == os.sep or dst[0] == '/':
  516. dst = dst[1:]
  517. print '=> ', dst
  518. dst = os.path.join(target_path, dst)
  519. do_copy_file(src, dst)
  520. # copy tools directory
  521. print "=> tools"
  522. do_copy_folder(os.path.join(RTT_ROOT, "tools"), os.path.join(target_path, "tools"))
  523. do_copy_file(os.path.join(RTT_ROOT, 'AUTHORS'), os.path.join(target_path, 'AUTHORS'))
  524. do_copy_file(os.path.join(RTT_ROOT, 'COPYING'), os.path.join(target_path, 'COPYING'))
  525. def MakeCopyHeader(program):
  526. global source_ext
  527. source_ext = []
  528. source_ext = ["h", "xpm"]
  529. global source_list
  530. global Rtt_Root
  531. global Env
  532. target_path = os.path.join(Dir('#').abspath, 'rt-thread')
  533. if Env['PLATFORM'] == 'win32':
  534. RTT_ROOT = Rtt_Root.lower()
  535. else:
  536. RTT_ROOT = Rtt_Root
  537. if target_path.startswith(RTT_ROOT):
  538. return
  539. for item in program:
  540. walk_children(item)
  541. source_list.sort()
  542. # filte source file in RT-Thread
  543. target_list = []
  544. for src in source_list:
  545. if Env['PLATFORM'] == 'win32':
  546. src = src.lower()
  547. if src.startswith(RTT_ROOT):
  548. target_list.append(src)
  549. source_list = target_list
  550. for src in source_list:
  551. dst = src.replace(RTT_ROOT, '')
  552. if dst[0] == os.sep or dst[0] == '/':
  553. dst = dst[1:]
  554. print '=> ', dst
  555. dst = os.path.join(target_path, dst)
  556. do_copy_file(src, dst)
  557. # copy tools directory
  558. print "=> tools"
  559. do_copy_folder(os.path.join(RTT_ROOT, "tools"), os.path.join(target_path, "tools"))
  560. do_copy_file(os.path.join(RTT_ROOT, 'AUTHORS'), os.path.join(target_path, 'AUTHORS'))
  561. do_copy_file(os.path.join(RTT_ROOT, 'COPYING'), os.path.join(target_path, 'COPYING'))