-
Notifications
You must be signed in to change notification settings - Fork 5
/
SConstruct
135 lines (114 loc) · 3.71 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
"""
* This file is part of a CODESKIN library that is being made available
* as open source under the GNU Lesser General Public License.
*
* Copyright 2005-2017 by CodeSkin LLC, www.codeskin.com.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
"""
Top-level SCons Build File
"""
import os
import sys
import platform
# ensure these versions of tools or newer:
EnsurePythonVersion(2,6)
EnsureSConsVersion(1,2)
# get build options
vars = Variables('build_options.py')
vars.AddVariables(
('ARCH', 'Architecture (32/64bit)','32'),
('RELEASE', 'Set to 1 to build for release', '0'),
('INSTALL_DIRS', 'Specify installation directories', []),
)
# create new environment
env = Environment(variables = vars);
unknown = vars.UnknownVariables()
if unknown:
print("Unknown variables:", unknown.keys())
Exit(1)
Help(vars.GenerateHelpText(env))
# configure toolchain
if((os.name == 'posix') and (platform.system() == 'Darwin' )):
import mac_build
mac_build.set_build_options(env)
elif ((os.name == 'nt') and (platform.system() == 'Windows' )):
import vs_build
vs_build.set_build_options(env)
elif ((os.name == 'posix') and (platform.system() == 'Linux' )):
import linux_build
linux_build.set_build_options(env)
else:
raise Exception, 'Don''t know this os and platform ('+os.name+', '+platform.system()+')'
# add libpath tool
import libname
env.AddMethod(libname.lib_name, "LibName")
env.AddMethod(libname.sharedlib_name, "SharedLibName")
env.AddMethod(libname.sharedlib_name_with_ext, "SharedLibNameExt")
env.AddMethod(libname.external_sharedlib_name_with_ext, "ExtDll")
# export for hierarchical build
Export('env');
# we build in variant directory (as to separate source from generated code)
VariantDir('build/utils', 'src/utils', 0)
VariantDir('build/can', 'src/can', 0)
VariantDir('build/can_dll', 'src/can_dll', 0)
VariantDir('build/can_async', 'src/can_async', 0)
VariantDir('build/can_lua', 'src/can_lua', 0)
VariantDir('build/slcan_can', 'src/slcan_can', 0)
VariantDir('build/socketcan_can', 'src/socketcan_can', 0)
# subdirectories needing to be built
if ((os.name == 'nt') and (platform.system() == 'Windows' )):
if int(env['ARCH']) == 32:
srcs = [
'build/utils',
'build/can',
'build/can_dll',
'build/can_lua',
'build/can_async',
'build/slcan_can',
]
else:
srcs = [
'build/utils',
'build/can',
'build/can_dll',
'build/can_lua',
'build/can_async',
'build/slcan_can',
]
elif ((os.name == 'posix') and (platform.system() == 'Linux' )):
srcs = [
'build/utils',
'build/can',
'build/can_dll',
'build/can_lua',
'build/can_async',
'build/slcan_can',
'build/socketcan_can'
]
elif ((os.name == 'posix') and (platform.system() == 'Darwin' )):
srcs = [
'build/utils',
'build/can',
'build/can_dll',
'build/can_lua',
'build/can_async',
'build/slcan_can'
]
else:
srcs = []
# built
objs = []
for subdir in srcs:
o = SConscript('%s/SConscript' % subdir)
objs.append(o)