Allowe to unflag(remove) base/initial flags using build_unflags // Resolve #559

This commit is contained in:
Ivan Kravets
2016-04-27 12:55:07 +03:00
parent a7c0e2e944
commit ab5d7f3313
4 changed files with 36 additions and 6 deletions

View File

@ -16,23 +16,27 @@ PlatformIO 2.0
* Added support for `Microchip PIC32 <http://docs.platformio.org/en/latest/platforms/microchippic32.html>`__
development platform
(`issue #438 <https://github.com/platformio/platformio/issues/438>`_)
* Updated Arduino core for Espressif platform to 2.2.0
(`issue #627 <https://github.com/platformio/platformio/issues/627>`_)
* New boards for `ARM mbed <http://docs.platformio.org/en/latest/frameworks/mbed.html>`__
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 <http://docs.platformio.org/en/latest/platforms/timsp430.html>`__
boards: TI LaunchPad w/ msp430fr4133 and TI LaunchPad w/ msp430fr6989
* Updated Arduino core for Espressif platform to 2.2.0
(`issue #627 <https://github.com/platformio/platformio/issues/627>`_)
* Updated native SDK for ESP8266 to 1.5
(`issue #366 <https://github.com/platformio/platformio/issues/366>`_)
* PlatformIO Library Registry in JSON format! Implemented
``--json-output`` and ``--page`` options for
`platformio lib search <http://docs.platformio.org/en/latest/userguide/lib/cmd_search.html>`__
command
(`issue #604 <https://github.com/platformio/platformio/issues/604>`_)
* Allowed to unflag(remove) base/initial flags using
`build_unflags <http://docs.platformio.org/en/latest/projectconf.html#build-unflags>`__
option
(`issue #559 <https://github.com/platformio/platformio/issues/559>`_)
* Allowed multiple VID/PID pairs when detecting serial ports
(`issue #632 <https://github.com/platformio/platformio/issues/632>`_)
* Updated native SDK for ESP8266 to 1.5
(`issue #366 <https://github.com/platformio/platformio/issues/366>`_)
* Automatically add ``-DUSB_MANUFACTURER`` with vendor's name
(`issue #631 <https://github.com/platformio/platformio/issues/631>`_)
* Automatically reboot Teensy board after upload when Teensy Loader GUI is used

View File

@ -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``

View File

@ -42,6 +42,7 @@ commonvars.AddVariables(
("FRAMEWORK",),
("BUILD_FLAGS",),
("SRC_BUILD_FLAGS",),
("BUILD_UNFLAGS",),
("SRC_FILTER",),
("LIB_DFCYCLIC",),
("LIB_IGNORE",),

View File

@ -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)