Improved handling of library dependencies defined as VCS or SemVer in platformio.ini // Resolve #1155

This commit is contained in:
Ivan Kravets
2017-11-25 19:22:00 +02:00
parent 9b514ba194
commit 547e983a86
3 changed files with 45 additions and 20 deletions

View File

@ -11,6 +11,9 @@ PlatformIO 3.0
* Integration with `Jenkins CI <http://docs.platformio.org/en/latest/ci/jenkins.html>`_ * Integration with `Jenkins CI <http://docs.platformio.org/en/latest/ci/jenkins.html>`_
* Depend on development platform using VSC URL (Git, Mercurial and Subversion) * Depend on development platform using VSC URL (Git, Mercurial and Subversion)
in `Project Configuration File "platformio.ini" <http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform>`__ in `Project Configuration File "platformio.ini" <http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform>`__
* Improved handling of library dependencies defined as VCS or SemVer in
`Project Configuration File "platformio.ini" <http://docs.platformio.org/en/latest/projectconf/section_env_general.html#platform>`__
(`issue #1155 <https://github.com/platformio/platformio-core/issues/1155>`_)
* Fixed "Super-Quick (Mac / Linux)" installer script * Fixed "Super-Quick (Mac / Linux)" installer script
(`issue #1017 <https://github.com/platformio/platformio-core/issues/1017>`_) (`issue #1017 <https://github.com/platformio/platformio-core/issues/1017>`_)
* Fixed issue with "IOError" in VSCode when processing a project * Fixed issue with "IOError" in VSCode when processing a project

View File

@ -19,7 +19,8 @@ from __future__ import absolute_import
import os import os
import sys import sys
from os.path import basename, commonprefix, isdir, isfile, join, realpath, sep from os.path import (basename, commonprefix, dirname, isdir, isfile, join,
realpath, sep)
from platform import system from platform import system
import SCons.Scanner import SCons.Scanner
@ -242,7 +243,7 @@ class LibBuilderBase(object):
"pio_lib_builder": self "pio_lib_builder": self
}) })
def _process_dependencies(self): def process_dependencies(self):
if not self.dependencies: if not self.dependencies:
return return
for item in self.dependencies: for item in self.dependencies:
@ -297,15 +298,10 @@ class LibBuilderBase(object):
def _get_found_includes(self, search_paths=None): def _get_found_includes(self, search_paths=None):
# all include directories # all include directories
if not LibBuilderBase.INC_DIRS_CACHE: if not LibBuilderBase.INC_DIRS_CACHE:
inc_dirs = [] LibBuilderBase.INC_DIRS_CACHE = []
used_inc_dirs = []
for lb in self.envorigin.GetLibBuilders(): for lb in self.envorigin.GetLibBuilders():
items = [self.env.Dir(d) for d in lb.get_inc_dirs()] LibBuilderBase.INC_DIRS_CACHE.extend(
if lb.dependent: [self.env.Dir(d) for d in lb.get_inc_dirs()])
used_inc_dirs.extend(items)
else:
inc_dirs.extend(items)
LibBuilderBase.INC_DIRS_CACHE = used_inc_dirs + inc_dirs
# append self include directories # append self include directories
inc_dirs = [self.env.Dir(d) for d in self.get_inc_dirs()] inc_dirs = [self.env.Dir(d) for d in self.get_inc_dirs()]
@ -356,7 +352,7 @@ class LibBuilderBase(object):
def search_deps_recursive(self, search_paths=None): def search_deps_recursive(self, search_paths=None):
if not self._is_dependent: if not self._is_dependent:
self._is_dependent = True self._is_dependent = True
self._process_dependencies() self.process_dependencies()
if self.lib_ldf_mode.startswith("deep"): if self.lib_ldf_mode.startswith("deep"):
search_paths = self.get_src_files() search_paths = self.get_src_files()
@ -588,17 +584,40 @@ class ProjectAsLibBuilder(LibBuilderBase):
# skip for project, options are already processed # skip for project, options are already processed
pass pass
def search_deps_recursive(self, search_paths=None): def process_dependencies(self):
for dep in self.env.get("LIB_DEPS", []): dependencies = self.env.get("LIB_DEPS", [])
for token in ("@", "="): if not dependencies:
if token in dep: return
dep, _ = dep.split(token, 1) storage_dirs = []
for lb in self.envorigin.GetLibBuilders(): for lb in self.env.GetLibBuilders():
if lb.name == dep: if dirname(lb.path) not in storage_dirs:
storage_dirs.append(dirname(lb.path))
for uri in self.env.get("LIB_DEPS", []):
found = False
for storage_dir in storage_dirs:
if found:
break
lm = LibraryManager(storage_dir)
pkg_dir = lm.get_package_dir(*lm.parse_pkg_uri(uri))
if not pkg_dir:
continue
for lb in self.envorigin.GetLibBuilders():
if lb.path != pkg_dir:
continue
if lb not in self.depbuilders:
self.depend_recursive(lb)
found = True
break
if not found:
print 67, uri
for lb in self.envorigin.GetLibBuilders():
if lb.name != uri:
continue
if lb not in self.depbuilders: if lb not in self.depbuilders:
self.depend_recursive(lb) self.depend_recursive(lb)
break break
return LibBuilderBase.search_deps_recursive(self, search_paths)
def build(self): def build(self):
self._is_built = True # do not build Project now self._is_built = True # do not build Project now
@ -609,7 +628,9 @@ class ProjectAsLibBuilder(LibBuilderBase):
def GetLibBuilders(env): # pylint: disable=too-many-branches def GetLibBuilders(env): # pylint: disable=too-many-branches
if "__PIO_LIB_BUILDERS" in DefaultEnvironment(): if "__PIO_LIB_BUILDERS" in DefaultEnvironment():
return DefaultEnvironment()['__PIO_LIB_BUILDERS'] return sorted(
DefaultEnvironment()['__PIO_LIB_BUILDERS'],
key=lambda lb: 0 if lb.dependent else 1)
items = [] items = []
compat_mode = int(env.get("LIB_COMPAT_MODE", 1)) compat_mode = int(env.get("LIB_COMPAT_MODE", 1))

View File

@ -104,6 +104,7 @@ class LibraryManager(BasePkgManager):
"sam": "atmelsam", "sam": "atmelsam",
"samd": "atmelsam", "samd": "atmelsam",
"esp8266": "espressif8266", "esp8266": "espressif8266",
"esp32": "espressif32",
"arc32": "intel_arc32" "arc32": "intel_arc32"
} }
for arch in manifest['architectures'].split(","): for arch in manifest['architectures'].split(","):