From f8bbcf9aef8d82fa802fbb0b06e6453cb435c768 Mon Sep 17 00:00:00 2001 From: "chaos.proton@gmail.com" Date: Wed, 9 Nov 2011 02:42:48 +0000 Subject: [PATCH] if --target is set, adjust CROSS_TOOL and PLATFORM automatically git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1792 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- tools/building.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tools/building.py b/tools/building.py index 5cf225428c..9167581644 100644 --- a/tools/building.py +++ b/tools/building.py @@ -476,17 +476,28 @@ def PrepareBuilding(env, root_directory, has_libcpu=False): PreProcessor.process_contents(contents) BuildOptions = PreProcessor.cpp_namespace - if (GetDepend('RT_USING_NEWLIB') == False and GetDepend('RT_USING_NOLIBC') == False) and rtconfig.PLATFORM == 'gcc': - AddDepend('RT_USING_MINILIBC') - # add target option AddOption('--target', dest='target', type='string', help='set target project: mdk') - if GetOption('target'): + #{target_name:(CROSS_TOOL, PLATFORM)} + tgt_dict = {'mdk':('keil', 'armcc'), + 'mdk4':('keil', 'armcc'), + 'iar':('iar', 'iar')} + tgt_name = GetOption('target') + if tgt_name: SetOption('no_exec', 1) + try: + rtconfig.CROSS_TOOL, rtconfig.PLATFORM = tgt_dict[tgt_name] + except KeyError: + print 'Unknow target: %s. Avaible targets: %s' % \ + (tgt_name, ', '.join(tgt_dict.keys())) + sys.exit(1) + elif (GetDepend('RT_USING_NEWLIB') == False and GetDepend('RT_USING_NOLIBC') == False) \ + and rtconfig.PLATFORM == 'gcc': + AddDepend('RT_USING_MINILIBC') #env['CCCOMSTR'] = "CC $TARGET" #env['ASCOMSTR'] = "AS $TARGET" @@ -584,10 +595,6 @@ def EndBuilding(target): if GetOption('target') == 'mdk': template = os.path.isfile('template.Uv2') - if rtconfig.CROSS_TOOL != 'keil': - print 'Please use Keil MDK compiler in rtconfig.py' - return - if template: MDKProject('project.Uv2', Projects) else: @@ -598,13 +605,7 @@ def EndBuilding(target): print 'No template project file found.' if GetOption('target') == 'mdk4': - if rtconfig.CROSS_TOOL != 'keil': - print 'Please use Keil MDK compiler in rtconfig.py' - return MDK4Project('project.uvproj', Projects) - + if GetOption('target') == 'iar': - if rtconfig.CROSS_TOOL != 'iar': - print 'Please use IAR compiler in rtconfig.py' - return IARProject('project.ewp', Projects)