GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — scons: fix unitsync compilation · heroboy/spring@2a579f5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .gitmodules
  • HughAI
  • SConstruct
  • rts/lib/lua/src
    • lmathlib.cpp
    • lvm.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitmodules‎

Copy file name to clipboardExpand all lines: .gitmodules
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
path = AI/Skirmish/NTai
66
url = git://github.com/Tarendai/ntai.git
77
[submodule "HughAI"]
8-
path = AI/Skirmish/HughAI
8+
path = HughAI
99
url = git://github.com/hughperkins/HughAI.git
Collapse file

‎HughAI‎

Copy file name to clipboard
Submodule HughAI added at f23bf8c
Collapse file

‎SConstruct‎

Copy file name to clipboardExpand all lines: SConstruct
+78-42Lines changed: 78 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,22 @@ import filelist
5252

5353
filelist.setSourceRootDir(os.path.abspath(os.getcwd()))
5454

55+
5556
if sys.platform == 'win32':
5657
# force to mingw, otherwise picks up msvc
5758
myTools = ['mingw']
5859
else:
5960
myTools = ['default']
6061
myTools += ['rts', 'gch']
6162

63+
6264
env = Environment(tools = myTools, toolpath = ['.', tmpBuildScriptsDir])
6365
#env = Environment(tools = myTools, toolpath = ['.', tmpBuildScriptsDir], ENV = {'PATH' : os.environ['PATH']})
66+
6467
if env['platform'] == 'windows':
65-
env['SHARED_OBJ_EXT'] = '.o'
68+
env['SHARED_OBJ_EXT'] = '.o'
6669
else:
67-
env['SHARED_OBJ_EXT'] = '.os'
70+
env['SHARED_OBJ_EXT'] = '.os'
6871

6972
if env['use_gch']:
7073
env['Gch'] = env.Gch(source='rts/System/StdAfx.h', target='rts/System/StdAfx.h.gch', CPPDEFINES=env['CPPDEFINES']+env['spring_defines'])[0]
@@ -73,6 +76,7 @@ else:
7376
if os.path.exists('rts/System/StdAfx.h.gch'):
7477
os.unlink('rts/System/StdAfx.h.gch')
7578

