|
| 1 | +import os |
| 2 | +import sys |
| 3 | +import rtconfig |
| 4 | +from SCons.Script import * |
| 5 | +from termcolor import colored |
| 6 | + |
| 7 | +if os.getenv('RTT_ROOT'): |
| 8 | + RTT_ROOT = os.getenv('RTT_ROOT') |
| 9 | +else: |
| 10 | + RTT_ROOT = os.path.normpath(os.getcwd() + '/../../../..') |
| 11 | + |
| 12 | +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] |
| 13 | + |
| 14 | +try: |
| 15 | + from building import * |
| 16 | +except: |
| 17 | + print('Cannot found RT-Thread root directory, please check RTT_ROOT') |
| 18 | + print(RTT_ROOT) |
| 19 | + exit(-1) |
| 20 | + |
| 21 | +TARGET = 'rtthread.' + rtconfig.TARGET_EXT |
| 22 | + |
| 23 | +print(colored('RT-Thread root directory: %s' % RTT_ROOT, 'green')) |
| 24 | +print(colored('Building path: %s' % os.path.abspath('.'), 'green')) |
| 25 | +print(colored('Building target: %s' % TARGET, 'green')) |
| 26 | + |
| 27 | +DefaultEnvironment(tools=[]) |
| 28 | +env = Environment(tools = ['mingw'], |
| 29 | + AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, |
| 30 | + CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS, |
| 31 | + AR = rtconfig.AR, ARFLAGS = '-rc', |
| 32 | + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, |
| 33 | + LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) |
| 34 | +env.PrependENVPath('PATH', rtconfig.EXEC_PATH) |
| 35 | + |
| 36 | +Export('RTT_ROOT') |
| 37 | +Export('rtconfig') |
| 38 | + |
| 39 | +SDK_ROOT = os.path.abspath('./') |
| 40 | +print(colored('SDK_ROOT: %s' % SDK_ROOT, 'green')) |
| 41 | + |
| 42 | +if os.path.exists(SDK_ROOT + '/libraries'): |
| 43 | + libraries_path_prefix = SDK_ROOT + '../libraries' |
| 44 | +else: |
| 45 | + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/../libraries' |
| 46 | + |
| 47 | +print(colored('libraries_path_prefix: %s' % libraries_path_prefix, 'green')) |
| 48 | +SDK_LIB = libraries_path_prefix |
| 49 | +Export('SDK_LIB') |
| 50 | + |
| 51 | +# prepare building environment |
| 52 | +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) |
| 53 | + |
| 54 | +bsp_vdir = 'build' |
| 55 | +library_vdir = 'build/libraries' |
| 56 | + |
| 57 | +# common include drivers |
| 58 | +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'SConscript'), variant_dir=library_vdir, duplicate=0)) |
| 59 | + |
| 60 | +# make a building |
| 61 | +DoBuilding(TARGET, objs) |
0 commit comments