summaryrefslogtreecommitdiff
path: root/platform/windows/detect.py
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows/detect.py')
-rw-r--r--platform/windows/detect.py57
1 files changed, 39 insertions, 18 deletions
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 2ce55d98be..dcd3597e88 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -62,8 +62,8 @@ def get_opts():
# XP support dropped after EOL due to missing API for IPv6 and other issues
# Vista support dropped after EOL due to GH-10243
('target_win_version', 'Targeted Windows version, >= 0x0601 (Windows 7)', '0x0601'),
- EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')),
- BoolVariable('separate_debug_symbols', 'Create a separate file with the debug symbols', False),
+ EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')),
+ BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False),
('msvc_version', 'MSVC version to use. Ignored if VCINSTALLDIR is set in shell env.', None),
BoolVariable('use_mingw', 'Use the Mingw compiler, even if MSVC is installed. Only used on Windows.', False),
]
@@ -166,20 +166,22 @@ def configure_msvc(env, manual_msvc_config):
# Build type
if (env["target"] == "release"):
- env.Append(CCFLAGS=['/O2'])
+ if (env["optimize"] == "speed"): #optimize for speed (default)
+ env.Append(CCFLAGS=['/O2'])
+ else: # optimize for size
+ env.Append(CCFLAGS=['/O1'])
env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
+ env.Append(LINKFLAGS=['/OPT:REF'])
elif (env["target"] == "release_debug"):
- env.Append(CCFLAGS=['/O2'])
+ if (env["optimize"] == "speed"): #optimize for speed (default)
+ env.Append(CCFLAGS=['/O2'])
+ else: # optimize for size
+ env.Append(CCFLAGS=['/O1'])
env.AppendUnique(CPPDEFINES = ['DEBUG_ENABLED'])
env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
-
- elif (env["target"] == "debug_release"):
- env.Append(CCFLAGS=['/Z7', '/Od'])
- env.Append(LINKFLAGS=['/DEBUG'])
- env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
- env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup'])
+ env.Append(LINKFLAGS=['/OPT:REF'])
elif (env["target"] == "debug"):
env.AppendUnique(CCFLAGS=['/Z7', '/Od', '/EHsc'])
@@ -188,16 +190,24 @@ def configure_msvc(env, manual_msvc_config):
env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
env.Append(LINKFLAGS=['/DEBUG'])
+ if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes"):
+ env.AppendUnique(CCFLAGS=['/Z7'])
+ env.AppendUnique(LINKFLAGS=['/DEBUG'])
+
## Compile/link flags
env.AppendUnique(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo'])
env.AppendUnique(CXXFLAGS=['/TP']) # assume all sources are C++
if manual_msvc_config: # should be automatic if SCons found it
- env.Append(CPPPATH=[os.getenv("WindowsSdkDir") + "/Include"])
+ if os.getenv("WindowsSdkDir") is not None:
+ env.Append(CPPPATH=[os.getenv("WindowsSdkDir") + "/Include"])
+ else:
+ print("Missing environment variable: WindowsSdkDir")
env.AppendUnique(CPPDEFINES = ['WINDOWS_ENABLED', 'OPENGL_ENABLED',
'RTAUDIO_ENABLED', 'WASAPI_ENABLED',
- 'TYPED_METHOD_BIND', 'WIN32', 'MSVC',
+ 'WINMIDI_ENABLED', 'TYPED_METHOD_BIND',
+ 'WIN32', 'MSVC',
{'WINVER' : '$target_win_version',
'_WIN32_WINNT': '$target_win_version'}])
if env["bits"] == "64":
@@ -211,7 +221,10 @@ def configure_msvc(env, manual_msvc_config):
env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS])
if manual_msvc_config:
- env.Append(LIBPATH=[os.getenv("WindowsSdkDir") + "/Lib"])
+ if os.getenv("WindowsSdkDir") is not None:
+ env.Append(LIBPATH=[os.getenv("WindowsSdkDir") + "/Lib"])
+ else:
+ print("Missing environment variable: WindowsSdkDir")
## LTO
@@ -241,10 +254,14 @@ def configure_mingw(env):
if (env["target"] == "release"):
env.Append(CCFLAGS=['-msse2'])
- if (env["bits"] == "64"):
- env.Append(CCFLAGS=['-O3'])
- else:
- env.Append(CCFLAGS=['-O2'])
+ if (env["optimize"] == "speed"): #optimize for speed (default)
+ if (env["bits"] == "64"):
+ env.Append(CCFLAGS=['-O3'])
+ else:
+ env.Append(CCFLAGS=['-O2'])
+ else: #optimize for size
+ env.Prepend(CCFLAGS=['-Os'])
+
env.Append(LINKFLAGS=['-Wl,--subsystem,windows'])
@@ -259,7 +276,11 @@ def configure_mingw(env):
env.Prepend(CCFLAGS=['-g1'])
if (env["debug_symbols"] == "full"):
env.Prepend(CCFLAGS=['-g2'])
-
+ if (env["optimize"] == "speed"): #optimize for speed (default)
+ env.Append(CCFLAGS=['-O2'])
+ else: #optimize for size
+ env.Prepend(CCFLAGS=['-Os'])
+
elif (env["target"] == "debug"):
env.Append(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])