79+
7680
def createStaticExtLibraryBuilder(env):
7781
"""This is a utility function that creates the StaticExtLibrary
7882
Builder in an Environment if it is not there already.
@@ -111,51 +115,59 @@ def create_static_objects(env, fileList, suffix, additionalCPPDEFINES = []):
111115
fname, fext = fbase.rsplit('.', 1)
112116
objsList.append(myEnv.StaticObject(os.path.join(fpath, fname + suffix), f))
113117
return objsList
118+
119+
114120

115121
################################################################################
116122
### Build streflop
117123
################################################################################
118124

119125
# 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)
125131

126132
# 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']
129135
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'])
133140

134141
# create the libm sub-part build environment
135-
slibmenv = senv.Clone()
142+
slibmenv = streflopEnv.Clone()
136143
slibmenv.AppendUnique(CPPPATH = ['rts/lib/streflop/libm/headers'])
137144

138145
# gather the sources
139146
sobjs_flt32 = create_static_objects(slibmenv, filelist.get_source(slibmenv, 'rts/lib/streflop/libm/flt-32'), '-streflop-flt32', ['LIBM_COMPILING_FLT32'])
140147
#sobjs_dbl64 = create_static_objects(slibmenv, filelist.get_source(slibmenv, 'rts/lib/streflop/libm/dbl-64'), '-streflop-dbl64', ['LIBM_COMPILING_DBL64'])
141148
#sobjs_ldbl96 = create_static_objects(slibmenv, filelist.get_source(slibmenv, 'rts/lib/streflop/libm/ldbl-96'), '-streflop-ldbl96', ['LIBM_COMPILING_LDBL96'])
149+
142150
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+
]
147155
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+
149159
streflopSource += sobjs_flt32
150160
# not needed => safer (and faster) to not compile them at all
151161
#streflopSource += sobjs_flt32 + sobjs_dbl64 + sobjs_ldbl96
152162

153163
# 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)
157167
Alias('streflop', streflop_lib) # Allow `scons streflop' to compile just streflop
158168

169+
170+
159171
################################################################################
160172
### Build oscpack
161173
################################################################################
@@ -166,7 +178,7 @@ oscenv['CPPPATH'] = []
166178
oscenv.BuildDir(os.path.join(oscenv['builddir'], 'rts/lib/oscpack'),
167179
'rts/lib/oscpack', duplicate = False)
168180

169-
oscenv['CXXFLAGS'] = senv['CXXFLAGS']
181+
oscenv['CXXFLAGS'] = streflopEnv['CXXFLAGS']
170182

171183
# setup flags and defines
172184
if oscenv['platform'] == 'darwin':
@@ -188,6 +200,8 @@ createStaticExtLibraryBuilder(oscenv)
188200
oscpack_lib = oscenv.StaticExtLibrary(oscenv['builddir'], oscpackSource)
189201
Alias('oscpack', oscpack_lib) # Allow `scons oscpack' to compile just oscpack
190202

203+
204+
191205
################################################################################
192206
### Build spring(.exe)
193207
################################################################################
@@ -222,19 +236,20 @@ if env['use_nedmalloc']:
222236
nedmalloc = SConscript('tools/nedmalloc/SConscript', exports='env')
223237
spring_files += [nedmalloc]
224238

225-
springenv = env.Clone(CPPDEFINES=env['CPPDEFINES']+env['spring_defines'])
239+
240+
springEnv = env.Clone(CPPDEFINES=env['CPPDEFINES']+env['spring_defines'])
226241
if env['platform'] == 'windows':
227242
# create import library and .def file on Windows
228243
springDef = os.path.join(env['builddir'], 'spring.def')
229244
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]
233248
instSpringSuppl = [env.Install(os.path.join(env['installprefix'], env['bindir']), springDef)]
234249
instSpringSuppl += [env.Install(os.path.join(env['installprefix'], env['bindir']), springA)]
235250
Alias('install', instSpringSuppl)
236251
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)
238253

239254
Alias('spring', spring)
240255
Default(spring)
@@ -247,15 +262,25 @@ if env['strip']:
247262
env.AddPostAction(spring, Action([['strip','$TARGET']]))
248263

249264

265+
250266
################################################################################
251267
### Build unitsync shared object
252268
################################################################################
269+
253270
# HACK we should probably compile libraries from 7zip, hpiutil2 and minizip
254271
# so we don't need so much bloat here.
255272
# Need a new env otherwise scons chokes on equal targets built with different flags.
273+
#
256274
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']
259284

260285
def remove_precompiled_header(env):
261286
while 'USE_PRECOMPILED_HEADER' in env['CPPDEFINES']:
@@ -265,16 +290,16 @@ def remove_precompiled_header(env):
265290
while '-DUSE_PRECOMPILED_HEADER' in env['CXXFLAGS']:
266291
env['CXXFLAGS'].remove('-DUSE_PRECOMPILED_HEADER')
267292

268-
remove_precompiled_header(uenv)
293+
remove_precompiled_header(unitsyncEnv)
269294

270295
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)
272297

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)
274299
unitsync_files = usync_get_source('tools/unitsync')
275300
unitsync_fs_files = usync_get_source('rts/System/FileSystem/', exclude_list=('rts/System/FileSystem/DataDirLocater.cpp'));
276301
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')
278303
unitsync_minizip_files = usync_get_source('rts/lib/minizip', 'rts/lib/minizip/iowin32.c');
279304
unitsync_hpiutil2_files = usync_get_source('rts/lib/hpiutil2');
280305
unitsync_extra_files = [
@@ -301,20 +326,28 @@ unitsync_files.extend(unitsync_hpiutil2_files)
301326
unitsync_files.extend(unitsync_extra_files)
302327

303328
unitsync_objects = []
329+
304330
if env['platform'] == 'windows':
305331
# crosscompiles on buildbot need this, but native mingw builds fail
306332
# during linking
307333
if os.name != 'nt':
308334
unitsync_files.append('rts/lib/minizip/iowin32.c')
335+
309336
unitsync_files.append('rts/System/FileSystem/DataDirLocater.cpp')
337+
310338
# 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']
312340
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)
314342
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+
318351

319352
Alias('unitsync', unitsync)
320353
inst = env.Install(os.path.join(env['installprefix'], env['libdir']), unitsync)
@@ -334,20 +367,23 @@ if env['platform'] != 'windows':
334367
Default(unitsync)
335368

336369

370+
337371
#################################################################################
338372
#### AIs
339373
#################################################################################
340374

341375
print('AI installprefix: ' + os.path.join(env['installprefix'], env['libdir'], 'AI'))
342376
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+
)
346380
remove_precompiled_header(ai_env)
347381
#SConscript(['AI/SConscript'], exports=['env', 'ai_env'], variant_dir=env['builddir'])
348382
SConscript(['AI/SConscript'], exports=['env', 'ai_env', 'streflop_lib'])
349383
#SConscript(['AI/SConscript'], exports=['env', 'ai_env'], variant_dir=ai_env['builddir'])
350384

385+
386+
351387
################################################################################
352388
### Run Tests
353389
################################################################################
@@ -365,6 +401,7 @@ if 'test' in sys.argv and env['platform'] != 'windows':
365401
os.system(test)
366402

367403

404+
368405
################################################################################
369406
### Build gamedata zip archives & misc.
370407
################################################################################
@@ -429,4 +466,3 @@ for f in luaui_files:
429466
if not os.path.isdir(f):
430467
inst = env.Install(os.path.join(env['installprefix'], env['datadir'], os.path.dirname(f)[5:]), f)
431468
Alias('install', inst)
432-
Collapse file

‎rts/lib/lua/src/lmathlib.cpp‎

Copy file name to clipboardExpand all lines: rts/lib/lua/src/lmathlib.cpp
+7-11Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66

77

88
#include <stdlib.h>
9-
//SPRING#include <math.h>
10-
#include "streflop_cond.h" // FIXME -- should always be compiled with streflop
9+
10+
// Spring
11+
#include "streflop_cond.h"
1112
#include "FastMath.h"
12-
#ifdef UNITSYNC
13-
using std::isfinite;
14-
using std::isnan;
15-
using std::isinf;
16-
#endif
1713

1814
#define lmathlib_c
1915
#define LUA_LIB
@@ -208,7 +204,7 @@ static int math_random (lua_State *L) {
208204
// SPRING
209205
// respect the original lua code that uses rand,
210206
// and rand is auto-seeded always with the same value
211-
#ifdef STREFLOP_H // unitsync is compiled without streflop
207+
#ifdef STREFLOP_H
212208
if (lua_streflop_random_seed == 0) {
213209
lua_streflop_random_seed = 1;
214210
streflop::RandomInit(1);
@@ -247,7 +243,7 @@ static int math_random (lua_State *L) {
247243
static int math_randomseed (lua_State *L) {
248244
/* SPRING srand(luaL_checkint(L, 1)); */
249245

250-
#ifdef STREFLOP_H // unitsync is compiled without streflop
246+
#ifdef STREFLOP_H
251247
streflop::RandomInit(luaL_checkint(L, 1));
252248
#endif
253249
return 0;
@@ -294,8 +290,8 @@ LUALIB_API int luaopen_math (lua_State *L) {
294290
luaL_register(L, LUA_MATHLIBNAME, mathlib);
295291
lua_pushnumber(L, PI);
296292
lua_setfield(L, -2, "pi");
297-
#ifdef STREFLOP_H // unitsync is compiled without streflop
298-
lua_pushnumber(L, streflop::SimplePositiveInfinity);
293+
#ifdef STREFLOP_H
294+
lua_pushnumber(L, SimplePositiveInfinity);
299295
#else
300296
lua_pushnumber(L, HUGE_VAL);
301297
#endif
Collapse file

‎rts/lib/lua/src/lvm.cpp‎

Copy file name to clipboardExpand all lines: rts/lib/lua/src/lvm.cpp
+2-7Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99
#include <stdlib.h>
1010
#include <string.h>
1111

12-
//SPRING#include <math.h>
13-
#include "streflop_cond.h" // FIXME -- should always be compiled with streflop
14-
#ifdef UNITSYNC
15-
using std::isfinite;
16-
using std::isnan;
17-
using std::isinf;
18-
#endif
12+
// Spring
13+
#include "streflop_cond.h"
1914

2015
#define lvm_c
2116
#define LUA_CORE

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.