-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConstruct
57 lines (43 loc) · 1.6 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
import subprocess
#add debug and release builds
AddOption('--d',action='store_true',help='build a debug build',default=False)
AddOption('--r',action='store_true',help='build a release build',default=False)
#Sets up an environment object
env = Environment()
#define some directories and common files
bins = "bins/"
srcs = "src/"
libs = "lib/"
build = "build/"
SConscript_name = "SConscript"
framework_name = "2014-2015-Framework/"
#the default flags for all builds
flags = "-Wall "
#set up some differences between debug and release
if GetOption('d'):
flags += "-g"
if GetOption('r'):
flags += "-O3"
env.Append(CCFLAGS=flags)
#setting the output dir to be build instead,
#also making it so it doesn't copy the files
#library_build_dir = build + 'framework/'
#env.VariantDir(library_build_dir,libs+framework_name+srcs)
#program_build_dir = build + 'program/'
#env.VariantDir(program_build_dir,'src')
#add the cpp path
env.Append(CPPPATH = ['../framework/'])
#i can't find a better way to do this
def copyanything(src, dst):
subprocess.check_call(['rsync','-r','-i',src,dst])
print("Copying Files...")
copyanything(srcs,build+"program/")
copyanything(libs+framework_name+srcs,build+"framework/")
print("Building Library...")
#build the library
library_objects = SConscript(build+'framework/'+SConscript_name, exports = 'env')
env.Library(bins + 'framework',library_objects)
print("Building Program...")
#actually build the program
program_objects = SConscript(build+'program/'+SConscript_name, exports= 'env')
env.Program(target = 'robot_program',source=program_objects,libs=[bins +'framework'],variant_dir=build+"program")