1import os 2import sys 3import rtconfig 4from SCons.Script import * 5 6if os.getenv('RTT_ROOT'): 7 RTT_ROOT = os.getenv('RTT_ROOT') 8else: 9 RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..') 10print(RTT_ROOT) 11sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]# 模块搜索路径 12try: 13 from building import * 14except: 15 print('Cannot found RT-Thread root directory, please check RTT_ROOT') 16 print(RTT_ROOT) 17 exit(-1) 18 19TARGET = 'rtthread.' + rtconfig.TARGET_EXT 20 21DefaultEnvironment(tools=[]) 22env = Environment(tools = ['mingw'], 23 AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, 24 CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS, 25 AR = rtconfig.AR, ARFLAGS = '-rc', 26 CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, 27 LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) 28env.PrependENVPath('PATH', rtconfig.EXEC_PATH) 29 30if rtconfig.PLATFORM in ['iccarm']: 31 env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES']) 32 env.Replace(ARFLAGS = ['']) 33 env.Replace(LINKCOM = env["LINKCOM"] + ' --map project.map') 34 35Export('RTT_ROOT') 36Export('rtconfig') 37 38SDK_ROOT = os.path.abspath('./') #当前脚本所在路径的绝对地址 39#SDK_ROOT = E:\rt-thread\bsp\core-v-mcu\core-v-cv32e40p 40 41if os.path.exists(SDK_ROOT + '/Libraries'): 42 libraries_path_prefix = SDK_ROOT + '/Libraries' 43else: 44 libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/Libraries' 45#libraries_path_prefix = E:\rt-thread\bsp\core-v-mcu\Libraries 46SDK_LIB = libraries_path_prefix 47Export('SDK_LIB') 48#SDK_LIB = E:\rt-thread\bsp\core-v-mcu\Libraries 49 50# prepare building environment 51objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) 52 53core_v_library = 'core_v_hal_libraries' 54rtconfig.BSP_LIBRARY_TYPE = core_v_library 55 56bsp_vdir = 'build' 57library_vdir = 'build/libraries' 58 59#libraries_path_prefix = E:\rt-thread\bsp\core-v-mcu\Libraries 60#objs.extend 将扩展列表的元素都加到 objs列表中 61# include libraries 62objs.extend(SConscript(os.path.join(libraries_path_prefix, core_v_library, 'SConscript'), variant_dir=library_vdir + '/core_v_hal_libraries', duplicate=0)) 63 64# common include drivers 65objs.extend(SConscript(os.path.join(libraries_path_prefix, 'core_v_drivers', 'SConscript'), variant_dir=library_vdir + '/core_v_drivers', duplicate=0)) 66 67# make a building 68DoBuilding(TARGET, objs) 69