@@ -26,6 +26,21 @@ FC_CHECK='''extern "C" {
2626int main() { return (int)FcInit(); }
2727'''
2828
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+
2944Context .Context .line_just = 55 # should fit for everything on 80x26
3045
3146projects = {
@@ -155,13 +170,24 @@ def get_taskgen_count(self):
155170 except : idx = 0 # don't set tg_idx_count to not increase counter
156171 return idx
157172
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+
158178def define_platform (conf ):
159179 conf .env .DEDICATED = conf .options .DEDICATED
160180 conf .env .TESTS = conf .options .TESTS
161181 conf .env .TOGLES = conf .options .TOGLES
162182 conf .env .GL = conf .options .GL and not conf .options .TESTS and not conf .options .DEDICATED
163183 conf .env .OPUS = conf .options .OPUS
164184
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+
165191 if conf .options .DEDICATED :
166192 conf .options .SDL = False
167193 conf .define ('DEDICATED' , 1 )
@@ -186,7 +212,7 @@ def define_platform(conf):
186212 conf .env .SDL = 1
187213 conf .define ('USE_SDL' , 1 )
188214
189- if conf . options . ALLOW64 :
215+ if arch64 :
190216 conf .define ('PLATFORM_64BITS' , 1 )
191217
192218 if conf .env .DEST_OS == 'linux' :
@@ -252,11 +278,14 @@ def define_platform(conf):
252278 'NDEBUG'
253279 ])
254280
281+ conf .define ('GIT_COMMIT_HASH' , conf .env .GIT_VERSION )
282+
283+
255284def options (opt ):
256285 grp = opt .add_option_group ('Common options' )
257286
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]' )
260289
261290 grp .add_option ('-d' , '--dedicated' , action = 'store_true' , dest = 'DEDICATED' , default = False ,
262291 help = 'build dedicated server [default: %default]' )
@@ -410,9 +439,10 @@ def configure(conf):
410439 # subsystem=bld.env.MSVC_SUBSYSTEM
411440 # TODO: wrapper around bld.stlib, bld.shlib and so on?
412441 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+
416446 if sys .platform == 'win32' :
417447 conf .load ('msvc_pdb_ext msdev msvs' )
418448 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):
421451 elif conf .env .DEST_OS == 'darwin' :
422452 conf .load ('mm_hook' )
423453
424- define_platform (conf )
425- conf .define ('GIT_COMMIT_HASH' , conf .env .GIT_VERSION )
426-
427454 if conf .env .TOGLES :
428455 projects ['game' ] += ['togles' ]
429456 elif conf .env .GL :
@@ -435,11 +462,13 @@ def configure(conf):
435462 if conf .options .OPUS or conf .env .DEST_OS == 'android' :
436463 projects ['game' ] += ['engine/voice_codecs/opus' ]
437464
438- conf .env .BIT32_MANDATORY = not conf .options .ALLOW64
465+ conf .env .BIT32_MANDATORY = conf .options .TARGET32
439466 if conf .env .BIT32_MANDATORY :
440467 Logs .info ('WARNING: will build engine for 32-bit target' )
441468 conf .load ('force_32bit' )
442469
470+ define_platform (conf )
471+
443472 if conf .options .DISABLE_WARNS :
444473 compiler_optional_flags = ['-w' ]
445474 else :
0 commit comments