|
| 1 | +import os |
| 2 | +import sys |
| 3 | +import rtconfig |
| 4 | + |
| 5 | +if os.getenv('RTT_ROOT'): |
| 6 | + RTT_ROOT = os.getenv('RTT_ROOT') |
| 7 | +else: |
| 8 | + RTT_ROOT = os.path.normpath(os.getcwd() + '/../../../..') |
| 9 | + |
| 10 | +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] |
| 11 | +try: |
| 12 | + from building import * |
| 13 | +except: |
| 14 | + print('Cannot found RT-Thread root directory, please check RTT_ROOT') |
| 15 | + print(RTT_ROOT) |
| 16 | + exit(-1) |
| 17 | + |
| 18 | +TARGET = 'rtthread.' + rtconfig.TARGET_EXT |
| 19 | + |
| 20 | +DefaultEnvironment(tools=[]) |
| 21 | +env = 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) |
| 27 | +env.PrependENVPath('PATH', rtconfig.EXEC_PATH) |
| 28 | + |
| 29 | +if 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 rtthread.map') |
| 33 | + |
| 34 | +Export('RTT_ROOT') |
| 35 | +Export('rtconfig') |
| 36 | + |
| 37 | +SDK_ROOT = os.path.abspath('./') |
| 38 | + |
| 39 | +if os.path.exists(SDK_ROOT + '/libraries'): |
| 40 | + libraries_path_prefix = SDK_ROOT + '/libraries' |
| 41 | +else: |
| 42 | + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries' |
| 43 | + |
| 44 | +SDK_LIB = libraries_path_prefix |
| 45 | +Export('SDK_LIB') |
| 46 | + |
| 47 | +# prepare building environment |
| 48 | +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) |
| 49 | + |
| 50 | +gd32_library = 'GD32F5xx_Firmware_Library' |
| 51 | +rtconfig.BSP_LIBRARY_TYPE = gd32_library |
| 52 | + |
| 53 | +# include libraries |
| 54 | +objs.extend(SConscript(os.path.join(libraries_path_prefix, gd32_library, 'SConscript'))) |
| 55 | + |
| 56 | +# include drivers |
| 57 | +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'gd32_drivers', 'SConscript'))) |
| 58 | + |
| 59 | +# make a building |
| 60 | +DoBuilding(TARGET, objs) |
0 commit comments