diff --git a/HISTORY.rst b/HISTORY.rst index a040ff52..912f3872 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -31,6 +31,9 @@ PlatformIO 2.0 `platformio lib search `__ command (`issue #604 `_) +* Allowed to specify default environments `env_default `__ + which should be processed by default with ``platformio run`` command + (`issue #576 `_) * Allowed to unflag(remove) base/initial flags using `build_unflags `__ option diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 91f2ba23..0af9c5f5 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -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]`` diff --git a/docs/userguide/cmd_run.rst b/docs/userguide/cmd_run.rst index dcd2cbdc..6034cb04 100644 --- a/docs/userguide/cmd_run.rst +++ b/docs/userguide/cmd_run.rst @@ -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:: diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 30a0f1c4..c0739dc5 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -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