From d5d0cac107c0c5c636235d9a409c19f5f448d406 Mon Sep 17 00:00:00 2001 From: JusicP Date: Sat, 19 Mar 2022 14:40:11 +0200 Subject: [PATCH] Fix Windows build with WAF --- appframework/wscript | 19 ++- bitmap/wscript | 9 +- dedicated/wscript | 15 +- engine/audio/private/snd_dev_direct.cpp | 2 +- engine/wscript | 38 +++-- filesystem/wscript | 9 +- game/client/wscript | 7 +- game/server/wscript | 5 + gameui/wscript | 14 +- inputsystem/wscript | 9 +- ivp | 2 +- launcher/wscript | 9 +- materialsystem/shaderapidx9/wscript | 26 ++- materialsystem/shadersystem.cpp | 3 +- materialsystem/wscript | 3 + public/tier0/etwprof.h | 2 +- scripts/waifulib/compiler_optimizations.py | 12 +- serverbrowser/wscript | 5 + soundemittersystem/wscript | 3 + tier0/assert_dialog.rc | 2 + tier0/wscript | 32 ++-- tier1/wscript | 19 ++- utils/bzip2/wscript | 7 +- vgui2/src/wscript | 17 +- vgui2/vgui_controls/wscript | 3 + vgui2/vgui_surfacelib/wscript | 11 +- vguimatsurface/wscript | 9 +- video/wscript | 3 + vstdlib/wscript | 6 +- vtf/wscript | 6 +- wscript | 180 ++++++++++++++------- 31 files changed, 361 insertions(+), 126 deletions(-) diff --git a/appframework/wscript b/appframework/wscript index d5126d96dd..29822a4b18 100755 --- a/appframework/wscript +++ b/appframework/wscript @@ -18,13 +18,24 @@ def build(bld): source = [ 'AppSystemGroup.cpp', '../public/filesystem_init.cpp', -# 'vguimatsysapp.cpp' [$WIN32] -# 'winapp.cpp' [$WIN32] - 'posixapp.cpp',# [$POSIX] - 'sdlmgr.cpp'# [$SDL] # 'glmrendererinfo_osx.mm' [$OSXALL] ] + if bld.env.SDL: + source += [ + 'sdlmgr.cpp' + ] + + if bld.env.DEST_OS == 'win32': + source += [ + 'vguimatsysapp.cpp', + 'winapp.cpp' + ] + else: + source += [ + 'posixapp.cpp',# [$POSIX] + ] + includes = [ '.', '../public', diff --git a/bitmap/wscript b/bitmap/wscript index dae3a16f45..8c32f45a10 100755 --- a/bitmap/wscript +++ b/bitmap/wscript @@ -21,7 +21,6 @@ def build(bld): 'float_bm.cpp', 'float_bm2.cpp', 'float_bm3.cpp', - #'float_bm4.cpp', [$WINDOWS] 'float_bm_bilateral_filter.cpp', 'float_cube.cpp', 'imageformat.cpp', @@ -31,6 +30,11 @@ def build(bld): 'tgawriter.cpp', 'bitmap.cpp' ] + + if bld.env.DEST_OS == 'win32': + source += [ + 'float_bm4.cpp' + ] includes = [ '.', @@ -43,6 +47,9 @@ def build(bld): defines = [] libs = [] + + if bld.env.DEST_OS == 'win32': + libs += ['NVTC', 'ATI_COMPRESS_MT_VC10'] bld.stlib( source = source, diff --git a/dedicated/wscript b/dedicated/wscript index 485ef2880a..adb01eb821 100755 --- a/dedicated/wscript +++ b/dedicated/wscript @@ -24,11 +24,8 @@ def build(bld): '../common/SteamAppStartup.cpp', 'sys_common.cpp', 'sys_ded.cpp', - #'sys_windows.cpp', [$WINDOWS] - 'sys_linux.cpp', # [$POSIX] 'console/conproc.cpp', 'console/textconsole.cpp', - 'console/TextConsoleUnix.cpp', # [$POSIX] '../filesystem/filetracker.cpp', '../filesystem/basefilesystem.cpp', '../filesystem/packfile.cpp', @@ -36,9 +33,19 @@ def build(bld): '../filesystem/filesystem_stdio.cpp', '../filesystem/QueuedLoader.cpp', '../public/zip_utils.cpp', - '../filesystem/linux_support.cpp' # [$POSIX] ] + if bld.env.DEST_OS == 'win32' + source += [ + 'sys_windows.cpp' + ] + else: + source += [ + 'sys_linux.cpp', # [$POSIX] + 'console/TextConsoleUnix.cpp', # [$POSIX] + '../filesystem/linux_support.cpp' # [$POSIX] + ] + includes = [ '.', '../public', diff --git a/engine/audio/private/snd_dev_direct.cpp b/engine/audio/private/snd_dev_direct.cpp index fad4752d16..a60e181bfc 100644 --- a/engine/audio/private/snd_dev_direct.cpp +++ b/engine/audio/private/snd_dev_direct.cpp @@ -11,7 +11,7 @@ // Fix for VS 2010 build errors copied from Dota #if !defined( NEW_DXSDK ) && ( _MSC_VER >= 1600 ) #undef KSDATAFORMAT_SUBTYPE_WAVEFORMATEX -#undef KSDATAFORMAT_SUBTYPE_PCM +//#undef KSDATAFORMAT_SUBTYPE_PCM #undef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT #endif #include diff --git a/engine/wscript b/engine/wscript index 29a03ad826..117e504724 100755 --- a/engine/wscript +++ b/engine/wscript @@ -171,7 +171,6 @@ def build(bld): 'sys_dll.cpp', 'sys_dll2.cpp', 'sys_engine.cpp', - 'sys_linuxwind.cpp', #[$POSIX] 'testscriptmgr.cpp', 'traceinit.cpp', '../public/vallocator.cpp', @@ -193,21 +192,34 @@ def build(bld): 'EngineSoundServer.cpp', 'audio/private/voice_wavefile.cpp', 'audio/private/vox.cpp', - 'audio/private/snd_posix.cpp', # [$POSIX] - #'audio/private/snd_dev_direct.cpp', [$WINDOWS]/ - #'audio/private/snd_dev_wave.cpp', [$WINDOWS]/ - #'audio/private/voice_mixer_controls.cpp', [$WINDOWS] / - #'audio/private/voice_record_dsound.cpp', [$WINDOWS] / #'audio/private/snd_dev_xaudio.cpp',[$X360] #'audio/private/snd_wave_mixer_xma.cpp', [$X360] - 'audio/private/snd_dev_sdl.cpp', #[$SDL && !$OSXALL] #'audio/private/snd_dev_openal.cpp', # [$OSXALL] #'audio/private/snd_dev_mac_audioqueue.cpp',# [$OSXALL] #'audio/private/voice_record_mac_audioqueue.cpp', #[$OSXALL] ] + if bld.env.SDL: + source += [ + 'audio/private/snd_dev_sdl.cpp' #[$SDL && !$OSXALL] + ] + + if bld.env.DEST_OS == 'win32': + source += [ + '../public/tier0/memoverride.cpp', + 'audio/private/snd_dev_direct.cpp', + 'audio/private/snd_dev_wave.cpp', + 'audio/private/voice_mixer_controls.cpp', + 'audio/private/voice_record_dsound.cpp', + ] + else: + source += [ + 'sys_linuxwind.cpp', + 'audio/private/snd_posix.cpp', + ] + if bld.env.DEDICATED: source += ['cl_null.cpp'] else: @@ -295,8 +307,6 @@ def build(bld): 'audio/private/VBRHeader.cpp', #[!$X360] 'audio/private/voice.cpp', #[!$X360] 'audio/private/voice_sound_engine_interface.cpp', #[!$X360] - 'audio/private/voice_mixer_controls_openal.cpp', #[$OSXALL||$LINUXALL] - 'audio/private/voice_record_openal.cpp', #[$OSXALL||$LINUXALL] '../public/vgui_controls/vgui_controls.cpp', '../common/vgui/vgui_basebudgetpanel.cpp', '../common/vgui/vgui_budgetbargraphpanel.cpp', @@ -314,6 +324,12 @@ def build(bld): 'vgui_vprofpanel.cpp', 'toolframework.cpp' ] + + if bld.env.DEST_OS != 'win32': + source += [ + 'audio/private/voice_mixer_controls_openal.cpp', #[$OSXALL||$LINUXALL] + 'audio/private/voice_record_openal.cpp' #[$OSXALL||$LINUXALL] + ] includes = [ '.', @@ -332,7 +348,9 @@ def build(bld): if bld.env.DEST_OS == 'android': libs += ['SSL', 'CRYPTO'] # android curl was built with openssl - + elif bld.env.DEST_OS == 'win32': + libs += ['USER32', 'WINMM', 'WININET', 'DSOUND', 'DXGUID', 'GDI32', 'bzip2'] + install_path = bld.env.LIBDIR bld.shlib( diff --git a/filesystem/wscript b/filesystem/wscript index adfdd37298..5a8ae9466d 100755 --- a/filesystem/wscript +++ b/filesystem/wscript @@ -28,10 +28,14 @@ def build(bld): '../public/kevvaluescompiler.cpp', '../public/zip_utils.cpp', 'QueuedLoader.cpp', - 'linux_support.cpp', # [$POSIX] '../public/tier0/memoverride.cpp' ] + if bld.env.DEST_OS != 'win32': + source += [ + 'linux_support.cpp' + ] + includes = [ '.', '../public', @@ -43,6 +47,9 @@ def build(bld): defines = [] libs = ['tier0','tier1','tier2','vstdlib','vpklib'] + + if bld.env.DEST_OS == 'win32': + libs += ['SHELL32'] install_path = bld.env.LIBDIR diff --git a/game/client/wscript b/game/client/wscript index 9b9a50e4d5..961dea3728 100755 --- a/game/client/wscript +++ b/game/client/wscript @@ -66,8 +66,11 @@ def build(bld): if bld.env.DEST_OS != 'android': install_path += '/'+bld.env.GAMES+'/bin' - source = [ 'touch.cpp', 'arch.c' ] - + source = [ 'arch.c' ] + if bld.env.DEST_OS == 'win32': + source += [ '../../public/tier0/memoverride.cpp' ] + libs += ['USER32'] + if bld.env.DEST_OS == 'android': source += [ 'third/minizip/mz_zip.c', diff --git a/game/server/wscript b/game/server/wscript index a474c2f8cb..03f2b24d6f 100755 --- a/game/server/wscript +++ b/game/server/wscript @@ -54,6 +54,8 @@ def build(bld): defines = [] libs = ['tier0','particles','dmxloader','tier1','tier2','tier3','mathlib','vstdlib','choreoobjects','steam_api'] + if bld.env.DEST_OS == 'win32': + libs += ['USER32'] install_path = bld.env.PREFIX if bld.env.DEST_OS != 'android': @@ -63,6 +65,9 @@ def build(bld): includes += game["includes"] defines = game["defines"] + if bld.env.DEST_OS == 'win32': + source += ['../../public/tier0/memoverride.cpp'] + defines.remove('PROTECTED_THINGS_ENABLE') bld.shlib( diff --git a/gameui/wscript b/gameui/wscript index 76473ce265..e644396de5 100755 --- a/gameui/wscript +++ b/gameui/wscript @@ -21,7 +21,6 @@ def build(bld): 'BasePanel.cpp', 'GameConsole.cpp', 'GameUI_Interface.cpp', - # 'LogoFile.cpp', [!$POSIX] 'ModInfo.cpp', 'MouseMessageForwardingPanel.cpp', '../common/GameUI/ObjectList.cpp', @@ -66,7 +65,6 @@ def build(bld): 'LoadCommentaryDialog.cpp', 'LoadingDialog.cpp', 'BaseSaveGameDialog.cpp', - #'ChangeGameDialog.cpp', [!$POSIX] 'CreateMultiplayerGameBotPage.cpp', 'CreateMultiplayerGameDialog.cpp', 'CreateMultiplayerGameGameplayPage.cpp', @@ -87,7 +85,6 @@ def build(bld): 'OptionsSubAudio.cpp', 'OptionsSubDifficulty.cpp', 'OptionsSubGame.cpp', - #'OptionsSubHaptics.cpp', [$WIN32] [$WIN32] 'OptionsSubKeyboard.cpp', 'OptionsSubMouse.cpp', 'OptionsSubMultiplayer.cpp', @@ -96,6 +93,14 @@ def build(bld): 'OptionsSubVoice.cpp', ] + if bld.env.DEST_OS == 'win32': + source += [ + '../public/tier0/memoverride.cpp', + 'LogoFile.cpp', + 'ChangeGameDialog.cpp', + 'OptionsSubHaptics.cpp' + ] + includes = [ '.', '../public', @@ -109,6 +114,9 @@ def build(bld): libs = ['tier0','vgui_controls','tier1','tier2','tier3','vstdlib','vtf','bitmap','mathlib','SDL2','steam_api','matsys_controls','JPEG','PNG','ZLIB'] + if bld.env.DEST_OS == 'win32': + libs += ['USER32', 'GDI32'] + install_path = bld.env.LIBDIR bld.shlib( diff --git a/inputsystem/wscript b/inputsystem/wscript index cf2e8be518..814fe7e252 100755 --- a/inputsystem/wscript +++ b/inputsystem/wscript @@ -19,11 +19,15 @@ def build(bld): 'inputsystem.cpp', 'joystick_sdl.cpp', 'touch_sdl.cpp', - #'novint.cpp', # [$WIN32] 'key_translation.cpp', 'steamcontroller.cpp' ] + if bld.env.DEST_OS == 'win32': + source += [ + 'novint.cpp' + ] + includes = [ '.', '../common', @@ -35,6 +39,9 @@ def build(bld): libs = ['tier0','tier1','tier2','vstdlib','SDL2','steam_api'] + if bld.env.DEST_OS == 'win32': + libs += ['USER32'] + install_path = bld.env.LIBDIR bld.shlib( diff --git a/ivp b/ivp index 82849306f7..5dc57228f1 160000 --- a/ivp +++ b/ivp @@ -1 +1 @@ -Subproject commit 82849306f728db57868d7a82fe7bcff333eb468c +Subproject commit 5dc57228f12ac1deca3bb2d20ef3eaa290d65586 diff --git a/launcher/wscript b/launcher/wscript index 5beb4f915c..ab9e1a3ff5 100755 --- a/launcher/wscript +++ b/launcher/wscript @@ -19,9 +19,13 @@ def build(bld): '../public/filesystem_init.cpp', 'launcher.cpp', 'reslistgenerator.cpp', - 'android.cpp' ] + if bld.env.DEST_OS == 'android': + source += [ + 'android.cpp' + ] + includes = [ '.', '../public', @@ -33,6 +37,9 @@ def build(bld): defines = [] libs = ['tier0','tier1','tier2','tier3','vstdlib','steam_api','appframework','SDL2','togl'] + + if bld.env.DEST_OS == 'win32': + libs += ['USER32', 'OLE32', 'SHELL32'] install_path = bld.env.LIBDIR diff --git a/materialsystem/shaderapidx9/wscript b/materialsystem/shaderapidx9/wscript index d1126bb9e5..6165d51582 100755 --- a/materialsystem/shaderapidx9/wscript +++ b/materialsystem/shaderapidx9/wscript @@ -18,9 +18,13 @@ def configure(conf): #'PROTECTED_THINGS_ENABLE', # conflicts with stlport 'strncpy=use_Q_strncpy_instead', '_snprintf=use_Q_snprintf_instead', - 'GL_GLEXT_PROTOTYPES', - 'DX_TO_GL_ABSTRACTION' ]) + + if conf.env.DEST_OS == 'win32' and not conf.env.GL: + conf.env.append_unique('DEFINES',[ + 'USE_ACTUAL_DX', + ]) + def build(bld): source = [ @@ -29,7 +33,6 @@ def build(bld): 'hardwareconfig.cpp', 'meshbase.cpp', 'meshdx8.cpp', - #'recording.cpp', [$WIN32 && !$GL] 'shaderapidx8.cpp', 'shaderdevicebase.cpp', 'shaderapibase.cpp', @@ -40,11 +43,20 @@ def build(bld): 'cvballoctracker.cpp', 'vertexdecl.cpp', 'vertexshaderdx8.cpp', - #'wmi.cpp', [$WIN32 && !$GL] #'textureheap.cpp', [$X360] - 'winutils.cpp'# [!$WIN32] ] + if bld.env.DEST_OS == 'win32' and not bld.env.GL: + source += [ + 'recording.cpp', + 'wmi.cpp' + ] + + if bld.env.DEST_OS != 'win32': + source += ['winutils.cpp'] + else: + source += ['../../public/tier0/memoverride.cpp'] + includes = [ '.', '../../public', @@ -60,7 +72,9 @@ def build(bld): if bld.env.DEST_OS == 'android': libs += ['ANDROID_SUPPORT'] - + elif bld.env.DEST_OS == 'win32' and not bld.env.GL: + libs += ['D3D9', 'D3DX9', 'bzip2'] + install_path = bld.env.LIBDIR bld.shlib( diff --git a/materialsystem/shadersystem.cpp b/materialsystem/shadersystem.cpp index 3a52393edb..b3da33e110 100644 --- a/materialsystem/shadersystem.cpp +++ b/materialsystem/shadersystem.cpp @@ -447,7 +447,8 @@ extern "C" void CShaderSystem::VerifyBaseShaderDLL( CSysModule *pModule ) { -#if defined( _WIN32 ) && !defined( _X360 ) +//#if defined( _WIN32 ) && !defined( _X360 ) +#if 0 const char *pErrorStr = "Corrupt save data settings."; unsigned char *testData1 = new unsigned char[SHADER_DLL_VERIFY_DATA_LEN1]; diff --git a/materialsystem/wscript b/materialsystem/wscript index a99fb8042d..763870c18a 100755 --- a/materialsystem/wscript +++ b/materialsystem/wscript @@ -47,6 +47,9 @@ def build(bld): 'ctexturecompositor.cpp' ] + if bld.env.DEST_OS == 'win32': + source += ['../public/tier0/memoverride.cpp'] + includes = [ '.', '../../public', diff --git a/public/tier0/etwprof.h b/public/tier0/etwprof.h index c1d4282204..dc9d1c39e7 100644 --- a/public/tier0/etwprof.h +++ b/public/tier0/etwprof.h @@ -27,7 +27,7 @@ #ifdef IS_WINDOWS_PC // ETW support should be compiled in for all Windows PC platforms. It isn't // supported on Windows XP but that is determined at run-time. -#define ETW_MARKS_ENABLED +//#define ETW_MARKS_ENABLED #endif #ifdef ETW_MARKS_ENABLED diff --git a/scripts/waifulib/compiler_optimizations.py b/scripts/waifulib/compiler_optimizations.py index 90dbcbe542..fcfb5f6ec5 100644 --- a/scripts/waifulib/compiler_optimizations.py +++ b/scripts/waifulib/compiler_optimizations.py @@ -47,13 +47,13 @@ LINKFLAGS = { CFLAGS = { 'common': { # disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP - 'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'], + 'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-'], 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'], 'gcc': ['-g', '-fvisibility=hidden'], 'owcc': ['-fno-short-enum', '-ffloat-store', '-g3'] }, 'fast': { - 'msvc': ['/O2', '/Oy'], + 'msvc': ['/O2', '/Oy', '/MT'], 'gcc': { '3': ['-O3', '-fomit-frame-pointer'], 'default': ['-Ofast', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'] @@ -62,23 +62,23 @@ CFLAGS = { 'default': ['-O3'] }, 'fastnative': { - 'msvc': ['/O2', '/Oy'], + 'msvc': ['/O2', '/Oy', '/MT'], 'gcc': ['-Ofast', '-march=native', '-funsafe-math-optimizations', '-funsafe-loop-optimizations', '-fomit-frame-pointer'], 'clang': ['-Ofast', '-march=native'], 'default': ['-O3'] }, 'release': { - 'msvc': ['/O2'], + 'msvc': ['/O2', '/MT'], 'owcc': ['-O3', '-foptimize-sibling-calls', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-fschedule-insns', '-funsafe-math-optimizations', '-funroll-loops', '-frerun-optimizer', '-finline-functions', '-finline-limit=512', '-fguess-branch-probability', '-fno-strict-aliasing', '-floop-optimize'], 'default': ['-O3'] }, 'debug': { - 'msvc': ['/Od'], + 'msvc': ['/Od', '/MTd'], 'owcc': ['-O0', '-fno-omit-frame-pointer', '-funwind-tables', '-fno-omit-leaf-frame-pointer'], 'default': ['-O0'] }, 'sanitize': { - 'msvc': ['/Od', '/RTC1'], + 'msvc': ['/Od', '/RTC1', '/MT'], 'gcc': ['-Og', '-fsanitize=undefined', '-fsanitize=address'], 'clang': ['-O0', '-fsanitize=undefined', '-fsanitize=address'], 'default': ['-O0'] diff --git a/serverbrowser/wscript b/serverbrowser/wscript index 1dc3cb8f87..646b059cdd 100755 --- a/serverbrowser/wscript +++ b/serverbrowser/wscript @@ -43,6 +43,11 @@ def build(bld): '../common/ServerBrowser/blacklisted_server_manager.cpp' ] + if bld.env.DEST_OS == 'win32': + source += [ + '../public/tier0/memoverride.cpp' + ] + includes = [ '.', '../public', diff --git a/soundemittersystem/wscript b/soundemittersystem/wscript index 3da4b83ad5..b1a2ec077d 100755 --- a/soundemittersystem/wscript +++ b/soundemittersystem/wscript @@ -24,6 +24,9 @@ def build(bld): '../public/SoundParametersInternal.cpp' ] + if bld.env.DEST_OS == 'win32': + source += ['../public/tier0/memoverride.cpp'] + includes = [ '.', '../public', diff --git a/tier0/assert_dialog.rc b/tier0/assert_dialog.rc index 19b79829e4..fed1133b43 100644 --- a/tier0/assert_dialog.rc +++ b/tier0/assert_dialog.rc @@ -121,4 +121,6 @@ END // ETW event manifest data from ValveETWProviders.man // +#if 0 #include "ValveETWProviderEvents.rc" +#endif \ No newline at end of file diff --git a/tier0/wscript b/tier0/wscript index 0e9faed4d6..d97b94b837 100755 --- a/tier0/wscript +++ b/tier0/wscript @@ -18,15 +18,12 @@ def configure(conf): def build(bld): source = [ 'assert_dialog.cpp', - #'assert_dialog.rc', [$WINDOWS] 'commandline.cpp', 'cpu.cpp', 'cpumonitoring.cpp', - 'cpu_posix.cpp', #[$POSIX] 'cpu_usage.cpp', 'dbg.cpp', 'dynfunction.cpp', - #'etwprof.cpp', [$WINDOWS] 'fasttimer.cpp', # 'InterlockedCompareExchange128.masm', [$WIN64] 'mem.cpp', @@ -36,11 +33,7 @@ def build(bld): 'memvalidate.cpp', 'minidump.cpp', 'pch_tier0.cpp', - #'platform.cpp', [$WINDOWS||$X360] - 'platform_posix.cpp', # [$POSIX] #'pmc360.cpp', [$X360] - #'pme.cpp', [$WINDOWS] - 'pme_posix.cpp', # [$POSIX] 'PMELib.cpp', #[$WINDOWS||$POSIX] 'progressbar.cpp', 'security.cpp', @@ -50,12 +43,26 @@ def build(bld): 'threadtools.cpp', 'tier0_strtools.cpp', 'tslist.cpp', - #'vcrmode.cpp', #[$WINDOWS] - 'vcrmode_posix.cpp', #[$POSIX] 'vprof.cpp', - # 'win32consoleio.cpp', [$WINDOWS] #'../tier1/pathmatch.cpp' # [$LINUXALL] ] + + if bld.env.DEST_OS == 'win32': + source += [ + 'assert_dialog.rc', + #'etwprof.cpp', [$WINDOWS] + 'platform.cpp', + 'pme.cpp', + 'vcrmode.cpp', + 'win32consoleio.cpp' + ] + else: + source += [ + 'cpu_posix.cpp', + 'platform_posix.cpp', + 'pme_posix.cpp', + 'vcrmode_posix.cpp' + ] includes = [ '.', @@ -65,7 +72,10 @@ def build(bld): defines = [] - libs = ['DL', 'M', 'LOG'] + if bld.env.DEST_OS == 'win32': + libs = ['ADVAPI32', 'WS2_32'] + else: + libs = ['DL', 'M', 'LOG'] install_path = bld.env.LIBDIR diff --git a/tier1/wscript b/tier1/wscript index 80a32f69ef..6009e7f0c2 100755 --- a/tier1/wscript +++ b/tier1/wscript @@ -40,10 +40,6 @@ def build(bld): 'memstack.cpp', 'NetAdr.cpp', 'newbitbuf.cpp', -# 'pathmatch.cpp', # [$LINUXALL] - # 'processor_detect.cpp', # [$WINDOWS||$X360] - 'processor_detect_linux.cpp', # [$POSIX] - 'qsort_s.cpp', # [$LINUXALL||$PS3] 'rangecheckedvar.cpp', 'reliabletimer.cpp', 'snappy-sinksource.cpp', @@ -64,6 +60,17 @@ def build(bld): 'utlsymbol.cpp' ] + if bld.env.DEST_OS == 'win32': + source += [ + 'processor_detect.cpp', + ] + else: + source += [ + #'pathmatch.cpp', + 'processor_detect_linux.cpp', + 'qsort_s.cpp', + ] + includes = [ '.', '../public', @@ -75,7 +82,9 @@ def build(bld): defines = [] libs = [] - + if bld.env.DEST_OS == 'win32': + libs += ['RPCRT4'] + bld.stlib( source = source, target = PROJECT_NAME, diff --git a/utils/bzip2/wscript b/utils/bzip2/wscript index 92b9c0a8ce..70f1190942 100755 --- a/utils/bzip2/wscript +++ b/utils/bzip2/wscript @@ -12,8 +12,8 @@ def options(opt): return def configure(conf): - conf.env.append_unique('CFLAGS',['-std=gnu11']) - + if conf.env.DEST_OS != 'win32': + conf.env.append_unique('CFLAGS',['-std=gnu11']) def build(bld): source = [ @@ -39,8 +39,6 @@ def build(bld): libs = [] - install_path = bld.env.PREFIX - bld.stlib( source = source, target = PROJECT_NAME, @@ -49,7 +47,6 @@ def build(bld): includes = includes, defines = defines, use = libs, - install_path = install_path, subsystem = bld.env.MSVC_SUBSYSTEM, idx = bld.get_taskgen_count() ) diff --git a/vgui2/src/wscript b/vgui2/src/wscript index f4e5547cd8..ad76f5a290 100644 --- a/vgui2/src/wscript +++ b/vgui2/src/wscript @@ -28,9 +28,6 @@ def build(bld): 'MemoryBitmap.cpp', 'MessageListener.cpp', 'Scheme.cpp', - #'Surface.cpp', [$WIN32] - #'System.cpp', [$WINDOWS||$X360] - 'system_posix.cpp',# [$POSIX] '../../public/UnicodeFileHelpers.cpp', 'vgui.cpp', 'vgui_internal.cpp', @@ -40,6 +37,17 @@ def build(bld): 'keyrepeat.cpp' ] + if bld.env.DEST_OS == 'win32': + source += [ + 'Surface.cpp', + 'System.cpp', + '../../public/tier0/memoverride.cpp' + ] + else: + source += [ + 'system_posix.cpp' + ] + includes = [ '.', '../../public', @@ -52,6 +60,9 @@ def build(bld): libs = ['tier0','tier1','tier2','tier3','vstdlib','SDL2'] + if bld.env.DEST_OS == 'win32': + libs += ['USER32', 'IMM32', 'GDI32', 'SHELL32', 'OLE32', 'SHLWAPI', 'vgui_surfacelib', 'WINMM'] + install_path = bld.env.LIBDIR bld.shlib( diff --git a/vgui2/vgui_controls/wscript b/vgui2/vgui_controls/wscript index 4962d3648b..68644dc067 100644 --- a/vgui2/vgui_controls/wscript +++ b/vgui2/vgui_controls/wscript @@ -106,6 +106,9 @@ def build(bld): libs = [] + if bld.env.DEST_OS == 'win32': + libs += ['SHELL32'] + bld.stlib( source = source, target = PROJECT_NAME, diff --git a/vgui2/vgui_surfacelib/wscript b/vgui2/vgui_surfacelib/wscript index 0de65a46ba..d93032bf9c 100644 --- a/vgui2/vgui_surfacelib/wscript +++ b/vgui2/vgui_surfacelib/wscript @@ -20,11 +20,18 @@ def build(bld): 'FontAmalgam.cpp', 'FontManager.cpp', 'FontEffects.cpp', - #'Win32Font.cpp', [$WIN32 && !$X360] #'Win32Font_x360.cpp', [$X360] #'osxfont.cpp', [$OSXALL] - 'linuxfont.cpp' # [$LINUXALL] ] + + if bld.env.DEST_OS == 'win32': + source += [ + 'Win32Font.cpp' + ] + else: + source += [ + 'linuxfont.cpp' + ] includes = [ '.', diff --git a/vguimatsurface/wscript b/vguimatsurface/wscript index 7359a3ab37..db0f3d05d7 100644 --- a/vguimatsurface/wscript +++ b/vguimatsurface/wscript @@ -27,12 +27,17 @@ def build(bld): 'Input.cpp', 'MatSystemSurface.cpp', 'asanstubs.cpp', - #'memorybitmap.cpp', [$WIN32] 'TextureDictionary.cpp', '../vgui2/src/vgui_key_translation.cpp', '../public/vgui_controls/vgui_controls.cpp' ] + if bld.env.DEST_OS == 'win32': + source += [ + '../public/tier0/memoverride.cpp', + 'memorybitmap.cpp' + ] + includes = [ '.', '../public', @@ -47,6 +52,8 @@ def build(bld): if bld.env.DEST_OS == 'android': libs += ['EXPAT'] + elif bld.env.DEST_OS == 'win32': + libs += ['USER32', 'GDI32'] install_path = bld.env.LIBDIR diff --git a/video/wscript b/video/wscript index 30d7a5605c..b30df1ad90 100755 --- a/video/wscript +++ b/video/wscript @@ -31,6 +31,9 @@ def build(bld): libs = ['tier0','tier1','tier2','tier3','vstdlib'] + if bld.env.DEST_OS == 'win32': + libs += ['USER32'] + install_path = bld.env.LIBDIR bld.shlib( diff --git a/vstdlib/wscript b/vstdlib/wscript index 3e2547affd..0ed048e89e 100755 --- a/vstdlib/wscript +++ b/vstdlib/wscript @@ -22,11 +22,15 @@ def build(bld): 'jobthread.cpp', 'KeyValuesSystem.cpp', 'osversion.cpp', - #'processutils.cpp' # [$WINDOWS] 'random.cpp', 'vcover.cpp', '../public/tier0/memoverride.cpp' ] + + if bld.env.DEST_OS == 'win32': + source += [ + 'processutils.cpp' + ] includes = [ '.', diff --git a/vtf/wscript b/vtf/wscript index 3698d0c475..ed49385b67 100755 --- a/vtf/wscript +++ b/vtf/wscript @@ -17,11 +17,15 @@ def configure(conf): def build(bld): source = [ 'convert_x360.cpp', - #$File "s3tc_decode.cpp" # [$WINDOWS] 'vtf.cpp' #$File "vtf_x360.cpp"# [$X360] ] + if bld.env.DEST_OS == 'win32': + source += [ + 's3tc_decode.cpp' + ] + includes = [ '.', '../public', diff --git a/wscript b/wscript index 05681f75f4..c0daf0e0a1 100644 --- a/wscript +++ b/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: