forked from platformio/platformio-core
Allow passing custom project configuration options to `platformio ci
and
platformio init
commands using
-O, --project-option
`.
This commit is contained in:
@ -70,6 +70,8 @@ PlatformIO 3.0
|
|||||||
* Renamed ``platformio serialports`` command to ``platformio device``
|
* Renamed ``platformio serialports`` command to ``platformio device``
|
||||||
* Build System: Attach custom Before/Pre and After/Post actions for targets
|
* Build System: Attach custom Before/Pre and After/Post actions for targets
|
||||||
(`issue #542 <https://github.com/platformio/platformio/issues/542>`_)
|
(`issue #542 <https://github.com/platformio/platformio/issues/542>`_)
|
||||||
|
* Allowed passing custom project configuration options to ``platformio ci``
|
||||||
|
and ``platformio init`` commands using ``-O, --project-option``.
|
||||||
* Print human-readable information when processing environments without
|
* Print human-readable information when processing environments without
|
||||||
``-v, --verbose`` option
|
``-v, --verbose`` option
|
||||||
(`issue #721 <https://github.com/platformio/platformio/issues/721>`_)
|
(`issue #721 <https://github.com/platformio/platformio/issues/721>`_)
|
||||||
|
@ -49,20 +49,11 @@ Systems please follow to :ref:`ci` page.
|
|||||||
.. note::
|
.. note::
|
||||||
:ref:`cmd_ci` command is useful for library developers. It allows to build
|
:ref:`cmd_ci` command is useful for library developers. It allows to build
|
||||||
different examples without creating own project per them. Also, is possible
|
different examples without creating own project per them. Also, is possible
|
||||||
to upload firmware to the target device. In this case, need to create
|
to upload firmware to the target device. In this case, you need to pass
|
||||||
:ref:`projectconf` where specify "upload" :ref:`projectconf_targets`. Custom
|
additional option ``--project-option="targets=upload"``. What is more,
|
||||||
upload port can be overridden with :ref:`projectconf_upload_port` option.
|
you can specify custom upload port using
|
||||||
Then need to specify the path to this :ref:`projectconf` to
|
``--project-option="upload_port=<port>"`` option.
|
||||||
:option:`platformio ci --project-conf`. For example,
|
See :option:`platformio ci --project-option` for details.
|
||||||
|
|
||||||
.. code-block:: ini
|
|
||||||
|
|
||||||
[env:uno]
|
|
||||||
platform = atmelavr
|
|
||||||
framework = arduino
|
|
||||||
targets = upload
|
|
||||||
; custom upload port
|
|
||||||
; upload_port = ...
|
|
||||||
|
|
||||||
Options
|
Options
|
||||||
-------
|
-------
|
||||||
@ -120,10 +111,19 @@ temporary directory within your operation system.
|
|||||||
Don't remove :option:`platformio ci --build-dir` after build process.
|
Don't remove :option:`platformio ci --build-dir` after build process.
|
||||||
|
|
||||||
.. option::
|
.. option::
|
||||||
--project-conf
|
-P, --project-conf
|
||||||
|
|
||||||
Buid project using pre-configured :ref:`projectconf`.
|
Buid project using pre-configured :ref:`projectconf`.
|
||||||
|
|
||||||
|
.. option::
|
||||||
|
-O, --project-option
|
||||||
|
|
||||||
|
Pass additional options from :ref:`projectconf` to
|
||||||
|
:option:`platformio init --project-option` command. For example,
|
||||||
|
automatically install dependent libraries
|
||||||
|
``platformio ci --project-option="lib_deps=ArduinoJSON"`` or ignore specific
|
||||||
|
library ``platformio ci --project-option="lib_ignore=SomeLib"``.
|
||||||
|
|
||||||
.. option::
|
.. option::
|
||||||
-v, --verbose
|
-v, --verbose
|
||||||
|
|
||||||
|
@ -65,18 +65,17 @@ The full list with pre-configured boards is available here :ref:`platforms`.
|
|||||||
.. option::
|
.. option::
|
||||||
--ide
|
--ide
|
||||||
|
|
||||||
Initialise PlatformIO project for the specified IDE which can be imported later
|
Initialize PlatformIO project for the specified IDE which can be imported later
|
||||||
via "Import Project" functionality.
|
via "Import Project" functionality.
|
||||||
|
|
||||||
A list with supported IDE is available within ``platformio init --help`` command.
|
A list with supported IDE is available within ``platformio init --help`` command.
|
||||||
Also, please take a look at :ref:`ide` page.
|
Also, please take a look at :ref:`ide` page.
|
||||||
|
|
||||||
.. option::
|
.. option::
|
||||||
--enable-auto-uploading
|
-O, --project-option
|
||||||
|
|
||||||
If you initialise project with the specified
|
Initialize project with additional options from :ref:`projectconf`. For example,
|
||||||
:option:`platformio init --board`, then *PlatformIO*
|
``platformio init --project-option="lib_deps=ArduinoJSON"``.
|
||||||
will create environment with enabled firmware auto-uploading.
|
|
||||||
|
|
||||||
.. option::
|
.. option::
|
||||||
--env-prefix
|
--env-prefix
|
||||||
@ -104,7 +103,6 @@ Examples
|
|||||||
platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-|
|
platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-|
|
||||||
src - Put your source files here
|
src - Put your source files here
|
||||||
lib - Put here project specific (private) libraries
|
lib - Put here project specific (private) libraries
|
||||||
Do you want to continue? [y/N]: y
|
|
||||||
Project has been successfully initialized!
|
Project has been successfully initialized!
|
||||||
Useful commands:
|
Useful commands:
|
||||||
`platformio run` - process/build project from the current directory
|
`platformio run` - process/build project from the current directory
|
||||||
@ -122,14 +120,13 @@ Examples
|
|||||||
platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-|
|
platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-|
|
||||||
src - Put your source files here
|
src - Put your source files here
|
||||||
lib - Put here project specific (private) libraries
|
lib - Put here project specific (private) libraries
|
||||||
Do you want to continue? [y/N]: y
|
|
||||||
Project has been successfully initialized!
|
Project has been successfully initialized!
|
||||||
Useful commands:
|
Useful commands:
|
||||||
`platformio run` - process/build project from the current directory
|
`platformio run` - process/build project from the current directory
|
||||||
`platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board
|
`platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board
|
||||||
`platformio run --target clean` - clean project (remove compiled files)
|
`platformio run --target clean` - clean project (remove compiled files)
|
||||||
|
|
||||||
3. Initialise project for Arduino Uno
|
3. Initialize project for Arduino Uno
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
@ -143,7 +140,6 @@ Examples
|
|||||||
platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-|
|
platformio.ini - Project Configuration File. |-> PLEASE EDIT ME <-|
|
||||||
src - Put your source files here
|
src - Put your source files here
|
||||||
lib - Put here project specific (private) libraries
|
lib - Put here project specific (private) libraries
|
||||||
Do you want to continue? [y/N]: y
|
|
||||||
Project has been successfully initialized!
|
Project has been successfully initialized!
|
||||||
Useful commands:
|
Useful commands:
|
||||||
`platformio run` - process/build project from the current directory
|
`platformio run` - process/build project from the current directory
|
||||||
|
@ -68,6 +68,7 @@ def validate_path(ctx, param, value): # pylint: disable=unused-argument
|
|||||||
resolve_path=True))
|
resolve_path=True))
|
||||||
@click.option("--keep-build-dir", is_flag=True)
|
@click.option("--keep-build-dir", is_flag=True)
|
||||||
@click.option(
|
@click.option(
|
||||||
|
"-C",
|
||||||
"--project-conf",
|
"--project-conf",
|
||||||
type=click.Path(
|
type=click.Path(
|
||||||
exists=True,
|
exists=True,
|
||||||
@ -75,6 +76,7 @@ def validate_path(ctx, param, value): # pylint: disable=unused-argument
|
|||||||
dir_okay=False,
|
dir_okay=False,
|
||||||
readable=True,
|
readable=True,
|
||||||
resolve_path=True))
|
resolve_path=True))
|
||||||
|
@click.option("-O", "--project-option", multiple=True)
|
||||||
@click.option("-v", "--verbose", is_flag=True)
|
@click.option("-v", "--verbose", is_flag=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, # pylint: disable=R0913
|
def cli(ctx, # pylint: disable=R0913
|
||||||
@ -85,6 +87,7 @@ def cli(ctx, # pylint: disable=R0913
|
|||||||
build_dir,
|
build_dir,
|
||||||
keep_build_dir,
|
keep_build_dir,
|
||||||
project_conf,
|
project_conf,
|
||||||
|
project_option,
|
||||||
verbose):
|
verbose):
|
||||||
|
|
||||||
if not src and getenv("PLATFORMIO_CI_SRC"):
|
if not src and getenv("PLATFORMIO_CI_SRC"):
|
||||||
@ -113,7 +116,11 @@ def cli(ctx, # pylint: disable=R0913
|
|||||||
_exclude_contents(build_dir, exclude)
|
_exclude_contents(build_dir, exclude)
|
||||||
|
|
||||||
# initialise project
|
# initialise project
|
||||||
ctx.invoke(cmd_init, project_dir=build_dir, board=board)
|
ctx.invoke(
|
||||||
|
cmd_init,
|
||||||
|
project_dir=build_dir,
|
||||||
|
board=board,
|
||||||
|
project_option=project_option)
|
||||||
|
|
||||||
# process project
|
# process project
|
||||||
ctx.invoke(cmd_run, project_dir=build_dir, verbose=verbose)
|
ctx.invoke(cmd_run, project_dir=build_dir, verbose=verbose)
|
||||||
|
@ -58,14 +58,14 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613
|
|||||||
"-b", "--board", multiple=True, metavar="ID", callback=validate_boards)
|
"-b", "--board", multiple=True, metavar="ID", callback=validate_boards)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--ide", type=click.Choice(ProjectGenerator.get_supported_ides()))
|
"--ide", type=click.Choice(ProjectGenerator.get_supported_ides()))
|
||||||
@click.option("--enable-auto-uploading", is_flag=True)
|
@click.option("-O", "--project-option", multiple=True)
|
||||||
@click.option("--env-prefix", default="")
|
@click.option("--env-prefix", default="")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx, # pylint: disable=R0913
|
def cli(ctx, # pylint: disable=R0913
|
||||||
project_dir,
|
project_dir,
|
||||||
board,
|
board,
|
||||||
ide,
|
ide,
|
||||||
enable_auto_uploading,
|
project_option,
|
||||||
env_prefix):
|
env_prefix):
|
||||||
|
|
||||||
if project_dir == getcwd():
|
if project_dir == getcwd():
|
||||||
@ -92,8 +92,8 @@ def cli(ctx, # pylint: disable=R0913
|
|||||||
init_base_project(project_dir)
|
init_base_project(project_dir)
|
||||||
|
|
||||||
if board:
|
if board:
|
||||||
fill_project_envs(ctx, project_dir, board, enable_auto_uploading,
|
fill_project_envs(ctx, project_dir, board, project_option, env_prefix,
|
||||||
env_prefix, ide is not None)
|
ide is not None)
|
||||||
|
|
||||||
if ide:
|
if ide:
|
||||||
if not board:
|
if not board:
|
||||||
@ -288,7 +288,7 @@ def init_cvs_ignore(project_dir):
|
|||||||
|
|
||||||
|
|
||||||
def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
|
def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
|
||||||
ctx, project_dir, board_ids, enable_auto_uploading, env_prefix,
|
ctx, project_dir, board_ids, project_option, env_prefix,
|
||||||
force_download):
|
force_download):
|
||||||
installed_boards = PlatformManager().get_installed_boards()
|
installed_boards = PlatformManager().get_installed_boards()
|
||||||
content = []
|
content = []
|
||||||
@ -327,8 +327,8 @@ def fill_project_envs( # pylint: disable=too-many-arguments,too-many-locals
|
|||||||
content.append("framework = %s" % frameworks[0])
|
content.append("framework = %s" % frameworks[0])
|
||||||
|
|
||||||
content.append("board = %s" % id_)
|
content.append("board = %s" % id_)
|
||||||
if enable_auto_uploading:
|
if project_option:
|
||||||
content.append("targets = upload")
|
content.extend(project_option)
|
||||||
|
|
||||||
if force_download and used_platforms:
|
if force_download and used_platforms:
|
||||||
_install_dependent_platforms(ctx, used_platforms)
|
_install_dependent_platforms(ctx, used_platforms)
|
||||||
|
Reference in New Issue
Block a user