|
| 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, CCFLAGS = rtconfig.CFLAGS, |
| 31 | + CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS, |
| 32 | + AR = rtconfig.AR, ARFLAGS = '-rc', |
| 33 | + LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) |
| 34 | +env.PrependENVPath('PATH', rtconfig.EXEC_PATH) |
| 35 | +env['ASCOM'] = env['ASPPCOM'] |
| 36 | + |
| 37 | +Export('RTT_ROOT') |
| 38 | +Export('rtconfig') |
| 39 | + |
| 40 | + |
| 41 | +# prepare building environment |
| 42 | +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False) |
| 43 | + |
| 44 | +stack_size = 4096 |
| 45 | + |
| 46 | +if GetDepend('RT_USING_SMART'): |
| 47 | + # use smart link.lds |
| 48 | + env['LINKFLAGS'] = env['LINKFLAGS'].replace('link.lds', 'link_smart.lds') |
| 49 | + |
| 50 | +stack_lds = open('link_stacksize.lds', 'w') |
| 51 | +if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__') |
| 52 | +stack_lds.write('__STACKSIZE__ = %d;\n' % stack_size) |
| 53 | +stack_lds.close() |
| 54 | + |
| 55 | +# make a building |
| 56 | +DoBuilding(TARGET, objs) |
0 commit comments