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 = 'rtthread.' + rtconfig.TARGET_EXT
19
20DefaultEnvironment(tools=[])
21env = Environment(tools = ['mingw'],
22    AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
23    CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
24    AR = rtconfig.AR, ARFLAGS = '-rc',
25    LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
26env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
27
28if rtconfig.PLATFORM in ['iccarm']:
29    env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
30    env.Replace(ARFLAGS = [''])
31    env.Replace(LINKCOM = env["LINKCOM"] + ' --map project.map')
32
33Export('RTT_ROOT')
34Export('rtconfig')
35
36SDK_ROOT = os.path.abspath('./')
37
38if os.path.exists(SDK_ROOT + '/libraries'):
39    libraries_path_prefix = SDK_ROOT + '/libraries'
40else:
41    libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
42
43
44# prepare building environment
45objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
46
47# make a building
48DoBuilding(TARGET, objs)
49