Allow to specify default environments "env_default" // Resolve #576

This commit is contained in:
Ivan Kravets
2016-04-27 14:10:18 +03:00
parent ad9ae4c0af
commit 4b6fc94f94
4 changed files with 54 additions and 2 deletions

View File

@ -31,6 +31,9 @@ PlatformIO 2.0
`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 specify default environments `env_default <http://docs.platformio.org/en/latest/projectconf.html#env-default>`__
which should be processed by default with ``platformio run`` command
(`issue #576 <https://github.com/platformio/platformio/issues/576>`_)
* Allowed to unflag(remove) base/initial flags using
`build_unflags <http://docs.platformio.org/en/latest/projectconf.html#build-unflags>`__
option

View File

@ -130,6 +130,45 @@ project.
This option can be overridden by global environment variable
:envvar:`PLATFORMIO_DATA_DIR`.
.. _projectconf_pio_env_default:
``env_default``
^^^^^^^^^^^^^^^
:ref:`cmd_run` command processes all environments ``[env:***]`` by default
if :option:`platformio run --environment` option is not specified.
:ref:`projectconf_pio_env_default` allows to define environments which
should be processed by default.
Multiple environments are allowed if they are separated with ``,`` (comma).
For example.
.. code-block:: ini
[platformio]
env_default = uno, nodemcu
[env:uno]
platform = atmelavr
framework = arduino
board = uno
[env:nodemcu]
platform = espressif
framework = arduino
board = nodemcu
[env:teensy31]
platform = teensy
framework = arduino
board = teensy31
[env:lpmsp430g2553]
platform = timsp430
framework = energia
board = lpmsp430g2553
build_flags = -D LED_BUILTIN=RED_LED
----------
Section ``[env:NAME]``

View File

@ -38,7 +38,10 @@ Options
.. option::
-e, --environment
Process specified environments
Process specified environments.
You can also specify which environments should be processed by default using
:ref:`projectconf_pio_env_default`.
.. option::

View File

@ -64,6 +64,12 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
fg="yellow"
)
env_default = None
if config.has_option("platformio", "env_default"):
env_default = [
e.strip()
for e in config.get("platformio", "env_default").split(",")]
results = []
for section in config.sections():
# skip main configuration section
@ -74,7 +80,8 @@ def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
raise exception.InvalidEnvName(section)
envname = section[4:]
if environment and envname not in environment:
if ((environment and envname not in environment) or
(env_default and envname not in env_default)):
# echo("Skipped %s environment" % style(envname, fg="yellow"))
continue