@@ -52,19 +52,22 @@ import filelist |
52 | 52 |
|
53 | 53 | filelist.setSourceRootDir(os.path.abspath(os.getcwd())) |
54 | 54 |
|
| 55 | + |
55 | 56 | if sys.platform == 'win32': |
56 | 57 | # force to mingw, otherwise picks up msvc |
57 | 58 | myTools = ['mingw'] |
58 | 59 | else: |
59 | 60 | myTools = ['default'] |
60 | 61 | myTools += ['rts', 'gch'] |
61 | 62 |
|
| 63 | + |
62 | 64 | env = Environment(tools = myTools, toolpath = ['.', tmpBuildScriptsDir]) |
63 | 65 | #env = Environment(tools = myTools, toolpath = ['.', tmpBuildScriptsDir], ENV = {'PATH' : os.environ['PATH']}) |
| 66 | + |
64 | 67 | if env['platform'] == 'windows': |
65 | | - env['SHARED_OBJ_EXT'] = '.o' |
| 68 | + env['SHARED_OBJ_EXT'] = '.o' |
66 | 69 | else: |
67 | | - env['SHARED_OBJ_EXT'] = '.os' |
| 70 | + env['SHARED_OBJ_EXT'] = '.os' |
68 | 71 |
|
69 | 72 | if env['use_gch']: |
70 | 73 | env['Gch'] = env.Gch(source='rts/System/StdAfx.h', target='rts/System/StdAfx.h.gch', CPPDEFINES=env['CPPDEFINES']+env['spring_defines'])[0] |
|
73 | 76 | if os.path.exists('rts/System/StdAfx.h.gch'): |
74 | 77 | os.unlink('rts/System/StdAfx.h.gch') |
75 | 78 |
|
| 79 | + |
76 | 80 | def createStaticExtLibraryBuilder(env): |
77 | 81 | """This is a utility function that creates the StaticExtLibrary |
78 | 82 | Builder in an Environment if it is not there already. |
@@ -111,51 +115,59 @@ def create_static_objects(env, fileList, suffix, additionalCPPDEFINES = []): |
111 | 115 | fname, fext = fbase.rsplit('.', 1) |
112 | 116 | objsList.append(myEnv.StaticObject(os.path.join(fpath, fname + suffix), f)) |
113 | 117 | return objsList |
| 118 | + |
| 119 | + |
114 | 120 |
|
115 | 121 | ################################################################################ |
116 | 122 | ### Build streflop |
117 | 123 | ################################################################################ |
118 | 124 |
|
119 | 125 | # setup build environment |
120 | | -senv = env.Clone(builddir=os.path.join(env['builddir'], 'streflop')) |
121 | | -senv['CPPPATH'] = [] |
122 | | -senv.BuildDir(os.path.join(senv['builddir'], 'rts/lib/streflop'), 'rts/lib/streflop', duplicate = False) |
123 | | -for d in filelist.list_directories(senv, 'rts/lib/streflop', exclude_list=[]): |
124 | | - senv.BuildDir(os.path.join(senv['builddir'], d), d, duplicate = False) |
| 126 | +streflopEnv = env.Clone(builddir=os.path.join(env['builddir'], 'streflop')) |
| 127 | +streflopEnv['CPPPATH'] = [] |
| 128 | +streflopEnv.BuildDir(os.path.join(streflopEnv['builddir'], 'rts/lib/streflop'), 'rts/lib/streflop', duplicate = False) |
| 129 | +for d in filelist.list_directories(streflopEnv, 'rts/lib/streflop', exclude_list=[]): |
| 130 | + streflopEnv.BuildDir(os.path.join(streflopEnv['builddir'], d), d, duplicate = False) |
125 | 131 |
|
126 | 132 | # setup flags and defines |
127 | | -if senv['fpmath'] == 'sse': |
128 | | - senv['CPPDEFINES'] = ['STREFLOP_SSE=1'] |
| 133 | +if streflopEnv['fpmath'] == 'sse': |
| 134 | + streflopEnv['CPPDEFINES'] = ['STREFLOP_SSE=1'] |
129 | 135 | else: |
130 | | - senv['CPPDEFINES'] = ['STREFLOP_X87=1'] |
131 | | -senv['CXXFLAGS'] = ['-Wall', '-Wno-sign-compare', '-O3', '-pipe', '-g', '-mno-tls-direct-seg-refs', '-fsingle-precision-constant', '-frounding-math', '-fsignaling-nans', '-fno-strict-aliasing', '-mieee-fp'] |
132 | | -senv.AppendUnique(CXXFLAGS = senv['streflop_extra']) |
| 136 | + streflopEnv['CPPDEFINES'] = ['STREFLOP_X87=1'] |
| 137 | + |
| 138 | +streflopEnv['CXXFLAGS'] = ['-Wall', '-Wno-sign-compare', '-O3', '-pipe', '-g', '-mno-tls-direct-seg-refs', '-fsingle-precision-constant', '-frounding-math', '-fsignaling-nans', '-fno-strict-aliasing', '-mieee-fp'] |
| 139 | +streflopEnv.AppendUnique(CXXFLAGS = streflopEnv['streflop_extra']) |
133 | 140 |
|
134 | 141 | # create the libm sub-part build environment |
135 | | -slibmenv = senv.Clone() |
| 142 | +slibmenv = streflopEnv.Clone() |
136 | 143 | slibmenv.AppendUnique(CPPPATH = ['rts/lib/streflop/libm/headers']) |
137 | 144 |
|
138 | 145 | # gather the sources |
139 | 146 | sobjs_flt32 = create_static_objects(slibmenv, filelist.get_source(slibmenv, 'rts/lib/streflop/libm/flt-32'), '-streflop-flt32', ['LIBM_COMPILING_FLT32']) |
140 | 147 | #sobjs_dbl64 = create_static_objects(slibmenv, filelist.get_source(slibmenv, 'rts/lib/streflop/libm/dbl-64'), '-streflop-dbl64', ['LIBM_COMPILING_DBL64']) |
141 | 148 | #sobjs_ldbl96 = create_static_objects(slibmenv, filelist.get_source(slibmenv, 'rts/lib/streflop/libm/ldbl-96'), '-streflop-ldbl96', ['LIBM_COMPILING_LDBL96']) |
| 149 | + |
142 | 150 | streflopSource_tmp = [ |
143 | | - 'rts/lib/streflop/SMath.cpp', |
144 | | - 'rts/lib/streflop/Random.cpp', |
145 | | - 'rts/lib/streflop/streflopC.cpp' |
146 | | - ] |
| 151 | + 'rts/lib/streflop/SMath.cpp', |
| 152 | + 'rts/lib/streflop/Random.cpp', |
| 153 | + 'rts/lib/streflop/streflopC.cpp' |
| 154 | +] |
147 | 155 | streflopSource = [] |
148 | | -for f in streflopSource_tmp: streflopSource += [os.path.join(senv['builddir'], f)] |
| 156 | +for f in streflopSource_tmp: |
| 157 | + streflopSource += [os.path.join(streflopEnv['builddir'], f)] |
| 158 | + |
149 | 159 | streflopSource += sobjs_flt32 |
150 | 160 | # not needed => safer (and faster) to not compile them at all |
151 | 161 | #streflopSource += sobjs_flt32 + sobjs_dbl64 + sobjs_ldbl96 |
152 | 162 |
|
153 | 163 | # compile |
154 | | -createStaticExtLibraryBuilder(senv) |
155 | | -streflop_lib = senv.StaticExtLibrary(senv['builddir'], streflopSource) |
156 | | -#streflop_lib = senv.StaticLibrary(senv['builddir'], streflopSource) |
| 164 | +createStaticExtLibraryBuilder(streflopEnv) |
| 165 | +streflop_lib = streflopEnv.StaticExtLibrary(streflopEnv['builddir'], streflopSource) |
| 166 | +#streflop_lib = streflopEnv.StaticLibrary(streflopEnv['builddir'], streflopSource) |
157 | 167 | Alias('streflop', streflop_lib) # Allow `scons streflop' to compile just streflop |
158 | 168 |
|
| 169 | + |
| 170 | + |
159 | 171 | ################################################################################ |
160 | 172 | ### Build oscpack |
161 | 173 | ################################################################################ |
@@ -166,7 +178,7 @@ oscenv['CPPPATH'] = [] |
166 | 178 | oscenv.BuildDir(os.path.join(oscenv['builddir'], 'rts/lib/oscpack'), |
167 | 179 | 'rts/lib/oscpack', duplicate = False) |
168 | 180 |
|
169 | | -oscenv['CXXFLAGS'] = senv['CXXFLAGS'] |
| 181 | +oscenv['CXXFLAGS'] = streflopEnv['CXXFLAGS'] |
170 | 182 |
|
171 | 183 | # setup flags and defines |
172 | 184 | if oscenv['platform'] == 'darwin': |
@@ -188,6 +200,8 @@ createStaticExtLibraryBuilder(oscenv) |
188 | 200 | oscpack_lib = oscenv.StaticExtLibrary(oscenv['builddir'], oscpackSource) |
189 | 201 | Alias('oscpack', oscpack_lib) # Allow `scons oscpack' to compile just oscpack |
190 | 202 |
|
| 203 | + |
| 204 | + |
191 | 205 | ################################################################################ |
192 | 206 | ### Build spring(.exe) |
193 | 207 | ################################################################################ |
@@ -222,19 +236,20 @@ if env['use_nedmalloc']: |
222 | 236 | nedmalloc = SConscript('tools/nedmalloc/SConscript', exports='env') |
223 | 237 | spring_files += [nedmalloc] |
224 | 238 |
|
225 | | -springenv = env.Clone(CPPDEFINES=env['CPPDEFINES']+env['spring_defines']) |
| 239 | + |
| 240 | +springEnv = env.Clone(CPPDEFINES=env['CPPDEFINES']+env['spring_defines']) |
226 | 241 | if env['platform'] == 'windows': |
227 | 242 | # create import library and .def file on Windows |
228 | 243 | springDef = os.path.join(env['builddir'], 'spring.def') |
229 | 244 | springA = os.path.join(env['builddir'], 'spring.a') |
230 | | - springenv['LINKFLAGS'] = springenv['LINKFLAGS'] + ['-Wl,--output-def,' + springDef] |
231 | | - springenv['LINKFLAGS'] = springenv['LINKFLAGS'] + ['-Wl,--kill-at', '--add-stdcall-alias'] |
232 | | - springenv['LINKFLAGS'] = springenv['LINKFLAGS'] + ['-Wl,--out-implib,' + springA] |
| 245 | + springEnv['LINKFLAGS'] = springEnv['LINKFLAGS'] + ['-Wl,--output-def,' + springDef] |
| 246 | + springEnv['LINKFLAGS'] = springEnv['LINKFLAGS'] + ['-Wl,--kill-at', '--add-stdcall-alias'] |
| 247 | + springEnv['LINKFLAGS'] = springEnv['LINKFLAGS'] + ['-Wl,--out-implib,' + springA] |
233 | 248 | instSpringSuppl = [env.Install(os.path.join(env['installprefix'], env['bindir']), springDef)] |
234 | 249 | instSpringSuppl += [env.Install(os.path.join(env['installprefix'], env['bindir']), springA)] |
235 | 250 | Alias('install', instSpringSuppl) |
236 | 251 | Alias('install-spring', instSpringSuppl) |
237 | | -spring = springenv.Program(os.path.join(springenv['builddir'], 'spring'), spring_files) |
| 252 | +spring = springEnv.Program(os.path.join(springEnv['builddir'], 'spring'), spring_files) |
238 | 253 |
|
239 | 254 | Alias('spring', spring) |
240 | 255 | Default(spring) |
@@ -247,15 +262,25 @@ if env['strip']: |
247 | 262 | env.AddPostAction(spring, Action([['strip','$TARGET']])) |
248 | 263 |
|
249 | 264 |
|
| 265 | + |
250 | 266 | ################################################################################ |
251 | 267 | ### Build unitsync shared object |
252 | 268 | ################################################################################ |
| 269 | + |
253 | 270 | # HACK we should probably compile libraries from 7zip, hpiutil2 and minizip |
254 | 271 | # so we don't need so much bloat here. |
255 | 272 | # Need a new env otherwise scons chokes on equal targets built with different flags. |
| 273 | +# |
256 | 274 | usync_builddir = os.path.join(env['builddir'], 'unitsync') |
257 | | -uenv = env.Clone(builddir=usync_builddir) |
258 | | -uenv.AppendUnique(CPPDEFINES=['UNITSYNC', 'BITMAP_NO_OPENGL']) |
| 275 | +unitsyncEnv = env.Clone(builddir=usync_builddir) |
| 276 | +unitsyncEnv.AppendUnique(CPPDEFINES=['UNITSYNC', 'BITMAP_NO_OPENGL']) |
| 277 | + |
| 278 | +## needed because without it lua/lmathlib.cpp only includes cmath |
| 279 | +## via streflop_cond.h (which places everything in std namespace) |
| 280 | +if streflopEnv['fpmath'] == 'sse': |
| 281 | + unitsyncEnv['CPPDEFINES'] += ['STREFLOP_SSE=1'] |
| 282 | +else: |
| 283 | + unitsyncEnv['CPPDEFINES'] += ['STREFLOP_X87=1'] |
259 | 284 |
|
260 | 285 | def remove_precompiled_header(env): |
261 | 286 | while 'USE_PRECOMPILED_HEADER' in env['CPPDEFINES']: |
@@ -265,16 +290,16 @@ def remove_precompiled_header(env): |
265 | 290 | while '-DUSE_PRECOMPILED_HEADER' in env['CXXFLAGS']: |
266 | 291 | env['CXXFLAGS'].remove('-DUSE_PRECOMPILED_HEADER') |
267 | 292 |
|
268 | | -remove_precompiled_header(uenv) |
| 293 | +remove_precompiled_header(unitsyncEnv) |
269 | 294 |
|
270 | 295 | def usync_get_source(*args, **kwargs): |
271 | | - return filelist.get_source(uenv, ignore_builddir=True, *args, **kwargs) |
| 296 | + return filelist.get_source(unitsyncEnv, ignore_builddir=True, *args, **kwargs) |
272 | 297 |
|
273 | | -uenv.BuildDir(os.path.join(uenv['builddir'], 'tools/unitsync'), 'tools/unitsync', duplicate = False) |
| 298 | +unitsyncEnv.BuildDir(os.path.join(unitsyncEnv['builddir'], 'tools/unitsync'), 'tools/unitsync', duplicate = False) |
274 | 299 | unitsync_files = usync_get_source('tools/unitsync') |
275 | 300 | unitsync_fs_files = usync_get_source('rts/System/FileSystem/', exclude_list=('rts/System/FileSystem/DataDirLocater.cpp')); |
276 | 301 | unitsync_lua_files = usync_get_source('rts/lib/lua/src'); |
277 | | -unitsync_7zip_files = usync_get_source('rts/lib/7z') + usync_get_source('rts/lib/7z/Archive/7z'); |
| 302 | +unitsync_7zip_files = usync_get_source('rts/lib/7z') ##+ usync_get_source('rts/lib/7z/Archive/7z') |
278 | 303 | unitsync_minizip_files = usync_get_source('rts/lib/minizip', 'rts/lib/minizip/iowin32.c'); |
279 | 304 | unitsync_hpiutil2_files = usync_get_source('rts/lib/hpiutil2'); |
280 | 305 | unitsync_extra_files = [ |
@@ -301,20 +326,28 @@ unitsync_files.extend(unitsync_hpiutil2_files) |
301 | 326 | unitsync_files.extend(unitsync_extra_files) |
302 | 327 |
|
303 | 328 | unitsync_objects = [] |
| 329 | + |
304 | 330 | if env['platform'] == 'windows': |
305 | 331 | # crosscompiles on buildbot need this, but native mingw builds fail |
306 | 332 | # during linking |
307 | 333 | if os.name != 'nt': |
308 | 334 | unitsync_files.append('rts/lib/minizip/iowin32.c') |
| 335 | + |
309 | 336 | unitsync_files.append('rts/System/FileSystem/DataDirLocater.cpp') |
| 337 | + |
310 | 338 | # Need the -Wl,--kill-at --add-stdcall-alias because TASClient expects undecorated stdcall functions. |
311 | | - uenv['LINKFLAGS'] += ['-Wl,--kill-at', '--add-stdcall-alias'] |
| 339 | + unitsyncEnv['LINKFLAGS'] += ['-Wl,--kill-at', '--add-stdcall-alias'] |
312 | 340 | else: |
313 | | - ddlcpp = uenv.SharedObject(os.path.join(env['builddir'], 'rts/System/FileSystem/DataDirLocater.cpp'), CPPDEFINES = uenv['CPPDEFINES']+datadir) |
| 341 | + ddlcpp = unitsyncEnv.SharedObject(os.path.join(env['builddir'], 'rts/System/FileSystem/DataDirLocater.cpp'), CPPDEFINES = unitsyncEnv['CPPDEFINES']+datadir) |
314 | 342 | unitsync_objects += [ ddlcpp ] |
315 | | -# some scons stupidity |
316 | | -unitsync_objects += [uenv.SharedObject(source=f, target=os.path.join(uenv['builddir'], f)+uenv['SHARED_OBJ_EXT']) for f in unitsync_files] |
317 | | -unitsync = uenv.SharedLibrary(os.path.join(uenv['builddir'], 'unitsync'), unitsync_objects) |
| 343 | + |
| 344 | + |
| 345 | +# work around some Scons stupidity |
| 346 | +unitsyncEnv['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME']=1 |
| 347 | +unitsync_objects += [unitsyncEnv.SharedObject(source=f, target=os.path.join(unitsyncEnv['builddir'], f) + unitsyncEnv['SHARED_OBJ_EXT']) for f in unitsync_files] |
| 348 | +unitsync_objects += [streflop_lib] |
| 349 | +unitsync = unitsyncEnv.SharedLibrary(os.path.join(unitsyncEnv['builddir'], 'unitsync'), unitsync_objects) |
| 350 | + |
318 | 351 |
|
319 | 352 | Alias('unitsync', unitsync) |
320 | 353 | inst = env.Install(os.path.join(env['installprefix'], env['libdir']), unitsync) |
@@ -334,20 +367,23 @@ if env['platform'] != 'windows': |
334 | 367 | Default(unitsync) |
335 | 368 |
|
336 | 369 |
|
| 370 | + |
337 | 371 | ################################################################################# |
338 | 372 | #### AIs |
339 | 373 | ################################################################################# |
340 | 374 |
|
341 | 375 | print('AI installprefix: ' + os.path.join(env['installprefix'], env['libdir'], 'AI')) |
342 | 376 | ai_env = env.Clone( |
343 | | - builddir = os.path.join(env['builddir'], 'AI'), |
344 | | - installprefix = os.path.join(env['installprefix'], env['libdir'], 'AI') |
345 | | - ) |
| 377 | + builddir = os.path.join(env['builddir'], 'AI'), |
| 378 | + installprefix = os.path.join(env['installprefix'], env['libdir'], 'AI') |
| 379 | +) |
346 | 380 | remove_precompiled_header(ai_env) |
347 | 381 | #SConscript(['AI/SConscript'], exports=['env', 'ai_env'], variant_dir=env['builddir']) |
348 | 382 | SConscript(['AI/SConscript'], exports=['env', 'ai_env', 'streflop_lib']) |
349 | 383 | #SConscript(['AI/SConscript'], exports=['env', 'ai_env'], variant_dir=ai_env['builddir']) |
350 | 384 |
|
| 385 | + |
| 386 | + |
351 | 387 | ################################################################################ |
352 | 388 | ### Run Tests |
353 | 389 | ################################################################################ |
@@ -365,6 +401,7 @@ if 'test' in sys.argv and env['platform'] != 'windows': |
365 | 401 | os.system(test) |
366 | 402 |
|
367 | 403 |
|
| 404 | + |
368 | 405 | ################################################################################ |
369 | 406 | ### Build gamedata zip archives & misc. |
370 | 407 | ################################################################################ |
@@ -429,4 +466,3 @@ for f in luaui_files: |
429 | 466 | if not os.path.isdir(f): |
430 | 467 | inst = env.Install(os.path.join(env['installprefix'], env['datadir'], os.path.dirname(f)[5:]), f) |
431 | 468 | Alias('install', inst) |
432 | | - |
|