1import os 2import sys 3import rtconfig 4 5if os.getenv('RTT_ROOT'): 6 RTT_ROOT = os.getenv('RTT_ROOT') 7else: 8 RTT_ROOT = os.path.join(Dir('#').get_abspath(), '..', '..', '..', '..', '..') 9 10sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] 11from building import * 12 13TARGET = 'build/rtthread_lpc43xx.' + rtconfig.TARGET_EXT 14 15DefaultEnvironment(tools=[]) 16env = Environment(tools = ['mingw'], 17 AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, 18 CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS, 19 AR = rtconfig.AR, ARFLAGS = '-rc', 20 LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) 21env.PrependENVPath('PATH', rtconfig.EXEC_PATH) 22 23Export('RTT_ROOT') 24Export('rtconfig') 25 26# prepare building environment 27objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) 28import glob 29if rtconfig.PLATFORM in ['gcc']: 30 print('build M0 code first') 31 if sys.platform.startswith('linux'): 32 33 ocwd = os.getcwd() 34 os.chdir('../M0') 35 res = os.system('scons') 36 if res: 37 print('build M0 exit with code %d\n' % res) 38 sys.exit(res) 39 os.chdir(ocwd) 40 res = os.system('cd ../Libraries/; find -name \*.o -exec rm {} \;') 41 os.chdir(ocwd) 42 else: 43 # Assume Windows. 44 ocwd = os.getcwd() 45 os.chdir('..\M0') 46 os.system('scons.bat') 47 os.chdir(ocwd) 48 49 # Remove the .o for M0 left on the drivers dir. 50 for i in glob.glob(GetCurrentDir() + '/../drivers/*.o'): 51 print('RM %s' % i) 52 os.unlink(i) 53 54# do building 55DoBuilding(TARGET, objs) 56