forked from rqbh/RTGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
141 lines (119 loc) · 4 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import os
import sys
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
print "error! Please set the environment var 'RTT_ROOT'"
sys.exit(255)
path_cwd = os.path.normpath(os.getcwd())
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
sys.path.insert(0, os.path.join(path_cwd, 'components', 'rtgui', 'utils'))
import rtconfig
from building import *
Export('RTT_ROOT')
Export('rtconfig')
if rtconfig.PLATFORM == 'cl':
TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT
libs = Split('''
winmm
gdi32
winspool
comdlg32
advapi32
shell32
ole32
oleaut32
uuid
odbc32
msvcrt
odbccp32
''')
definitions = Split('''
WIN32
_DEBUG
_CONSOLE
MSVC
''')
env = Environment(TARGET_ARCH='x86')
env.Append(CCFLAGS=rtconfig.CFLAGS)
env.Append(LINKFLAGS=rtconfig.LFLAGS)
env['LIBS']=libs
env['CPPDEFINES']=definitions
elif rtconfig.PLATFORM == 'mingw':
libs = Split('''
winmm
gdi32
winspool
comdlg32
advapi32
shell32
ole32
oleaut32
uuid
odbc32
odbccp32
''')
TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env['LIBS']=libs
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
elif rtconfig.CROSS_TOOL == 'clang-analyze':
env = Environment(AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
else:
TARGET = 'rtthread'
env = Environment(TARGET_ARCH='x86')
env.Append(CCFLAGS=rtconfig.CFLAGS)
env.Append(LINKFLAGS=rtconfig.LFLAGS)
env.Append(LIBS=['m'])
# list of targets, list item format in:
# ['executable_name', 'path_to_SConscript']
TARGETS = [['demo', 'demo'], ['realtouch', 'realtouch']]
exe_dir = 'executables'
# prepare building environment
base_objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False, remove_components=['rtgui'])
path_jn = os.path.join
BSP_ROOT = path_jn(RTT_ROOT, 'bsp/simulator')
# make use of bsp/simulator
sim_objs = SConscript(GetCurrentDir() + '/sim-common/SConscript',
variant_dir='build/simulator/sim-com',
duplicate=0)
sim_objs.extend(SConscript(path_jn(BSP_ROOT, 'drivers/SConscript'),
variant_dir='build/simulator/sim-drv',
duplicate=0))
base_objs.extend(sim_objs)
#sdl_lib_path = [os.path.abspath(path_jn(BSP_ROOT, 'SDL/lib/x86'))]
#sdl_include_path = [os.path.abspath(path_jn(BSP_ROOT, 'SDL/include'))]
#env.Append(LIBPATH=sdl_lib_path)
#env.Append(CPPPATH=sdl_include_path)
for exe_name, src_path in TARGETS:
work_objs = base_objs + SConscript(dirs=[src_path],
variant_dir=os.path.join('build', src_path),
duplicate=0)
# build program
program = env.Program(os.path.join(exe_dir, exe_name), work_objs)
# end building
EndBuilding(exe_name, program)
AddOption('--build-tests',
action='store_true',
help='build all the test cases')
if GetOption('build_tests'):
# build for testcases
list = os.listdir(os.path.join(str(Dir('#')), 'test_cases'))
for d in list:
src_path = os.path.join(str(Dir('#')), 'test_cases', d)
if os.path.isfile(os.path.join(src_path, 'SConscript')):
exe_name = os.path.basename(src_path)
objs = base_objs + SConscript(dirs=[src_path],
variant_dir=os.path.join('build', src_path),
duplicate=0)
# build program
env.Program(os.path.join(exe_dir, exe_name), objs)
# end building
EndBuilding(exe_name)