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.normpath(os.getcwd() + '/../../..') 9 10sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] 11try: 12 from building import * 13except: 14 print('Cannot found RT-Thread root directory, please check RTT_ROOT') 15 print(RTT_ROOT) 16 exit(-1) 17 18TARGET = 'rt-thread-' + rtconfig.DEVICE_PART + '.' + rtconfig.TARGET_EXT 19 20DefaultEnvironment(tools=[]) 21env = Environment(tools = ['mingw'], 22 AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, 23 CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, 24 AR = rtconfig.AR, ARFLAGS = '-rc', 25 CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, 26 LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) 27env.PrependENVPath('PATH', rtconfig.EXEC_PATH) 28 29if rtconfig.PLATFORM in ['iccarm']: 30 env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES']) 31 env.Replace(ARFLAGS = ['']) 32 env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread-'+ rtconfig.DEVICE_PART + '.map') 33 34Export('RTT_ROOT') 35Export('rtconfig') 36 37SDK_ROOT = os.path.abspath('./') 38 39if os.path.exists(SDK_ROOT + '/common'): 40 common_path_prefix = SDK_ROOT + '/common' 41else: 42 common_path_prefix = os.path.dirname(SDK_ROOT) + '/common' 43 44SDK_LIB = common_path_prefix 45Export('SDK_LIB') 46 47# prepare building environment 48objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) 49 50sam_board = 'board' 51rtconfig.BSP_LIBRARY_TYPE = sam_board 52 53# include libraries 54objs.extend(SConscript(os.path.join(common_path_prefix, sam_board, 'SConscript'))) 55 56# include drivers 57objs.extend(SConscript(os.path.join(common_path_prefix, 'applications', 'SConscript'))) 58 59# make a building 60DoBuilding(TARGET, objs) 61