@@ -99,6 +99,7 @@ class ExtensionConfig(object):
99
99
self .smapi_path = None
100
100
self .all_targets = []
101
101
self .target_archs = set ()
102
+ self .libsafetyhook = {}
102
103
103
104
if self .build_extension ():
104
105
if builder .options .targets :
@@ -265,8 +266,6 @@ class ExtensionConfig(object):
265
266
# Platform-specifics
266
267
if cxx .target .platform == 'linux' :
267
268
self .configure_linux (cxx )
268
- elif cxx .target .platform == 'mac' :
269
- self .configure_mac (cxx )
270
269
elif cxx .target .platform == 'windows' :
271
270
self .configure_windows (cxx )
272
271
@@ -283,10 +282,6 @@ class ExtensionConfig(object):
283
282
284
283
def configure_gcc (self , cxx ):
285
284
cxx .defines += [
286
- 'stricmp=strcasecmp' ,
287
- '_stricmp=strcasecmp' ,
288
- '_snprintf=snprintf' ,
289
- '_vsnprintf=vsnprintf' ,
290
285
'typeof=__typeof__' ,
291
286
'HAVE_STDINT_H' ,
292
287
'GNUC' ,
@@ -299,8 +294,9 @@ class ExtensionConfig(object):
299
294
'-Wno-unused' ,
300
295
'-Wno-switch' ,
301
296
'-Wno-array-bounds' ,
297
+ '-Wno-implicit-exception-spec-mismatch' ,
298
+ '-Wno-dangling-else' ,
302
299
'-msse' ,
303
- '-m32' ,
304
300
'-fvisibility=hidden' ,
305
301
]
306
302
cxx .cxxflags += [
@@ -387,7 +383,7 @@ class ExtensionConfig(object):
387
383
]
388
384
389
385
if builder .options .opt == '1' :
390
- cxx .cflags += ['/Ox' , '/Zo' , '-O3' ]
386
+ cxx .cflags += ['/Ox' , '/Zo' ]
391
387
cxx .linkflags += ['/OPT:ICF' , '/OPT:REF' ]
392
388
393
389
if builder .options .debug == '1' :
@@ -398,28 +394,28 @@ class ExtensionConfig(object):
398
394
cxx .cflags += ['/Oy-' ]
399
395
400
396
def configure_linux (self , cxx ):
401
- cxx .defines += ['_LINUX' , 'POSIX' ]
397
+ cxx .defines += ['_LINUX' , 'POSIX' , 'LINUX' ]
402
398
cxx .linkflags += ['-Wl,--exclude-libs,ALL' , '-lm' ]
403
399
if cxx .vendor == 'gcc' :
404
400
cxx .linkflags += ['-static-libgcc' ]
405
401
elif cxx .vendor == 'clang' :
406
402
cxx .linkflags += ['-lgcc_eh' ]
407
403
cxx .linkflags += ['-static-libstdc++' ]
408
-
409
- def configure_mac (self , cxx ):
410
- cxx .defines += ['OSX' , '_OSX' , 'POSIX' ]
411
- cxx .cflags += ['-mmacosx-version-min=10.7' ]
412
- cxx .linkflags += [
413
- '-mmacosx-version-min=10.7' ,
414
- '-arch' , 'i386' ,
415
- '-lstdc++' ,
416
- '-stdlib=libstdc++' ,
417
- ]
418
- cxx .cxxflags += ['-stdlib=libstdc++' ]
404
+ cxx .cflags += ["-march=pentium4" , "-march=core2" , "-msse2" , "-mfpmath=sse" ]
419
405
420
406
def configure_windows (self , cxx ):
421
407
cxx .defines += ['WIN32' , '_WINDOWS' ]
422
408
409
+ def AddCDetour (self , binary ):
410
+ binary .sources += [ os .path .join (self .sm_root , 'public' , 'CDetour' , 'detours.cpp' ) ]
411
+ binary .compiler .cxxincludes += [ os .path .join (builder .sourcePath , 'third_party' , 'safetyhook' , 'include' ) ]
412
+
413
+ for task in self .libsafetyhook :
414
+ if task .target .arch == binary .compiler .target .arch :
415
+ binary .compiler .linkflags += [task .binary ]
416
+ return
417
+ raise Exception ('No suitable build of safetyhook was found.' )
418
+
423
419
def ConfigureForExtension (self , context , compiler ):
424
420
compiler .cxxincludes += [
425
421
os .path .join (context .currentSourcePath ),
@@ -464,13 +460,6 @@ class ExtensionConfig(object):
464
460
465
461
compiler .defines += ['SOURCE_ENGINE=' + sdk .code ]
466
462
467
- if sdk .name in ['tf2' , 'sdk2013' , 'bms' ] and compiler .like ('gcc' ):
468
- # The 2013 SDK already has these in public/tier0/basetypes.h
469
- compiler .defines .remove ('stricmp=strcasecmp' )
470
- compiler .defines .remove ('_stricmp=strcasecmp' )
471
- compiler .defines .remove ('_snprintf=snprintf' )
472
- compiler .defines .remove ('_vsnprintf=vsnprintf' )
473
-
474
463
if compiler .like ('msvc' ):
475
464
compiler .defines += ['COMPILER_MSVC' ]
476
465
if compiler .target .arch == 'x86' :
@@ -509,7 +498,7 @@ class ExtensionConfig(object):
509
498
elif compiler .target .arch == 'x86_64' :
510
499
lib_folder = os .path .join (sdk .path , 'lib' , 'linux64' )
511
500
else :
512
- lib_folder = os .path .join (sdk .path , 'lib' , 'linux' )
501
+ lib_folder = os .path .join (sdk .path , 'lib' , 'public' , ' linux' )
513
502
elif compiler .target .platform == 'mac' :
514
503
if sdk .name in ['sdk2013' , 'bms' ]:
515
504
lib_folder = os .path .join (sdk .path , 'lib' , 'public' , 'osx32' )
@@ -555,9 +544,9 @@ class ExtensionConfig(object):
555
544
libs .append ('interfaces' )
556
545
for lib in libs :
557
546
if compiler .target .arch == 'x86' :
558
- lib_path = os .path .join (sdk .path , 'lib' , 'public' , lib ) + '.lib'
547
+ lib_path = os .path .join (sdk .path , 'lib' , 'public' , 'x86' , lib ) + '.lib'
559
548
elif compiler .target .arch == 'x86_64' :
560
- lib_path = os .path .join (sdk .path , 'lib' , 'public' , 'win64 ' , lib ) + '.lib'
549
+ lib_path = os .path .join (sdk .path , 'lib' , 'public' , 'x64 ' , lib ) + '.lib'
561
550
compiler .linkflags .append (lib_path )
562
551
563
552
for library in dynamic_libs :
@@ -617,6 +606,17 @@ if Extension.build_extension():
617
606
Extension .detectSDKs ()
618
607
Extension .configure ()
619
608
609
+ class SafetyHookShim (object ):
610
+ def __init__ (self ):
611
+ self .all_targets = {}
612
+ self .libsafetyhook = {}
613
+
614
+ if Extension .build_extension ():
615
+ SafetyHook = SafetyHookShim ()
616
+ SafetyHook .all_targets = Extension .all_targets
617
+ builder .Build (os .path .join ('third_party/safetyhook/AMBuilder' ), {'SafetyHook' : SafetyHook })
618
+ Extension .libsafetyhook = SafetyHook .libsafetyhook
619
+
620
620
if Extension .use_auto_versioning ():
621
621
Extension .generated_headers = builder .Build (
622
622
'tools/Versioning' ,
0 commit comments