@@ -26,6 +26,21 @@ FC_CHECK='''extern "C" {
26
26
int main() { return (int)FcInit(); }
27
27
'''
28
28
29
+ CPP_64BIT_CHECK = '''
30
+ #define TEST(a) (sizeof(void*) == a ? 1 : -1)
31
+ int g_Test[TEST(8)];
32
+
33
+ int main () { return 0; }
34
+ '''
35
+
36
+ CPP_32BIT_CHECK = '''
37
+ #define TEST(a) (sizeof(void*) == a ? 1 : -1)
38
+ int g_Test[TEST(4)];
39
+
40
+ int main () { return 0; }
41
+ '''
42
+
43
+
29
44
Context .Context .line_just = 55 # should fit for everything on 80x26
30
45
31
46
projects = {
@@ -155,13 +170,24 @@ def get_taskgen_count(self):
155
170
except : idx = 0 # don't set tg_idx_count to not increase counter
156
171
return idx
157
172
173
+ @Configure .conf
174
+ def run_test (self , fragment , msg ):
175
+ result = self .check_cxx (fragment = fragment , msg = msg , mandatory = False )
176
+ return False if result == None else True
177
+
158
178
def define_platform (conf ):
159
179
conf .env .DEDICATED = conf .options .DEDICATED
160
180
conf .env .TESTS = conf .options .TESTS
161
181
conf .env .TOGLES = conf .options .TOGLES
162
182
conf .env .GL = conf .options .GL and not conf .options .TESTS and not conf .options .DEDICATED
163
183
conf .env .OPUS = conf .options .OPUS
164
184
185
+ arch32 = conf .run_test (CPP_32BIT_CHECK , 'Testing 32bit support' )
186
+ arch64 = conf .run_test (CPP_64BIT_CHECK , 'Testing 64bit support' )
187
+
188
+ if not (arch32 ^ arch64 ):
189
+ conf .fatal ('Your compiler sucks' )
190
+
165
191
if conf .options .DEDICATED :
166
192
conf .options .SDL = False
167
193
conf .define ('DEDICATED' , 1 )
@@ -186,7 +212,7 @@ def define_platform(conf):
186
212
conf .env .SDL = 1
187
213
conf .define ('USE_SDL' , 1 )
188
214
189
- if conf . options . ALLOW64 :
215
+ if arch64 :
190
216
conf .define ('PLATFORM_64BITS' , 1 )
191
217
192
218
if conf .env .DEST_OS == 'linux' :
@@ -252,11 +278,14 @@ def define_platform(conf):
252
278
'NDEBUG'
253
279
])
254
280
281
+ conf .define ('GIT_COMMIT_HASH' , conf .env .GIT_VERSION )
282
+
283
+
255
284
def options (opt ):
256
285
grp = opt .add_option_group ('Common options' )
257
286
258
- grp .add_option ('-8 ' , '--64bits ' , action = 'store_true' , dest = 'ALLOW64 ' , default = False ,
259
- help = 'allow targetting 64 -bit engine(Linux/Windows/OSX x86 only) [default: %default]' )
287
+ grp .add_option ('-4 ' , '--32bits ' , action = 'store_true' , dest = 'TARGET32 ' , default = False ,
288
+ help = 'allow targetting 32 -bit engine(Linux/Windows/OSX x86 only) [default: %default]' )
260
289
261
290
grp .add_option ('-d' , '--dedicated' , action = 'store_true' , dest = 'DEDICATED' , default = False ,
262
291
help = 'build dedicated server [default: %default]' )
@@ -410,9 +439,10 @@ def configure(conf):
410
439
# subsystem=bld.env.MSVC_SUBSYSTEM
411
440
# TODO: wrapper around bld.stlib, bld.shlib and so on?
412
441
conf .env .MSVC_SUBSYSTEM = 'WINDOWS,5.01'
413
- conf .env .MSVC_TARGETS = ['x86' ] # explicitly request x86 target for MSVC
414
- if conf .options .ALLOW64 :
415
- conf .env .MSVC_TARGETS = ['x64' ]
442
+ conf .env .MSVC_TARGETS = ['x64' ] # explicitly request x86 target for MSVC
443
+ if conf .options .TARGET32 :
444
+ conf .env .MSVC_TARGETS = ['x32' ]
445
+
416
446
if sys .platform == 'win32' :
417
447
conf .load ('msvc_pdb_ext msdev msvs' )
418
448
conf .load ('subproject xcompile compiler_c compiler_cxx gitversion clang_compilation_database strip_on_install_v2 waf_unit_test enforce_pic' )
@@ -421,9 +451,6 @@ def configure(conf):
421
451
elif conf .env .DEST_OS == 'darwin' :
422
452
conf .load ('mm_hook' )
423
453
424
- define_platform (conf )
425
- conf .define ('GIT_COMMIT_HASH' , conf .env .GIT_VERSION )
426
-
427
454
if conf .env .TOGLES :
428
455
projects ['game' ] += ['togles' ]
429
456
elif conf .env .GL :
@@ -435,11 +462,13 @@ def configure(conf):
435
462
if conf .options .OPUS or conf .env .DEST_OS == 'android' :
436
463
projects ['game' ] += ['engine/voice_codecs/opus' ]
437
464
438
- conf .env .BIT32_MANDATORY = not conf .options .ALLOW64
465
+ conf .env .BIT32_MANDATORY = conf .options .TARGET32
439
466
if conf .env .BIT32_MANDATORY :
440
467
Logs .info ('WARNING: will build engine for 32-bit target' )
441
468
conf .load ('force_32bit' )
442
469
470
+ define_platform (conf )
471
+
443
472
if conf .options .DISABLE_WARNS :
444
473
compiler_optional_flags = ['-w' ]
445
474
else :
0 commit comments