From 31bfefb974cd91f1ddae505773e38d3afaa87cfd Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 30 Sep 2019 16:26:07 +1000 Subject: [PATCH] header_clean: build both release and debug when cleaning headers --- utils_maintenance/header_clean.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/utils_maintenance/header_clean.py b/utils_maintenance/header_clean.py index 0ae397e..c3fdb6f 100755 --- a/utils_maintenance/header_clean.py +++ b/utils_maintenance/header_clean.py @@ -261,6 +261,17 @@ def wash_source_include(arg_group): re_c = re.compile(r"\s*#\s*include\s+\"([a-zA-Z0-9_\-\.]+)\"") + + # Make multiple configurations (debug/non-debug). + build_args_all = [build_args] + build_args_other = re.sub("($|\\s)(-DNDEBUG)\\b", "\\1-DDEBUG", build_args) + if build_args_other != build_args: + build_args_all.append(build_args_other) + build_args_other = re.sub("($|\\s)(-DDEBUG)\\b", "\\1-DNDEBUG", build_args) + if build_args_other != build_args: + build_args_all.append(build_args_other) + del build_args, build_args_other + i = 0 while i < len(lines): l = lines[i] @@ -296,7 +307,11 @@ def wash_source_include(arg_group): write_lines(lines) # ensure this fails!, else we may be in an `#if 0` block - ret = os.system(build_args) + for build_args in build_args_all: + ret = os.system(build_args) + if ret != 0: + break + if ret != 0: lines[i] = l_new @@ -314,7 +329,11 @@ def wash_source_include(arg_group): del l_bad_guard - ret = os.system(build_args + " -Wno-unused-macros -Werror=missing-prototypes") + for build_args in build_args_all: + ret = os.system(build_args + " -Wno-unused-macros -Werror=missing-prototypes") + if ret != 0: + break + if ret != 0: lines[i] = l_prev write_lines(lines) -- GitLab