diff options
author | David Snopek <dsnopek@gmail.com> | 2023-08-09 18:53:16 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-09 18:53:16 -0500 |
commit | c47bd60c734ea49c60d6122d075721adbfb2d16e (patch) | |
tree | 5584fa78267e441601c370a12055c7d3849077c9 /tools/windows.py | |
parent | 5834e16a221fde8dc0b6ca4b7a6721cc4b258037 (diff) | |
parent | a745c2ac478157586120e37e2e4ba19a206c4dd3 (diff) | |
download | redot-cpp-c47bd60c734ea49c60d6122d075721adbfb2d16e.tar.gz |
Merge pull request #1203 from dsnopek/1082-update
Statically link mingw/msvc runtime libraries on Windows
Diffstat (limited to 'tools/windows.py')
-rw-r--r-- | tools/windows.py | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/tools/windows.py b/tools/windows.py index 979b56e..e156aef 100644 --- a/tools/windows.py +++ b/tools/windows.py @@ -9,6 +9,7 @@ from SCons.Variables import * def options(opts): opts.Add(BoolVariable("use_mingw", "Use the MinGW compiler instead of MSVC - only effective on Windows", False)) opts.Add(BoolVariable("use_clang_cl", "Use the clang driver instead of MSVC - only effective on Windows", False)) + opts.Add(BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True)) def exists(env): @@ -37,6 +38,11 @@ def generate(env): env["CC"] = "clang-cl" env["CXX"] = "clang-cl" + if env["use_static_cpp"]: + env.Append(CCFLAGS=["/MT"]) + else: + env.Append(CCFLAGS=["/MD"]) + elif sys.platform == "win32" or sys.platform == "msys": env["use_mingw"] = True mingw.generate(env) @@ -45,6 +51,18 @@ def generate(env): env["SHLIBPREFIX"] = "" # Want dll suffix env["SHLIBSUFFIX"] = ".dll" + + env.Append(CCFLAGS=["-Wwrite-strings"]) + env.Append(LINKFLAGS=["-Wl,--no-undefined"]) + if env["use_static_cpp"]: + env.Append( + LINKFLAGS=[ + "-static", + "-static-libgcc", + "-static-libstdc++", + ] + ) + # Long line hack. Use custom spawn, quick AR append (to avoid files with the same names to override each other). my_spawn.configure(env) @@ -60,15 +78,15 @@ def generate(env): # Want dll suffix env["SHLIBSUFFIX"] = ".dll" - # These options are for a release build even using target=debug - env.Append(CCFLAGS=["-O3", "-Wwrite-strings"]) - env.Append( - LINKFLAGS=[ - "--static", - "-Wl,--no-undefined", - "-static-libgcc", - "-static-libstdc++", - ] - ) + env.Append(CCFLAGS=["-Wwrite-strings"]) + env.Append(LINKFLAGS=["-Wl,--no-undefined"]) + if env["use_static_cpp"]: + env.Append( + LINKFLAGS=[ + "-static", + "-static-libgcc", + "-static-libstdc++", + ] + ) env.Append(CPPDEFINES=["WINDOWS_ENABLED"]) |