Added global “lib_extra_dirs” option to “[platformio]” section // Resolve #842

This commit is contained in:
Ivan Kravets
2016-12-05 14:43:06 +02:00
parent c75fc623cb
commit 44e11bcc33
5 changed files with 66 additions and 33 deletions

View File

@@ -41,6 +41,9 @@ PlatformIO 3.0
(`issue #837 <https://github.com/platformio/platformio-core/issues/837>`_) (`issue #837 <https://github.com/platformio/platformio-core/issues/837>`_)
* Added new `LDF Modes <http://docs.platformio.org/en/latest/librarymanager/ldf.html#ldf-mode>`__: * Added new `LDF Modes <http://docs.platformio.org/en/latest/librarymanager/ldf.html#ldf-mode>`__:
``chain+`` and ``deep+`` and set ``chain+`` as default ``chain+`` and ``deep+`` and set ``chain+`` as default
* Added global ``lib_extra_dirs`` option to ``[platformio]`` section for
`Project Configuration File "platformio.ini" <http://docs.platformio.org/en/stable/projectconf.html>`__
(`issue #842 <https://github.com/platformio/platformio-core/issues/842>`_)
* Changed a default exit combination for Device Monitor from ``Ctrl+]`` to ``Ctrl+C`` * Changed a default exit combination for Device Monitor from ``Ctrl+]`` to ``Ctrl+C``
* Improved detecting of ARM mbed media disk for uploading * Improved detecting of ARM mbed media disk for uploading
* Improved Project Generator for CLion IDE when source folder contains nested items * Improved Project Generator for CLion IDE when source folder contains nested items

View File

