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 = 'rtthread-lpc40xx.' + 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) 28 29if rtconfig.PLATFORM in ['gcc']: 30 import glob 31 # Remove the .o for M0 left on the drivers dir. 32 for i in glob.glob(GetCurrentDir() + '/../drivers/*.o'): 33 print('RM %s' % i) 34 os.unlink(i) 35 36 if sys.platform.startswith('linux'): 37 import glob 38 ocwd = os.getcwd() 39 res = os.system('cd ../Libraries/; find -name \*.o -exec rm {} \;') 40 os.chdir(ocwd) 41 else: 42 # Assume Windows. 43 ocwd = os.getcwd() 44 print('TODO: remove the object files in ../Libraries') 45 os.chdir(ocwd) 46 47# do building 48DoBuilding(TARGET, objs) 49