From 8e95bc94b6b18acf2a6c868d12fb36d2d174b1bf Mon Sep 17 00:00:00 2001 From: "bernard.xiong@gmail.com" Date: Wed, 22 Aug 2012 06:19:04 +0000 Subject: [PATCH] add --copy-header option to copy header of RT-Thread to local. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2257 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- tools/building.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/tools/building.py b/tools/building.py index 8373d3ccd..f59d856bd 100644 --- a/tools/building.py +++ b/tools/building.py @@ -71,7 +71,12 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ action='store_true', default=False, help='copy rt-thread directory to local.') - + AddOption('--copy-header', + dest='copy-header', + action='store_true', + default=False, + help='copy header of rt-thread directory to local.') + # add target option AddOption('--target', dest='target', @@ -252,6 +257,8 @@ def EndBuilding(target, program = None): if GetOption('copy') and program != None: MakeCopy(program) + if GetOption('copy-header') and program != None: + MakeCopyHeader(program) def SrcRemove(src, remove): if type(src[0]) == type('str'): @@ -392,3 +399,51 @@ def MakeCopy(program): do_copy_folder(os.path.join(RTT_ROOT, "tools"), os.path.join(target_path, "tools")) do_copy_file(os.path.join(RTT_ROOT, 'AUTHORS'), os.path.join(target_path, 'AUTHORS')) do_copy_file(os.path.join(RTT_ROOT, 'COPYING'), os.path.join(target_path, 'COPYING')) + +def MakeCopyHeader(program): + global source_ext + source_ext = [] + source_ext = ["h", "xpm"] + global source_list + global Rtt_Root + global Env + + target_path = os.path.join(Dir('#').abspath, 'rt-thread') + + if Env['PLATFORM'] == 'win32': + RTT_ROOT = Rtt_Root.lower() + else: + RTT_ROOT = Rtt_Root + + if target_path.startswith(RTT_ROOT): + return + + for item in program: + walk_children(item) + + source_list.sort() + + # filte source file in RT-Thread + target_list = [] + for src in source_list: + if Env['PLATFORM'] == 'win32': + src = src.lower() + + if src.startswith(RTT_ROOT): + target_list.append(src) + + source_list = target_list + + for src in source_list: + dst = src.replace(RTT_ROOT, '') + if dst[0] == os.sep or dst[0] == '/': + dst = dst[1:] + print '=> ', dst + dst = os.path.join(target_path, dst) + do_copy_file(src, dst) + + # copy tools directory + print "=> tools" + do_copy_folder(os.path.join(RTT_ROOT, "tools"), os.path.join(target_path, "tools")) + do_copy_file(os.path.join(RTT_ROOT, 'AUTHORS'), os.path.join(target_path, 'AUTHORS')) + do_copy_file(os.path.join(RTT_ROOT, 'COPYING'), os.path.join(target_path, 'COPYING')) -- GitLab