@@ -113,8 +113,8 @@ if :option:`platformio run --environment` option is not specified.
:ref:`projectconf_pio_env_default` allows to define environments which :ref:`projectconf_pio_env_default` allows to define environments which
should be processed by default. should be processed by default.
Multiple environments are allowed if they are separated with ", " Multiple environments are allowed if they *are separated with ", "
(comma+space). For example. (comma+space)*. For example.
.. code-block:: ini .. code-block:: ini
@@ -225,6 +225,21 @@ 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_LIBDEPS_DIR`. :envvar:`PLATFORMIO_LIBDEPS_DIR`.
``lib_extra_dirs``
^^^^^^^^^^^^^^^^^^
.. versionadded:: 3.2
A list with global extra directories for a project where :ref:`ldf` will look
for libraries.
This option has the same behavior as :ref:`projectconf_lib_extra_dirs` option
for a specific build environment defined in ``[env:]`` section. The main
difference is that the option that is defined in ``[platofrmio]`` section
will be applied automatically for all ``[env:]`` sections.
For the possible values and examples please follow to :ref:`projectconf_lib_extra_dirs`.
.. _projectconf_pio_src_dir: .. _projectconf_pio_src_dir:
``src_dir`` ``src_dir``
@@ -381,7 +396,7 @@ Examples:
:ref:`frameworks` name. :ref:`frameworks` name.
The multiple frameworks are allowed, split them with comma+space ", ". The multiple frameworks are allowed, *split them with comma+space ", "*.
.. _projectconf_env_board: .. _projectconf_env_board:
@@ -735,7 +750,7 @@ Library options
Specify project dependencies that should be installed automatically to Specify project dependencies that should be installed automatically to
:ref:`projectconf_pio_libdeps_dir` before environment processing. :ref:`projectconf_pio_libdeps_dir` before environment processing.
Multiple dependencies are allowed (multi-lines or separated with comma+space ", "). Multiple dependencies are allowed (*multi-lines or separated with comma+space ", "*).
If you have multiple build environments that depend on the same libraries, If you have multiple build environments that depend on the same libraries,
you can use :ref:`projectconf_dynamic_vars` to use common configuration. you can use :ref:`projectconf_dynamic_vars` to use common configuration.
@@ -784,7 +799,7 @@ Specify libraries which should be ignored by Library Dependency Finder.
The correct value for this option is library name (not The correct value for this option is library name (not
folder name). In the most cases, library name is pre-defined in manifest file folder name). In the 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+space ", ". library names are allowed, *split them with comma+space ", "*.
Example: Example:
@@ -803,8 +818,8 @@ Example:
Please make sure to read :ref:`ldf` guide first. Please make sure to read :ref:`ldf` guide first.
A list with extra directories/storages where :ref:`ldf` will A list with extra directories/storages where :ref:`ldf` will
look for dependencies. Multiple paths are allowed. Please separate them look for dependencies. Multiple paths are allowed. *Please separate them
using comma+space ", ". using comma+space ", "*.
This option can be set by global environment variable This option can be set by global environment variable
:envvar:`PLATFORMIO_LIB_EXTRA_DIRS`. :envvar:`PLATFORMIO_LIB_EXTRA_DIRS`.
@@ -865,8 +880,8 @@ Test options
Please make sure to read :ref:`unit_testing` guide first. Please make sure to read :ref:`unit_testing` guide first.
Ignore :ref:`unit_testing` tests where the name matches specified patterns. Ignore :ref:`unit_testing` tests where the name matches specified patterns.
Multiple names are allowed. Please separate them using comma+space ", ". Also, Multiple names are allowed. *Please separate them using comma+space ", "*.
you can ignore some tests using :option:`platformio test --ignore` command. Also, you can ignore some tests using :option:`platformio test --ignore` command.
.. list-table:: .. list-table::
:header-rows: 1 :header-rows: 1

View File

@@ -126,7 +126,15 @@ for opt in ("PIOFRAMEWORK", "LIB_DEPS", "LIB_IGNORE", "LIB_EXTRA_DIRS"):
continue continue
env[opt] = [l.strip() for l in env[opt].split(", ") if l.strip()] env[opt] = [l.strip() for l in env[opt].split(", ") if l.strip()]
# Configure extra library source directories for LDF
if util.get_project_optional_dir("lib_extra_dirs"):
env.Prepend(LIBSOURCE_DIRS=[
l.strip()
for l in util.get_project_optional_dir("lib_extra_dirs").split(", ")
if l.strip()
])
env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", [])) env.Prepend(LIBSOURCE_DIRS=env.get("LIB_EXTRA_DIRS", []))
env.LoadPioPlatform(commonvars) env.LoadPioPlatform(commonvars)
env.SConscriptChdir(0) env.SConscriptChdir(0)

View File

@@ -345,7 +345,7 @@ def check_project_defopts(config):
if not config.has_section("platformio"): if not config.has_section("platformio"):
return True return True
known = ("home_dir", "lib_dir", "libdeps_dir", "src_dir", "envs_dir", known = ("home_dir", "lib_dir", "libdeps_dir", "src_dir", "envs_dir",
"data_dir", "test_dir", "env_default") "data_dir", "test_dir", "env_default", "lib_extra_dirs")
unknown = set([k for k, _ in config.items("platformio")]) - set(known) unknown = set([k for k, _ in config.items("platformio")]) - set(known)
if not unknown: if not unknown:
return True return True

View File

@@ -175,26 +175,33 @@ def pioversion_to_intstr():
return [int(i) for i in vermatch.group(1).split(".")[:3]] return [int(i) for i in vermatch.group(1).split(".")[:3]]
def _get_projconf_option_dir(name, default=None): def get_project_optional_dir(name, default=None):
_env_name = "PLATFORMIO_%s" % name.upper() data = None
if _env_name in os.environ: var_name = "PLATFORMIO_%s" % name.upper()
return os.getenv(_env_name) if var_name in os.environ:
data = os.getenv(var_name)
else:
try: try:
config = load_project_config() config = load_project_config()
if (config.has_section("platformio") and if (config.has_section("platformio") and
config.has_option("platformio", name)): config.has_option("platformio", name)):
option_dir = config.get("platformio", name) data = config.get("platformio", name)
if option_dir.startswith("~"):
option_dir = expanduser(option_dir)
return abspath(option_dir)
except exception.NotPlatformIOProject: except exception.NotPlatformIOProject:
pass pass
if not data:
return default return default
items = []
for item in data.split(", "):
if item.startswith("~"):
item = expanduser(item)
items.append(abspath(item))
return ", ".join(items)
def get_home_dir(): def get_home_dir():
home_dir = _get_projconf_option_dir("home_dir", home_dir = get_project_optional_dir("home_dir",
join(expanduser("~"), ".platformio")) join(expanduser("~"), ".platformio"))
if "windows" in get_systype(): if "windows" in get_systype():
@@ -241,30 +248,30 @@ def is_platformio_project(project_dir=None):
def get_projectlib_dir(): def get_projectlib_dir():
return _get_projconf_option_dir("lib_dir", join(get_project_dir(), "lib")) return get_project_optional_dir("lib_dir", join(get_project_dir(), "lib"))
def get_projectlibdeps_dir(): def get_projectlibdeps_dir():
return _get_projconf_option_dir("libdeps_dir", return get_project_optional_dir("libdeps_dir",
join(get_project_dir(), ".piolibdeps")) join(get_project_dir(), ".piolibdeps"))
def get_projectsrc_dir(): def get_projectsrc_dir():
return _get_projconf_option_dir("src_dir", join(get_project_dir(), "src")) return get_project_optional_dir("src_dir", join(get_project_dir(), "src"))
def get_projecttest_dir(): def get_projecttest_dir():
return _get_projconf_option_dir("test_dir", return get_project_optional_dir("test_dir",
join(get_project_dir(), "test")) join(get_project_dir(), "test"))
def get_projectboards_dir(): def get_projectboards_dir():
return _get_projconf_option_dir("boards_dir", return get_project_optional_dir("boards_dir",
join(get_project_dir(), "boards")) join(get_project_dir(), "boards"))
def get_projectpioenvs_dir(force=False): def get_projectpioenvs_dir(force=False):
path = _get_projconf_option_dir("envs_dir", path = get_project_optional_dir("envs_dir",
join(get_project_dir(), ".pioenvs")) join(get_project_dir(), ".pioenvs"))
try: try:
if not isdir(path): if not isdir(path):
@@ -283,7 +290,7 @@ URL=http://docs.platformio.org/en/stable/projectconf.html#envs-dir
def get_projectdata_dir(): def get_projectdata_dir():
return _get_projconf_option_dir("data_dir", return get_project_optional_dir("data_dir",
join(get_project_dir(), "data")) join(get_project_dir(), "data"))