-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConstruct
218 lines (184 loc) · 9.76 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#srodowisko dla debiana -*- mode: Python; -*-
import os, platform, re, subprocess
faif_name = 'faif'
ver_major = '0'
ver_minor = '36'
ver_compilation = '000'
BOOST_INCLUDE_WINDOWS = 'D:/boost_1_57_0'
BOOST_INCLUDE_LINUX = '/usr/local/include/boost'
BOOST_LIB_WINDOWS = 'D:/boost_1_57_0/lib64-msvc-12.0'
BOOST_LIB_LINUX = '/usr/local/lib'
BOOST_THREAD_LINUX = 'boost_thread'
BOOST_THREAD_LINUX_D = 'boost_thread'
BOOST_DATE_TIME_LINUX = 'boost_date_time'
BOOST_DATE_TIME_LINUX_D = 'boost_date_time'
BOOST_CHRONO_LINUX = 'boost_chrono'
BOOST_CHRONO_LINUX_D = 'boost_chrono'
BOOST_SYSTEM_LINUX = 'boost_system'
BOOST_SYSTEM_LINUX_D = 'boost_system'
BOOST_SERIALIZATION_LINUX = 'boost_serialization'
BOOST_SERIALIZATION_LINUX_D = 'boost_serialization'
BOOST_UNIT_TEST_LINUX = 'boost_unit_test_framework'
BOOST_UNIT_TEST_LINUX_D = 'boost_unit_test_framework'
#odczytuje wersje kompilacji z wersji repozytorium
ver_repository = subprocess.Popen('hg sum', shell=True, stdout=subprocess.PIPE).communicate()[0]
try:
ver_compilation = re.search('(?<=parent: )\d+', ver_repository).group()
except BaseException:
pass
ver_install = '-1'
faif_ver = ver_major + '.' + ver_minor
faif_full_ver = faif_ver + '.' + ver_compilation + ver_install
#dodaje dodatkowe argumenty do budowania
vars = Variables('custom.py')
vars.Add(BoolVariable('install', 'build debian package or setup.exe', 0))
env = Environment(variables=vars)
#dodaje opis argumentow do pomocy
Help(vars.GenerateHelpText(env) )
Export('env')
Export('faif_name')
Export('ver_major ver_minor ver_compilation ver_install')
#settings for debug and release
if(platform.system() == "Linux"):
env.Append( CPPPATH = [ Dir('.'), Dir(BOOST_INCLUDE_LINUX) ] )
env.Append( LIBPATH = BOOST_LIB_LINUX )
#env.Append( CPPFLAGS = '-Wall -pedantic -pthread -fPIC -Wstrict-aliasing=2' )
env.Append( CPPFLAGS = '-Wall -pedantic -pthread --std=c++11' )
env.Append( LINKFLAGS = '-Wall -pthread --std=c++11' )
elif(platform.system() == "Windows"):
env.Append( CPPPATH = [ Dir('.'), Dir(BOOST_INCLUDE_WINDOWS) ] )
env.Append( LIBPATH = BOOST_LIB_WINDOWS )
env.Append( WINDOWS_INSERT_MANIFEST = True )
else:
print "platform not supported"
envdebug = env.Clone()
env.debugFlag = False #member used to distinguish between debug environment and non-debug one
envdebug.debugFlag = True
if(platform.system() == "Linux"):
env.Append( CPPFLAGS = ' -O3' )
env.Append( LINKFLAGS = ' -O3' )
env.Append( LIBS = [BOOST_THREAD_LINUX, BOOST_DATE_TIME_LINUX, BOOST_SERIALIZATION_LINUX, BOOST_CHRONO_LINUX, BOOST_SYSTEM_LINUX] )
envdebug.Append( CPPFLAGS = ' -g ' ) #-ftest-coverage -fprofile-arcs
envdebug.Append( LINKFLAGS = ' -g ' ) #-fprofile-arcs
envdebug.Append( LIBS = [BOOST_THREAD_LINUX_D, BOOST_DATE_TIME_LINUX_D, BOOST_SERIALIZATION_LINUX_D, BOOST_CHRONO_LINUX_D, BOOST_SYSTEM_LINUX_D ] )
elif(platform.system() == "Windows"):
env.Append( CPPFLAGS = ' /EHsc /MD /D "WIN32" /D "_CONSOLE" /W4 /Ox' )
env.Append( LINKFLAGS = ' /SUBSYSTEM:CONSOLE ' )
envdebug.Append( CPPFLAGS = ' /Od /EHsc /MDd /D "WIN32" /D "_CONSOLE" /D "_DEBUG" /W4 /Zi /TP' )
envdebug.Append( LINKFLAGS = ' /SUBSYSTEM:CONSOLE /DEBUG ' )
else:
print "System " + platform.system() + " not supported "
def add_test_settings( e ):
if(platform.system() == "Linux"):
if hasattr(e, 'debugFlag'):
if e.debugFlag:
e.Append( LIBS = BOOST_UNIT_TEST_LINUX_D )
else:
e.Append( LIBS = BOOST_UNIT_TEST_LINUX )
else:
e.Append( LIBS = BOOST_UNIT_TEST_LINUX )
elif(platform.system() == "Windows"):
pass
else:
print 'system not supported'
return e
import files
#dokleja nazwe build dir na poczatku kazdego elementu z listy src_files
def prepare_src_files( build_dir, src_files):
src_compilation = []
for f in src_files:
src_compilation.append(build_dir + f)
return src_compilation
def build_library_version( target, source, env):
file=open(str(target[0]),'w')
file.write('// this file is generated by SCons script\n')
file.write('#ifndef FAIF_VERSION_H\n')
file.write('#define FAIF_VERSION_H\n')
file.write('namespace faif {\n')
file.write(' const int FAIF_VERSION_MAJOR = ' + ver_major + ';\n')
file.write(' const int FAIF_VERSION_MINOR = ' + ver_minor + ';\n')
file.write(' const int FAIF_VERSION_COMPILATION = ' + ver_compilation + ';\n')
file.write('} //namespace faif\n')
file.write('#endif //FAIF_VERSION_H\n')
file.close()
return
def build_library(env):
#copy headers
install_include_dir = './faif/'
for mod in files.modules:
dir = install_include_dir + mod.path
for file in mod.head:
env.Install(dir, 'src/' + file)
return
def build_single_program( env, target, source):
t = env.Program( target = target, source = source)
env.SideEffect( File( str(target) + '.pdb'), t )
env.SideEffect( File( str(target) + '.ilk'), t )
env.SideEffect( File( str(target) + '.exp'), t )
env.SideEffect( File( str(target) + '.lib'), t )
return t
def build_tests( env, build_dir, post_name ):
em = env.Clone()
em = add_test_settings(em)
em.Append( CPPFLAGS = ' -D BOOST_TEST_MAIN' )
em.VariantDir( build_dir, 'tests/', duplicate = 0)
#tests of given properties
build_single_program( em, 'testPrimitives'+post_name, prepare_src_files(build_dir, ['PrimitivesTest.cpp'] ) )
build_single_program( em, 'testUtils'+post_name, prepare_src_files(build_dir, [ 'UtilsTest.cpp'] ) )
build_single_program( em, 'testDna'+post_name, prepare_src_files(build_dir, [ 'DnaTest.cpp'] ) )
build_single_program( em, 'testHapl'+post_name, prepare_src_files(build_dir, [ 'HaplTest.cpp'] ) )
build_single_program( em, 'testTimeseries'+post_name, prepare_src_files(build_dir, [ 'TimeseriesTest.cpp'] ) )
build_single_program( em, 'testDiscretizer'+post_name, prepare_src_files(build_dir, [ 'DiscretizerTest.cpp'] ) )
build_single_program( em, 'testTSPred'+post_name, prepare_src_files(build_dir, [ 'TimeseriesPredictionTest.cpp'] ) )
build_single_program( em, 'testLearning'+post_name, prepare_src_files(build_dir, [ 'LearningTest.cpp'] ) )
build_single_program( em, 'testNBC'+post_name, prepare_src_files(build_dir, [ 'NbcTest.cpp'] ) )
build_single_program( em, 'testDTC'+post_name, prepare_src_files(build_dir, [ 'DtcTest.cpp'] ) )
build_single_program( em, 'testKNN'+post_name, prepare_src_files(build_dir, [ 'KnnTest.cpp'] ) )
build_single_program( em, 'testSearch'+post_name, prepare_src_files(build_dir, [ 'SearchTest.cpp'] ) )
build_single_program( em, 'testOptAlg'+post_name, prepare_src_files(build_dir, [ 'OptAlgTest.cpp'] ) )
build_single_program( em, 'testMLR'+post_name, prepare_src_files(build_dir, ['MlrTest.cpp']))
#all tests
ea = env.Clone()
ea = add_test_settings(ea)
ea.VariantDir( build_dir + 'all/', 'tests/', duplicate = 0)
build_single_program( ea, 'testAll'+post_name, prepare_src_files(build_dir+'all/',
['PrimitivesTest.cpp', 'UtilsTest.cpp',
'DnaTest.cpp', 'HaplTest.cpp',
'TimeseriesTest.cpp', 'DiscretizerTest.cpp', 'TimeseriesPredictionTest.cpp',
'LearningTest.cpp', 'NbcTest.cpp', 'DtcTest.cpp', 'KnnTest.cpp',
'SearchTest.cpp', 'OptAlgTest.cpp','MlrTest.cpp',
'TestAll.cpp' ] ) )
return
def build_examples( env, build_dir ):
em = env.Clone()
em.VariantDir( build_dir, 'examples/', duplicate = 0)
build_single_program(em, 'dna', source = prepare_src_files(build_dir, ['dna.cpp'] ) )
build_single_program(em, 'ea', source = prepare_src_files(build_dir, ['ea.cpp'] ) )
build_single_program(em, 'hillclimb', source = prepare_src_files(build_dir, ['hillclimb.cpp'] ) )
build_single_program(em, 'nbc', source = prepare_src_files(build_dir, ['nbc.cpp'] ) )
build_single_program(em, 'dtc', source = prepare_src_files(build_dir, ['dtc.cpp'] ) )
build_single_program(em, 'knn', source = prepare_src_files(build_dir, ['knn.cpp'] ) )
build_single_program(em, 'nbcdb', source = prepare_src_files(build_dir, ['nbcdb.cpp'] ) )
build_single_program(em, 'dtcdb', source = prepare_src_files(build_dir, ['dtcdb.cpp'] ) )
build_single_program(em, 'random', source = prepare_src_files(build_dir, ['random.cpp'] ) )
build_single_program(em, 'search', source = prepare_src_files(build_dir, ['search.cpp'] ) )
build_single_program(em, 'discretizer', source = prepare_src_files(build_dir, ['discretizer.cpp'] ) )
build_single_program(em, 'mlr', source = prepare_src_files(build_dir, ['mlr.cpp'] ) )
if env['install'] == 1:
SConscript('install/SConscript')
else:
file_ver_name = 'src/Version.hpp'
env.Command(file_ver_name, [], build_library_version )
env.SideEffect( 'vc100.idb', 'src/Version.hpp' )
env.SideEffect( 'vc100.pdb', 'src/Version.hpp' )
env.SideEffect( 'install/faif-src-'+faif_ver+'.tar', 'src/Version.hpp' )
env.SideEffect( 'install/faif-src-'+faif_ver+'.tar.bz2', 'src/Version.hpp' )
env.SideEffect( 'install/faif-doc-'+faif_ver+'.tar', 'src/Version.hpp' )
env.SideEffect( 'install/faif-doc-'+faif_ver+'.tar.bz2', 'src/Version.hpp' )
env.SideEffect( 'install/' + faif_name + '_'+ faif_full_ver + '_i386.deb', 'src/Version.hpp' )
env.SideEffect( 'install/' + faif_name + '_'+ faif_full_ver + '_amd64.deb', 'src/Version.hpp' )
env.SideEffect( 'install/Faif-' + faif_full_ver + '-setup.exe', 'src/Version.hpp' )
build_tests( env, 'build/test/', '')
build_tests( envdebug, 'build/test_d/', '-d')
build_library( env )
build_examples( env, 'build/examples/' )