mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-03 05:49:41 +03:00
Fix Windows build with WAF
This commit is contained in:
180
wscript
180
wscript
@@ -153,7 +153,6 @@ def define_platform(conf):
|
||||
if conf.options.TOGLES:
|
||||
conf.env.append_unique('DEFINES', ['TOGLES'])
|
||||
|
||||
|
||||
if conf.options.SDL:
|
||||
conf.define('USE_SDL', 1)
|
||||
|
||||
@@ -166,8 +165,7 @@ def define_platform(conf):
|
||||
'NO_HOOK_MALLOC',
|
||||
'_DLL_EXT=.so'
|
||||
])
|
||||
|
||||
if conf.env.DEST_OS == 'android':
|
||||
elif conf.env.DEST_OS == 'android':
|
||||
conf.env.append_unique('DEFINES', [
|
||||
'ANDROID=1', '_ANDROID=1',
|
||||
'LINUX=1', '_LINUX=1',
|
||||
@@ -176,8 +174,20 @@ def define_platform(conf):
|
||||
'NO_HOOK_MALLOC',
|
||||
'_DLL_EXT=.so'
|
||||
])
|
||||
elif conf.env.DEST_OS == 'win32':
|
||||
conf.env.append_unique('DEFINES', [
|
||||
'WIN32=1', '_WIN32=1',
|
||||
'_WINDOWS',
|
||||
'_DLL_EXT=.dll',
|
||||
'_CRT_SECURE_NO_DEPRECATE',
|
||||
'_CRT_NONSTDC_NO_DEPRECATE',
|
||||
'_ALLOW_RUNTIME_LIBRARY_MISMATCH',
|
||||
'_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH',
|
||||
'_ALLOW_MSC_VER_MISMATCH',
|
||||
'NO_X360_XDK'
|
||||
])
|
||||
|
||||
if conf.options.DEBUG_ENGINE:
|
||||
if conf.options.DEBUG_ENGINE or conf.options.BUILD_TYPE == 'debug':
|
||||
conf.env.append_unique('DEFINES', [
|
||||
'DEBUG', '_DEBUG'
|
||||
])
|
||||
@@ -198,10 +208,10 @@ def options(opt):
|
||||
grp.add_option('-D', '--debug-engine', action = 'store_true', dest = 'DEBUG_ENGINE', default = False,
|
||||
help = 'build with -DDEBUG [default: %default]')
|
||||
|
||||
grp.add_option('--use-sdl', action = 'store', dest = 'SDL', type = 'int', default = True,
|
||||
grp.add_option('--use-sdl', action = 'store', dest = 'SDL', type = 'int', default = sys.platform != 'win32',
|
||||
help = 'build engine with SDL [default: %default]')
|
||||
|
||||
grp.add_option('--use-togl', action = 'store', dest = 'GL', type = 'int', default = True,
|
||||
grp.add_option('--use-togl', action = 'store', dest = 'GL', type = 'int', default = sys.platform != 'win32',
|
||||
help = 'build engine with ToGL [default: %default]')
|
||||
|
||||
grp.add_option('--build-games', action = 'store', dest = 'GAMES', type = 'string', default = 'hl2',
|
||||
@@ -223,7 +233,7 @@ def options(opt):
|
||||
opt.load('reconfigure')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('fwgslib reconfigure')
|
||||
conf.load('fwgslib reconfigure compiler_optimizations')
|
||||
|
||||
# Force XP compability, all build targets should add
|
||||
# subsystem=bld.env.MSVC_SUBSYSTEM
|
||||
@@ -231,7 +241,7 @@ def configure(conf):
|
||||
conf.env.MSVC_SUBSYSTEM = 'WINDOWS,5.01'
|
||||
conf.env.MSVC_TARGETS = ['x86'] # explicitly request x86 target for MSVC
|
||||
if sys.platform == 'win32':
|
||||
conf.load('msvc msvc_pdb msdev msvs')
|
||||
conf.load('msvc_pdb msdev msvs')
|
||||
conf.load('subproject xcompile compiler_c compiler_cxx gitversion clang_compilation_database strip_on_install waf_unit_test enforce_pic')
|
||||
|
||||
define_platform(conf)
|
||||
@@ -241,6 +251,9 @@ def configure(conf):
|
||||
elif conf.env.GL:
|
||||
projects['game'] += ['togl']
|
||||
|
||||
if conf.env.DEST_OS == 'win32':
|
||||
projects['game'] += ['utils/bzip2']
|
||||
projects['dedicated'] += ['utils/bzip2']
|
||||
|
||||
if conf.env.DEST_OS in ['win32', 'linux', 'darwin'] and conf.env.DEST_CPU == 'x86_64':
|
||||
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64
|
||||
@@ -269,7 +282,8 @@ def configure(conf):
|
||||
|
||||
cflags, linkflags = conf.get_optimization_flags()
|
||||
|
||||
flags = ['-fPIC']
|
||||
if conf.env.DEST_OS != 'win32':
|
||||
flags = ['-fPIC']
|
||||
|
||||
if conf.env.DEST_OS == 'android':
|
||||
flags += [
|
||||
@@ -289,15 +303,51 @@ def configure(conf):
|
||||
flags += ['-mcpu=cortex-a15', '-mtune=cortex-a15']
|
||||
else:
|
||||
flags += ['-march=native', '-mtune=native']
|
||||
else:
|
||||
elif conf.env.COMPILER_GCC:
|
||||
flags += ['-march=native','-mtune=native','-mfpmath=sse', '-msse', '-msse2']
|
||||
|
||||
|
||||
cflags += flags
|
||||
linkflags += flags
|
||||
if conf.env.DEST_OS != 'win32':
|
||||
cflags += flags
|
||||
linkflags += flags
|
||||
else:
|
||||
cflags += [
|
||||
'/I'+os.path.abspath('.')+'/thirdparty/SDL',
|
||||
'/arch:SSE',
|
||||
'/GF',
|
||||
'/Gy',
|
||||
'/fp:fast',
|
||||
'/Zc:forScope',
|
||||
'/Zc:wchar_t',
|
||||
'/GR',
|
||||
'/TP'
|
||||
]
|
||||
|
||||
if conf.options.BUILD_TYPE == 'debug':
|
||||
linkflags += [
|
||||
'/INCREMENTAL:NO',
|
||||
'/NODEFAULTLIB:libc',
|
||||
'/NODEFAULTLIB:libcd',
|
||||
'/NODEFAULTLIB:libcmt'
|
||||
]
|
||||
else:
|
||||
linkflags += [
|
||||
'/INCREMENTAL',
|
||||
'/NODEFAULTLIB:libc',
|
||||
'/NODEFAULTLIB:libcd',
|
||||
'/NODEFAULTLIB:libcmtd'
|
||||
]
|
||||
|
||||
linkflags += [
|
||||
'/LIBPATH:'+os.path.abspath('.')+'/lib/public',
|
||||
'/LIBPATH:'+os.path.abspath('.')+'/lib/common/win32/2015/release',
|
||||
'/LIBPATH:'+os.path.abspath('.')+'/dx9sdk/lib'
|
||||
]
|
||||
|
||||
# And here C++ flags starts to be treated separately
|
||||
cxxflags = list(cflags) + ['-std=c++11','-fpermissive']
|
||||
cxxflags = list(cflags)
|
||||
if conf.env.DEST_OS != 'win32':
|
||||
cxxflags += ['-std=c++11','-fpermissive']
|
||||
|
||||
if conf.env.COMPILER_CC == 'gcc':
|
||||
# wrapfunctions = ['freopen','creat','access','__xstat','stat','lstat','fopen64','open64',
|
||||
@@ -306,10 +356,13 @@ def configure(conf):
|
||||
|
||||
# for func in wrapfunctions:
|
||||
# linkflags += ['-Wl,--wrap='+func]
|
||||
|
||||
|
||||
conf.define('COMPILER_GCC', 1)
|
||||
|
||||
elif conf.env.COMPILER_CC == 'msvc':
|
||||
conf.define('COMPILER_MSVC', 1)
|
||||
if conf.env.DEST_CPU == 'x86':
|
||||
conf.define('COMPILER_MSVC32', 1)
|
||||
elif conf.env.DEST_CPU == 'x86_64':
|
||||
conf.define('COMPILER_MSVC64', 1)
|
||||
|
||||
if conf.env.COMPILER_CC != 'msvc':
|
||||
conf.check_cc(cflags=cflags, linkflags=linkflags, msg='Checking for required C flags')
|
||||
@@ -328,7 +381,59 @@ def configure(conf):
|
||||
conf.env.append_unique('LINKFLAGS', linkflags)
|
||||
conf.env.append_unique('INCLUDES', [os.path.abspath('common/')])
|
||||
|
||||
if conf.env.DEST_OS != 'android':
|
||||
if conf.env.DEST_OS == 'android':
|
||||
conf.check(lib='SDL2', uselib_store='SDL2')
|
||||
conf.check(lib='freetype2', uselib_store='FT2')
|
||||
conf.check(lib='openal', uselib_store='OPENAL')
|
||||
conf.check(lib='jpeg', uselib_store='JPEG')
|
||||
conf.check(lib='png', uselib_store='PNG')
|
||||
conf.check(lib='curl', uselib_store='CURL')
|
||||
conf.check(lib='z', uselib_store='ZLIB')
|
||||
conf.check(lib='crypto', uselib_store='CRYPTO')
|
||||
conf.check(lib='ssl', uselib_store='SSL')
|
||||
conf.check(lib='expat', uselib_store='EXPAT')
|
||||
conf.check(lib='android_support', uselib_store='ANDROID_SUPPORT')
|
||||
elif conf.env.DEST_OS == 'win32':
|
||||
# Common Win32 libraries
|
||||
# Don't check them more than once, to save time
|
||||
# Usually, they are always available
|
||||
# but we need them in uselib
|
||||
a = [
|
||||
'user32',
|
||||
'shell32',
|
||||
'gdi32',
|
||||
'advapi32',
|
||||
'dbghelp',
|
||||
'psapi',
|
||||
'ws2_32',
|
||||
'rpcrt4',
|
||||
'winmm',
|
||||
'wininet',
|
||||
'ole32',
|
||||
'shlwapi',
|
||||
'imm32'
|
||||
]
|
||||
|
||||
if conf.env.COMPILER_CC == 'msvc':
|
||||
for i in a:
|
||||
conf.start_msg('Checking for MSVC library')
|
||||
conf.check_lib_msvc(i)
|
||||
conf.end_msg(i)
|
||||
else:
|
||||
for i in a:
|
||||
conf.check_cc(lib = i)
|
||||
|
||||
conf.check(lib='libz', uselib_store='ZLIB')
|
||||
conf.check(lib='nvtc', uselib_store='NVTC')
|
||||
conf.check(lib='ati_compress_mt_vc10', uselib_store='ATI_COMPRESS_MT_VC10')
|
||||
conf.check(lib='SDL2', uselib_store='SDL2')
|
||||
conf.check(lib='libjpeg', uselib_store='JPEG')
|
||||
conf.check(lib='libpng', uselib_store='PNG')
|
||||
conf.check(lib='d3dx9', uselib_store='D3DX9')
|
||||
conf.check(lib='d3d9', uselib_store='D3D9')
|
||||
conf.check(lib='dsound', uselib_store='DSOUND')
|
||||
conf.check(lib='dxguid', uselib_store='DXGUID')
|
||||
else:
|
||||
if conf.options.SDL:
|
||||
conf.check_cfg(package='sdl2', uselib_store='SDL2', args=['--cflags', '--libs'])
|
||||
if conf.options.DEDICATED:
|
||||
@@ -341,18 +446,6 @@ def configure(conf):
|
||||
conf.check_cfg(package='libpng', uselib_store='PNG', args=['--cflags', '--libs'])
|
||||
conf.check_cfg(package='libcurl', uselib_store='CURL', args=['--cflags', '--libs'])
|
||||
conf.check_cfg(package='zlib', uselib_store='ZLIB', args=['--cflags', '--libs'])
|
||||
else:
|
||||
conf.check(lib='SDL2', uselib_store='SDL2')
|
||||
conf.check(lib='freetype2', uselib_store='FT2')
|
||||
conf.check(lib='openal', uselib_store='OPENAL')
|
||||
conf.check(lib='jpeg', uselib_store='JPEG')
|
||||
conf.check(lib='png', uselib_store='PNG')
|
||||
conf.check(lib='curl', uselib_store='CURL')
|
||||
conf.check(lib='z', uselib_store='ZLIB')
|
||||
conf.check(lib='crypto', uselib_store='CRYPTO')
|
||||
conf.check(lib='ssl', uselib_store='SSL')
|
||||
conf.check(lib='expat', uselib_store='EXPAT')
|
||||
conf.check(lib='android_support', uselib_store='ANDROID_SUPPORT')
|
||||
|
||||
if conf.env.DEST_OS != 'win32':
|
||||
conf.check_cc(lib='dl', mandatory=False)
|
||||
@@ -361,31 +454,6 @@ def configure(conf):
|
||||
|
||||
if not conf.env.LIB_M: # HACK: already added in xcompile!
|
||||
conf.check_cc(lib='m')
|
||||
else:
|
||||
# Common Win32 libraries
|
||||
# Don't check them more than once, to save time
|
||||
# Usually, they are always available
|
||||
# but we need them in uselib
|
||||
a = map(lambda x: {
|
||||
# 'features': 'c',
|
||||
# 'message': '...' + x,
|
||||
'lib': x,
|
||||
# 'uselib_store': x.upper(),
|
||||
# 'global_define': False,
|
||||
}, [
|
||||
'user32',
|
||||
'shell32',
|
||||
'gdi32',
|
||||
'advapi32',
|
||||
'dbghelp',
|
||||
'psapi',
|
||||
'ws2_32'
|
||||
])
|
||||
|
||||
for i in a:
|
||||
conf.check_cc(**i)
|
||||
|
||||
# conf.multicheck(*a, run_all_tests = True, mandatory = True)
|
||||
|
||||
# indicate if we are packaging for Linux/BSD
|
||||
if conf.env.DEST_OS != 'android':
|
||||
@@ -407,6 +475,10 @@ def configure(conf):
|
||||
def build(bld):
|
||||
os.environ["CCACHE_DIR"] = os.path.abspath('.ccache/'+bld.env.COMPILER_CC+'/'+bld.env.DEST_OS+'/'+bld.env.DEST_CPU)
|
||||
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
projects['game'] += ['utils/bzip2']
|
||||
projects['dedicated'] += ['utils/bzip2']
|
||||
|
||||
if bld.env.DEDICATED:
|
||||
bld.add_subproject(projects['dedicated'])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user