diff --git a/SConstruct b/SConstruct index 309a642a3..93352341a 100644 --- a/SConstruct +++ b/SConstruct @@ -94,6 +94,7 @@ env_base.__class__.add_library = methods.add_library env_base.__class__.add_program = methods.add_program env_base.__class__.CommandNoCache = methods.CommandNoCache env_base.__class__.disable_warnings = methods.disable_warnings +env_base.__class__.force_optimization_on_debug = methods.force_optimization_on_debug env_base.__class__.module_add_dependencies = methods.module_add_dependencies env_base.__class__.module_check_dependencies = methods.module_check_dependencies diff --git a/methods.py b/methods.py index 19764dd6b..e809aa923 100644 --- a/methods.py +++ b/methods.py @@ -46,18 +46,27 @@ def disable_warnings(self): if self.msvc: # We have to remove existing warning level defines before appending /w, # otherwise we get: "warning D9025 : overriding '/W3' with '/w'" - warn_flags = ["/Wall", "/W4", "/W3", "/W2", "/W1", "/WX"] - self.Append(CCFLAGS=["/w"]) - self.Append(CFLAGS=["/w"]) - self.Append(CXXFLAGS=["/w"]) - self["CCFLAGS"] = [x for x in self["CCFLAGS"] if not x in warn_flags] - self["CFLAGS"] = [x for x in self["CFLAGS"] if not x in warn_flags] - self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if not x in warn_flags] + self["CCFLAGS"] = [x for x in self["CCFLAGS"] if not (x.startswith("/W") or x.startswith("/w"))] + self["CFLAGS"] = [x for x in self["CFLAGS"] if not (x.startswith("/W") or x.startswith("/w"))] + self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if not (x.startswith("/W") or x.startswith("/w"))] + self.AppendUnique(CCFLAGS=["/w"]) else: - self.Append(CCFLAGS=["-w"]) - self.Append(CFLAGS=["-w"]) - self.Append(CXXFLAGS=["-w"]) + self.AppendUnique(CCFLAGS=["-w"]) +def force_optimization_on_debug(self): + # 'self' is the environment + if self["target"] != "debug": + return + + if self.msvc: + # We have to remove existing optimization level defines before appending /O2, + # otherwise we get: "warning D9025 : overriding '/0d' with '/02'" + self["CCFLAGS"] = [x for x in self["CCFLAGS"] if not x.startswith("/O")] + self["CFLAGS"] = [x for x in self["CFLAGS"] if not x.startswith("/O")] + self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if not x.startswith("/O")] + self.AppendUnique(CCFLAGS=["/O2"]) + else: + self.AppendUnique(CCFLAGS=["-O3"]) def add_module_version_string(self, s): self.module_version_string += "." + s