diff --git a/HISTORY.rst b/HISTORY.rst index 9bb538f4..a040ff52 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,23 +16,27 @@ PlatformIO 2.0 * Added support for `Microchip PIC32 `__ development platform (`issue #438 `_) -* Updated Arduino core for Espressif platform to 2.2.0 - (`issue #627 `_) * New boards for `ARM mbed `__ framework: ST Nucleo F410RB, ST Nucleo L073RZ and BBC micro:bit * Added support for Generic ATTiny boards: ATTiny24, ATTiny25, ATTiny45 and ATTiny85 * Added support for `TI MSP430 `__ boards: TI LaunchPad w/ msp430fr4133 and TI LaunchPad w/ msp430fr6989 +* Updated Arduino core for Espressif platform to 2.2.0 + (`issue #627 `_) +* Updated native SDK for ESP8266 to 1.5 + (`issue #366 `_) * PlatformIO Library Registry in JSON format! Implemented ``--json-output`` and ``--page`` options for `platformio lib search `__ command (`issue #604 `_) +* Allowed to unflag(remove) base/initial flags using + `build_unflags `__ + option + (`issue #559 `_) * Allowed multiple VID/PID pairs when detecting serial ports (`issue #632 `_) -* Updated native SDK for ESP8266 to 1.5 - (`issue #366 `_) * Automatically add ``-DUSB_MANUFACTURER`` with vendor's name (`issue #631 `_) * Automatically reboot Teensy board after upload when Teensy Loader GUI is used diff --git a/docs/projectconf.rst b/docs/projectconf.rst index ced07a46..91f2ba23 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -341,6 +341,17 @@ but will be applied only for the project source code from This option can be set by global environment variable :envvar:`PLATFORMIO_SRC_BUILD_FLAGS`. +``build_unflags`` +^^^^^^^^^^^^^^^^^ + +Remove base/initial flags which were set by development platform. + +.. code-block:: ini + + [env:unflags] + build_unflags = -Os -std=gnu++11 + build_flags = -O2 + .. _projectconf_src_filter: ``src_filter`` diff --git a/platformio/builder/main.py b/platformio/builder/main.py index ccb4a2d5..69f9e53c 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -42,6 +42,7 @@ commonvars.AddVariables( ("FRAMEWORK",), ("BUILD_FLAGS",), ("SRC_BUILD_FLAGS",), + ("BUILD_UNFLAGS",), ("SRC_FILTER",), ("LIB_DFCYCLIC",), ("LIB_IGNORE",), diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 3e51f95b..f897d24a 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -42,10 +42,14 @@ def BuildProgram(env): ASCOM="$ASPPCOM" ) + # process extra flags from board env.ProcessFlags([ - env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags"), - env.get("BUILD_FLAGS") + env.get("BOARD_OPTIONS", {}).get("build", {}).get("extra_flags") ]) + # remove base flags + env.ProcessUnFlags(env.get("BUILD_UNFLAGS")) + # apply user flags + env.ProcessFlags([env.get("BUILD_FLAGS")]) if env.get("FRAMEWORK"): env.BuildFrameworks([ @@ -128,6 +132,15 @@ def ProcessFlags(env, flags): env.Append(_CPPDEFFLAGS=" %s" % " ".join(undefines)) +def ProcessUnFlags(env, flags): + if not flags: + return + for var, values in env.ParseFlags(flags).items(): + for v in values: + if v in env[var]: + env[var].remove(v) + + def IsFileWithExt(env, file_, ext): # pylint: disable=W0613 if basename(file_).startswith("."): return False @@ -371,6 +384,7 @@ def exists(_): def generate(env): env.AddMethod(BuildProgram) env.AddMethod(ProcessFlags) + env.AddMethod(ProcessUnFlags) env.AddMethod(IsFileWithExt) env.AddMethod(VariantDirWrap) env.AddMethod(LookupSources)