diff --git a/SConstruct b/SConstruct index 93aeb334..7b021bda 100644 --- a/SConstruct +++ b/SConstruct @@ -8,7 +8,7 @@ opts = Variables(None, ARGUMENTS) opts.Add(EnumVariable('OS', "Target platform", str(Platform()), ('darwin', 'win32', 'posix'))) opts.Add('toolset', "Toolset to pass to the SCons builder", 'default') -opts.Add(BoolVariable('debug', "Build with debug symbols and no optimization", True)) +opts.Add(BoolVariable('release', "Build with optimization and no debug symbols", False)) opts.Add(EnumVariable('bits', "Build for 32-bit or 64-bit architectures", '64', ('32', '64'))) # Partial build flags -- by default, all targets will be built, @@ -36,6 +36,16 @@ opts.Add("LINKFLAGS", "Custom flags for the linker") env = Environment(variables=opts, ENV=os.environ) Help(opts.GenerateHelpText(env)) +# Source: https://github.com/godotengine/godot-cpp/blob/a42b3634d20b4e7088be721792bba1199277362c/SConstruct#L36 +if opts.UnknownVariables(): + unknown = opts.UnknownVariables() + if unknown: + print("WARNING: Unknown SCons variables were passed and will be ignored:") + for item in unknown.items(): + print(" " + item[0] + "=" + item[1]) + if item[0] == 'debug': + print(' NOTE: Debug builds are now the default. Pass `release=true` if you need a release build.') + platform = env['OS'] toolset = env['toolset'] arch = 'x86_64' if (env['bits'] == '64') else 'x86' @@ -75,7 +85,7 @@ env.VariantDir('#build/obj', 'src') env.VariantDir('#build/obj/test', 'test') env.VariantDir('#build/obj/test/deps', 'deps') -if env['debug']: +if not env['release']: if platform in ['posix', 'darwin']: env.Append(CCFLAGS=['-g','-O0']) elif platform == 'win32': diff --git a/src/game/SConscript b/src/game/SConscript index cd0998da..3b2e14e5 100644 --- a/src/game/SConscript +++ b/src/game/SConscript @@ -44,7 +44,7 @@ elif str(platform) == "posix": boe = env.Program("#build/bin/Blades of Exile", game_sources + party_classes + common_sources) debug_symbols = None -if str(platform) == "win32" and 'msvc' in env["TOOLS"] and env['debug']: +if str(platform) == "win32" and 'msvc' in env["TOOLS"] and not env['release']: debug_symbols = boe[0].abspath.replace('.exe', '.pdb') if str(platform) == "darwin": diff --git a/src/pcedit/SConscript b/src/pcedit/SConscript index 1f3b996f..38afdb9b 100644 --- a/src/pcedit/SConscript +++ b/src/pcedit/SConscript @@ -28,7 +28,7 @@ elif str(platform) == "posix": pced = env.Program("#build/bin/BoE Character Editor", pced_sources + party_classes + common_sources) debug_symbols = None -if str(platform) == "win32" and 'msvc' in env["TOOLS"] and env['debug']: +if str(platform) == "win32" and 'msvc' in env["TOOLS"] and not env['release']: debug_symbols = pced[0].abspath.replace('.exe', '.pdb') if str(platform) == "darwin": diff --git a/src/scenedit/SConscript b/src/scenedit/SConscript index f1082331..e0b7958a 100644 --- a/src/scenedit/SConscript +++ b/src/scenedit/SConscript @@ -32,7 +32,7 @@ elif str(platform) == "posix": scened = env.Program("#build/bin/BoE Scenario Editor", scened_sources + common_sources) debug_symbols = None -if str(platform) == "win32" and 'msvc' in env["TOOLS"] and env['debug']: +if str(platform) == "win32" and 'msvc' in env["TOOLS"] and not env['release']: debug_symbols = scened[0].abspath.replace('.exe', '.pdb') if str(platform) == "darwin": diff --git a/test/SConscript b/test/SConscript index 42fa5265..04767ee5 100644 --- a/test/SConscript +++ b/test/SConscript @@ -14,10 +14,10 @@ test_sources = Glob("""*.cpp""") + Split(""" debug_symbols = None if str(platform) == "win32" and 'msvc' in env["TOOLS"]: link_flags = f'/nologo /SUBSYSTEM:CONSOLE /MACHINE:X{arch_short}' - if env['debug']: + if not env['release']: link_flags += ' /DEBUG' test = env.Program("#build/bin/boe_test", party_classes + common_sources + test_sources, LINKFLAGS=link_flags) - if env['debug']: + if not env['release']: debug_symbols = test[0].abspath.replace(".exe", ".pdb") else: test = env.Program("#build/bin/boe_test", test_sources + party_classes + common_sources)