From 4f10047ba30b33d62e1df077e474fd03a3837a7f Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 23 May 2015 19:17:07 +0300 Subject: [PATCH] Handle new environment variable PLATFORMIO_BUILD_FLAGS --- HISTORY.rst | 2 ++ docs/envvars.rst | 22 ++++++++++++---------- docs/projectconf.rst | 5 ++++- platformio/builder/tools/platformio.py | 12 ++++++++---- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 0c0b5a3b..c1b41581 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,6 +4,8 @@ Release History 2.0.1 (2015-??-??) ------------------ +* Handle new environment variable + `PLATFORMIO_BUILD_FLAGS `_ * Pass to API requests information about Continuous Integration system. This information will be used by PlatformIO-API. * Fixed bug with converting ``*.ino`` to ``*.cpp`` diff --git a/docs/envvars.rst b/docs/envvars.rst index 765ec0a3..1b6aa2e4 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -36,44 +36,46 @@ In other words, ``CI=true`` automatically setup PLATFORMIO_HOME_DIR ~~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_pio_home_dir`. +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_home_dir`. .. _envvar_PLATFORMIO_LIB_DIR: PLATFORMIO_LIB_DIR ~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_pio_lib_dir`. +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_lib_dir`. .. _envvar_PLATFORMIO_SRC_DIR: PLATFORMIO_SRC_DIR ~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_pio_src_dir`. +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_src_dir`. .. _envvar_PLATFORMIO_ENVS_DIR: PLATFORMIO_ENVS_DIR ~~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_pio_envs_dir`. +Allows to override :ref:`projectconf` option :ref:`projectconf_pio_envs_dir`. Builder ------- +.. _envvar_PLATFORMIO_BUILD_FLAGS: + +PLATFORMIO_BUILD_FLAGS +~~~~~~~~~~~~~~~~~~~~~~ + +Allows to set :ref:`projectconf` option :ref:`projectconf_build_flags`. + .. _envvar_PLATFORMIO_SRCBUILD_FLAGS: PLATFORMIO_SRCBUILD_FLAGS ~~~~~~~~~~~~~~~~~~~~~~~~~ -Allows to override :ref:`projectconf` option -:ref:`projectconf_srcbuild_flags`. +Allows to set :ref:`projectconf` option :ref:`projectconf_srcbuild_flags`. Settings -------- diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 698a8762..23f93c8b 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -270,6 +270,9 @@ processes: - Add the directory *dir* to the list of directories to be searched for header files. +This option can be set by global environment variable +:ref:`envvar_PLATFORMIO_BUILD_FLAGS`. + Example: .. code-block:: ini @@ -306,7 +309,7 @@ An option ``srcbuild_flags`` has the same behaviour like ``build_flags`` but will be applied only for the project source code from :ref:`projectconf_pio_src_dir` directory. -This option can be overridden by global environment variable +This option can be set by global environment variable :ref:`envvar_PLATFORMIO_SRCBUILD_FLAGS`. ``install_libs`` diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index ec88fae9..252f8aa6 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -47,10 +47,11 @@ def BuildFirmware(env): _LIBFLAGS=" -Wl,--end-group" ) - _srcbuild_flags = getenv("PLATFORMIO_SRCBUILD_FLAGS", - env.subst("$SRCBUILD_FLAGS")) - if _srcbuild_flags: - firmenv.MergeFlags(_srcbuild_flags) + # Handle SRCBUILD_FLAGS + if getenv("PLATFORMIO_SRCBUILD_FLAGS", None): + firmenv.MergeFlags(getenv("PLATFORMIO_SRCBUILD_FLAGS")) + if "SRCBUILD_FLAGS" in env: + firmenv.MergeFlags(env['SRCBUILD_FLAGS']) firmenv.Append( CPPDEFINES=["PLATFORMIO={0:02d}{1:02d}{2:02d}".format( @@ -83,6 +84,9 @@ def ProcessFlags(env): if "extra_flags" in env.get("BOARD_OPTIONS", {}).get("build", {}): env.MergeFlags(env.subst("${BOARD_OPTIONS['build']['extra_flags']}")) + # Handle BUILD_FLAGS + if getenv("PLATFORMIO_BUILD_FLAGS", None): + env.MergeFlags(getenv("PLATFORMIO_BUILD_FLAGS")) if "BUILD_FLAGS" in env: env.MergeFlags(env['BUILD_FLAGS'])