mirror of
https://github.com/platformio/platformio-core.git
synced 2025-08-01 19:04:29 +02:00
Project dependencies per build environment using "lib_deps" option // Resolve #413
This commit is contained in:
@@ -26,10 +26,12 @@ PlatformIO 3.0
|
|||||||
|
|
||||||
* Library Manager 3.0
|
* Library Manager 3.0
|
||||||
|
|
||||||
|
+ Project dependencies per build environment using `lib_deps <http://docs.platformio.org/en/latest/projectconf.html#lib-deps>`__ option
|
||||||
|
(`issue #413 <https://github.com/platformio/platformio/issues/413>`_)
|
||||||
+ `Semantic Versioning <http://semver.org/>`__ for library commands and
|
+ `Semantic Versioning <http://semver.org/>`__ for library commands and
|
||||||
dependencies
|
dependencies
|
||||||
(`issue #410 <https://github.com/platformio/platformio/issues/410>`_)
|
(`issue #410 <https://github.com/platformio/platformio/issues/410>`_)
|
||||||
+ Multiple library storages: project's local, PlatformIO global or custom
|
+ Multiple library storages: Project's Local, PlatformIO's Global or Custom
|
||||||
(`issue #475 <https://github.com/platformio/platformio/issues/475>`_)
|
(`issue #475 <https://github.com/platformio/platformio/issues/475>`_)
|
||||||
+ Install library by name
|
+ Install library by name
|
||||||
(`issue #414 <https://github.com/platformio/platformio/issues/414>`_)
|
(`issue #414 <https://github.com/platformio/platformio/issues/414>`_)
|
||||||
|
@@ -57,6 +57,10 @@ Allows to override :ref:`projectconf` option :ref:`projectconf_pio_home_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_LIBDEPS_DIR
|
||||||
|
|
||||||
|
Allows to override :ref:`projectconf` option :ref:`projectconf_pio_libdeps_dir`.
|
||||||
|
|
||||||
.. envvar:: PLATFORMIO_SRC_DIR
|
.. envvar:: 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`.
|
||||||
|
@@ -30,6 +30,7 @@ Library Dependency Finder has controls that can be set up in :ref:`projectconf`:
|
|||||||
.. hlist::
|
.. hlist::
|
||||||
:columns: 3
|
:columns: 3
|
||||||
|
|
||||||
|
* :ref:`projectconf_lib_deps`
|
||||||
* :ref:`projectconf_lib_extra_dirs`
|
* :ref:`projectconf_lib_extra_dirs`
|
||||||
* :ref:`projectconf_lib_force`
|
* :ref:`projectconf_lib_force`
|
||||||
* :ref:`projectconf_lib_ignore`
|
* :ref:`projectconf_lib_ignore`
|
||||||
@@ -43,12 +44,13 @@ Library Dependency Finder has controls that can be set up in :ref:`projectconf`:
|
|||||||
Storage
|
Storage
|
||||||
-------
|
-------
|
||||||
|
|
||||||
There are different storages/folders where Library Dependency Finder looks for
|
There are different storages where Library Dependency Finder looks for
|
||||||
libraries. These folders/path have priority and LDF operates in the next order:
|
libraries. These storages (folders) have priority and LDF operates in the next
|
||||||
|
order:
|
||||||
|
|
||||||
1. :ref:`projectconf_lib_extra_dirs` - extra storages per build environment
|
1. :ref:`projectconf_lib_extra_dirs` - extra storages per build environment
|
||||||
2. :ref:`projectconf_pio_lib_dir` - own/private library storage per project
|
2. :ref:`projectconf_pio_lib_dir` - own/private library storage per project
|
||||||
3. :ref:`projectconf_pio_piolibdeps_dir` - project dependencies storage used by
|
3. :ref:`projectconf_pio_libdeps_dir` - project dependencies storage used by
|
||||||
:ref:`librarymanager`
|
:ref:`librarymanager`
|
||||||
4. ":ref:`projectconf_pio_home_dir`/lib" - global storage per all projects.
|
4. ":ref:`projectconf_pio_home_dir`/lib" - global storage per all projects.
|
||||||
|
|
||||||
|
@@ -102,17 +102,17 @@ Then in ``src/main.c`` you should use:
|
|||||||
PlatformIO will find your libraries automatically, configure preprocessor's
|
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||||
include paths and build them.
|
include paths and build them.
|
||||||
|
|
||||||
.. _projectconf_pio_piolibdeps_dir:
|
.. _projectconf_pio_libdeps_dir:
|
||||||
|
|
||||||
``piolibdeps_dir``
|
``libdeps_dir``
|
||||||
^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Internal storage where :ref:`librarymanager` will install project dependencies.
|
Internal storage where :ref:`librarymanager` will install project dependencies
|
||||||
A default value is ``.piolibdeps`` that means that folder is located in the root of
|
(:ref:`projectconf_lib_deps`). A default value is ``.piolibdeps`` that means
|
||||||
project.
|
that folder is located in the root of project.
|
||||||
|
|
||||||
This option can be overridden by global environment variable
|
This option can be overridden by global environment variable
|
||||||
:envvar:`PLATFORMIO_PIOLIBDEPS_DIR`.
|
:envvar:`PLATFORMIO_LIBDEPS_DIR`.
|
||||||
|
|
||||||
.. _projectconf_pio_src_dir:
|
.. _projectconf_pio_src_dir:
|
||||||
|
|
||||||
@@ -639,21 +639,40 @@ Library options
|
|||||||
.. contents::
|
.. contents::
|
||||||
:local:
|
:local:
|
||||||
|
|
||||||
``lib_install``
|
.. _projectconf_lib_deps:
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Specify dependent libraries which should be installed before environment
|
``lib_deps``
|
||||||
process. The only library IDs are allowed. Multiple libraries can be passed
|
^^^^^^^^^^^^
|
||||||
using comma ``,`` sign.
|
|
||||||
|
|
||||||
You can obtain library IDs using :ref:`cmd_lib_search` command.
|
Specify project dependencies that should be installed automatically to
|
||||||
|
:ref:`projectconf_pio_libdeps_dir` before an environment process.
|
||||||
|
Multiple dependencies are allowed (multi-lines).
|
||||||
|
|
||||||
|
**Valid forms**
|
||||||
|
|
||||||
|
.. code-block:: ini
|
||||||
|
|
||||||
|
[env:***]
|
||||||
|
lib_deps =
|
||||||
|
LIBRARY_1
|
||||||
|
LIBRARY_2
|
||||||
|
LIBRARY_N
|
||||||
|
|
||||||
|
The each line with ``LIBRARY_1... LIBRARY_N`` will be passed automatically to
|
||||||
|
:ref:`cmd_lib_install` command. Please follow to :ref:`cmd_lib_install` for
|
||||||
|
detailed documentation about possible values.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
.. code-block:: ini
|
.. code-block:: ini
|
||||||
|
|
||||||
[env:depends_on_some_libs]
|
[env:depends_on_some_libs]
|
||||||
lib_install = 1,13,19
|
lib_deps =
|
||||||
|
1
|
||||||
|
PubSubClient
|
||||||
|
Json@~5.6,!=5.4
|
||||||
|
https://github.com/gioblu/PJON.git@v2.0
|
||||||
|
https://github.com/me-no-dev/ESPAsyncTCP.git
|
||||||
|
|
||||||
.. _projectconf_lib_force:
|
.. _projectconf_lib_force:
|
||||||
|
|
||||||
@@ -663,12 +682,12 @@ Example:
|
|||||||
.. seealso::
|
.. seealso::
|
||||||
Please make sure to read :ref:`ldf` guide first.
|
Please make sure to read :ref:`ldf` guide first.
|
||||||
|
|
||||||
Force Library Dependency Finder to depend on the specified libraries if
|
Force Library Dependency Finder to depend on the specified library if it even
|
||||||
they even are not included in the project source code. Also, these
|
is not included in the project source code. Also, this library will be
|
||||||
libraries will be processed in the first order.
|
processed in the first order.
|
||||||
|
|
||||||
The correct value for this option is library name (not
|
The correct value for this option is library name (not folder name). In the
|
||||||
folder name). In the most cases, library name is pre-defined in manifest file
|
most cases, library name is pre-defined in manifest file
|
||||||
(:ref:`library_config`, ``library.properties``, ``module.json``). The multiple
|
(:ref:`library_config`, ``library.properties``, ``module.json``). The multiple
|
||||||
library names are allowed, split them with comma ``,`` separator.
|
library names are allowed, split them with comma ``,`` separator.
|
||||||
|
|
||||||
|
@@ -38,6 +38,7 @@ Usage
|
|||||||
# [LIBRARY...] forms
|
# [LIBRARY...] forms
|
||||||
platformio lib [STORAGE_OPTIONS] install (with no args, project dependencies)
|
platformio lib [STORAGE_OPTIONS] install (with no args, project dependencies)
|
||||||
platformio lib [STORAGE_OPTIONS] install <id>
|
platformio lib [STORAGE_OPTIONS] install <id>
|
||||||
|
platformio lib [STORAGE_OPTIONS] install id=<id>
|
||||||
platformio lib [STORAGE_OPTIONS] install <id>@<version>
|
platformio lib [STORAGE_OPTIONS] install <id>@<version>
|
||||||
platformio lib [STORAGE_OPTIONS] install <id>@<version range>
|
platformio lib [STORAGE_OPTIONS] install <id>@<version range>
|
||||||
platformio lib [STORAGE_OPTIONS] install <name>
|
platformio lib [STORAGE_OPTIONS] install <name>
|
||||||
@@ -47,7 +48,7 @@ Usage
|
|||||||
platformio lib [STORAGE_OPTIONS] install file://<zip or tarball file>
|
platformio lib [STORAGE_OPTIONS] install file://<zip or tarball file>
|
||||||
platformio lib [STORAGE_OPTIONS] install file://<folder>
|
platformio lib [STORAGE_OPTIONS] install file://<folder>
|
||||||
platformio lib [STORAGE_OPTIONS] install <repository>
|
platformio lib [STORAGE_OPTIONS] install <repository>
|
||||||
platformio lib [STORAGE_OPTIONS] install <name=repository> (name it should have locally)
|
platformio lib [STORAGE_OPTIONS] install <name>=<repository> (name it should have locally)
|
||||||
platformio lib [STORAGE_OPTIONS] install <repository#tag> ("tag" can be commit, branch or tag)
|
platformio lib [STORAGE_OPTIONS] install <repository#tag> ("tag" can be commit, branch or tag)
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
VERSION = (3, 0, "0.dev21")
|
VERSION = (3, 0, "0.dev22")
|
||||||
__version__ = ".".join([str(s) for s in VERSION])
|
__version__ = ".".join([str(s) for s in VERSION])
|
||||||
|
|
||||||
__title__ = "platformio"
|
__title__ = "platformio"
|
||||||
|
@@ -111,13 +111,14 @@ def cli(ctx, # pylint: disable=R0913,R0914
|
|||||||
|
|
||||||
class EnvironmentProcessor(object):
|
class EnvironmentProcessor(object):
|
||||||
|
|
||||||
KNOWN_OPTIONS = (
|
KNOWN_OPTIONS = ("platform", "framework", "board", "board_mcu",
|
||||||
"platform", "framework", "board", "board_mcu", "board_f_cpu",
|
"board_f_cpu", "board_f_flash", "board_flash_mode",
|
||||||
"board_f_flash", "board_flash_mode", "build_flags", "src_build_flags",
|
"build_flags", "src_build_flags", "build_unflags",
|
||||||
"build_unflags", "src_filter", "extra_script", "targets",
|
"src_filter", "extra_script", "targets", "upload_port",
|
||||||
"upload_port", "upload_protocol", "upload_speed", "upload_flags",
|
"upload_protocol", "upload_speed", "upload_flags",
|
||||||
"upload_resetmethod", "lib_install", "lib_force", "lib_ignore",
|
"upload_resetmethod", "lib_install", "lib_deps",
|
||||||
"lib_extra_dirs", "lib_ldf_mode", "lib_compat_mode", "piotest")
|
"lib_force", "lib_ignore", "lib_extra_dirs",
|
||||||
|
"lib_ldf_mode", "lib_compat_mode", "piotest")
|
||||||
|
|
||||||
REMAPED_OPTIONS = {"framework": "pioframework", "platform": "pioplatform"}
|
REMAPED_OPTIONS = {"framework": "pioframework", "platform": "pioplatform"}
|
||||||
|
|
||||||
@@ -141,10 +142,18 @@ class EnvironmentProcessor(object):
|
|||||||
terminal_width, _ = click.get_terminal_size()
|
terminal_width, _ = click.get_terminal_size()
|
||||||
start_time = time()
|
start_time = time()
|
||||||
|
|
||||||
click.echo("[%s] Processing %s (%s)" % (
|
process_opts = []
|
||||||
datetime.now().strftime("%c"), click.style(
|
for k, v in self.options.items():
|
||||||
self.name, fg="cyan", bold=True), ", ".join(
|
if "\n" in v:
|
||||||
["%s: %s" % (k, v) for k, v in self.options.iteritems()])))
|
process_opts.append((k, "; ".join(
|
||||||
|
[s.strip() for s in v.split("\n") if s.strip()])))
|
||||||
|
else:
|
||||||
|
process_opts.append((k, v))
|
||||||
|
|
||||||
|
click.echo("[%s] Processing %s (%s)" %
|
||||||
|
(datetime.now().strftime("%c"), click.style(
|
||||||
|
self.name, fg="cyan", bold=True),
|
||||||
|
", ".join(["%s: %s" % opts for opts in process_opts])))
|
||||||
click.secho("-" * terminal_width, bold=True)
|
click.secho("-" * terminal_width, bold=True)
|
||||||
|
|
||||||
self.options = self._validate_options(self.options)
|
self.options = self._validate_options(self.options)
|
||||||
@@ -212,8 +221,15 @@ class EnvironmentProcessor(object):
|
|||||||
|
|
||||||
# install dependent libraries
|
# install dependent libraries
|
||||||
if "lib_install" in self.options:
|
if "lib_install" in self.options:
|
||||||
_autoinstall_libs(self.cmd_ctx, self.options['lib_install'],
|
_autoinstall_libdeps(self.cmd_ctx, [
|
||||||
self.verbose)
|
int(d.strip()) for d in self.options['lib_install'].split(",")
|
||||||
|
if d.strip()
|
||||||
|
], self.verbose)
|
||||||
|
if "lib_deps" in self.options:
|
||||||
|
_autoinstall_libdeps(self.cmd_ctx, [
|
||||||
|
d.strip() for d in self.options['lib_deps'].split("\n")
|
||||||
|
if d.strip()
|
||||||
|
], self.verbose)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p = PlatformFactory.newPlatform(self.options['platform'])
|
p = PlatformFactory.newPlatform(self.options['platform'])
|
||||||
@@ -225,15 +241,12 @@ class EnvironmentProcessor(object):
|
|||||||
return p.run(build_vars, build_targets, self.verbose)
|
return p.run(build_vars, build_targets, self.verbose)
|
||||||
|
|
||||||
|
|
||||||
def _autoinstall_libs(ctx, libids_list, verbose=False):
|
def _autoinstall_libdeps(ctx, libraries, verbose=False):
|
||||||
storage_dir = util.get_projectlibdeps_dir()
|
storage_dir = util.get_projectlibdeps_dir()
|
||||||
ctx.obj = LibraryManager(storage_dir)
|
ctx.obj = LibraryManager(storage_dir)
|
||||||
if verbose:
|
if verbose:
|
||||||
click.echo("Library Storage: " + storage_dir)
|
click.echo("Library Storage: " + storage_dir)
|
||||||
ctx.invoke(
|
ctx.invoke(cmd_lib_install, libraries=libraries, quiet=not verbose)
|
||||||
cmd_lib_install,
|
|
||||||
libraries=[int(l.strip()) for l in libids_list.split(",")],
|
|
||||||
quiet=not verbose)
|
|
||||||
|
|
||||||
|
|
||||||
def _clean_pioenvs_dir(pioenvs_dir):
|
def _clean_pioenvs_dir(pioenvs_dir):
|
||||||
|
Reference in New Issue
Block a user