diff --git a/HISTORY.rst b/HISTORY.rst index 9adb24f5..8b0336e6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,8 @@ PlatformIO 3.0 3.5.4 (2018-??-??) ~~~~~~~~~~~~~~~~~~ +* Improved removing of default build flags using `build_unflags `__ option + (`issue #1712 `_) * Export ``LIBS``, ``LIBPATH``, and ``LINKFLAGS`` data from project dependent libraries to the global build environment * Don't export ``CPPPATH`` data of project dependent libraries to framework's diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index ac3dda2b..0d82bbed 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -190,7 +190,18 @@ def ProcessFlags(env, flags): # pylint: disable=too-many-branches def ProcessUnFlags(env, flags): if not flags: return - for key, unflags in env.ParseFlagsExtended(flags).items(): + parsed = env.ParseFlagsExtended(flags) + + # get all flags and copy them to each "*FLAGS" variable + all_flags = [] + for key, unflags in parsed.items(): + if key.endswith("FLAGS"): + all_flags.extend(unflags) + for key, unflags in parsed.items(): + if key.endswith("FLAGS"): + parsed[key].extend(all_flags) + + for key, unflags in parsed.items(): for unflag in unflags: for current in env.get(key, []): conditions = [