forked from platformio/platformio-core
Look in for "lib_deps" in all declared library storages // Resolve #2708
This commit is contained in:
@ -22,8 +22,8 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from os.path import (basename, commonprefix, dirname, expanduser, isdir,
|
from os.path import (basename, commonprefix, expanduser, isdir, isfile, join,
|
||||||
isfile, join, realpath, sep)
|
realpath, sep)
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import SCons.Scanner # pylint: disable=import-error
|
import SCons.Scanner # pylint: disable=import-error
|
||||||
@ -855,16 +855,27 @@ class ProjectAsLibBuilder(LibBuilderBase):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
not_found_uri = []
|
||||||
|
for uri in self.dependencies:
|
||||||
|
# check if built-in library
|
||||||
|
if _is_builtin(uri):
|
||||||
|
continue
|
||||||
|
|
||||||
|
found = False
|
||||||
|
for storage_dir in self.env.GetLibSourceDirs():
|
||||||
|
lm = LibraryManager(storage_dir)
|
||||||
|
if lm.get_package_dir(*lm.parse_pkg_uri(uri)):
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
if not found:
|
||||||
|
not_found_uri.append(uri)
|
||||||
|
|
||||||
|
did_install = False
|
||||||
lm = LibraryManager(
|
lm = LibraryManager(
|
||||||
self.env.subst(join("$PROJECTLIBDEPS_DIR", "$PIOENV")))
|
self.env.subst(join("$PROJECTLIBDEPS_DIR", "$PIOENV")))
|
||||||
did_install = False
|
for uri in not_found_uri:
|
||||||
for item in self.dependencies:
|
|
||||||
# check if built-in library or already installed
|
|
||||||
if (_is_builtin(item)
|
|
||||||
or lm.get_package_dir(*lm.parse_pkg_uri(item))):
|
|
||||||
continue
|
|
||||||
try:
|
try:
|
||||||
lm.install(item)
|
lm.install(uri)
|
||||||
did_install = True
|
did_install = True
|
||||||
except (exception.LibNotFound, exception.InternetIsOffline) as e:
|
except (exception.LibNotFound, exception.InternetIsOffline) as e:
|
||||||
click.secho("Warning! %s" % e, fg="yellow")
|
click.secho("Warning! %s" % e, fg="yellow")
|
||||||
@ -874,14 +885,9 @@ class ProjectAsLibBuilder(LibBuilderBase):
|
|||||||
DefaultEnvironment().Replace(__PIO_LIB_BUILDERS=None)
|
DefaultEnvironment().Replace(__PIO_LIB_BUILDERS=None)
|
||||||
|
|
||||||
def process_dependencies(self): # pylint: disable=too-many-branches
|
def process_dependencies(self): # pylint: disable=too-many-branches
|
||||||
storage_dirs = []
|
|
||||||
for lb in self.env.GetLibBuilders():
|
|
||||||
if dirname(lb.path) not in storage_dirs:
|
|
||||||
storage_dirs.append(dirname(lb.path))
|
|
||||||
|
|
||||||
for uri in self.dependencies:
|
for uri in self.dependencies:
|
||||||
found = False
|
found = False
|
||||||
for storage_dir in storage_dirs:
|
for storage_dir in self.env.GetLibSourceDirs():
|
||||||
if found:
|
if found:
|
||||||
break
|
break
|
||||||
lm = LibraryManager(storage_dir)
|
lm = LibraryManager(storage_dir)
|
||||||
@ -919,7 +925,8 @@ def GetLibSourceDirs(env):
|
|||||||
items = env.GetProjectOption("lib_extra_dirs", [])
|
items = env.GetProjectOption("lib_extra_dirs", [])
|
||||||
items.extend(env['LIBSOURCE_DIRS'])
|
items.extend(env['LIBSOURCE_DIRS'])
|
||||||
return [
|
return [
|
||||||
expanduser(item) if item.startswith("~") else item for item in items
|
env.subst(expanduser(item) if item.startswith("~") else item)
|
||||||
|
for item in items
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -954,12 +961,12 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches
|
|||||||
verbose = int(ARGUMENTS.get("PIOVERBOSE", 0))
|
verbose = int(ARGUMENTS.get("PIOVERBOSE", 0))
|
||||||
found_incompat = False
|
found_incompat = False
|
||||||
|
|
||||||
for libs_dir in env.GetLibSourceDirs():
|
for storage_dir in env.GetLibSourceDirs():
|
||||||
libs_dir = realpath(env.subst(libs_dir))
|
storage_dir = realpath(storage_dir)
|
||||||
if not isdir(libs_dir):
|
if not isdir(storage_dir):
|
||||||
continue
|
continue
|
||||||
for item in sorted(os.listdir(libs_dir)):
|
for item in sorted(os.listdir(storage_dir)):
|
||||||
lib_dir = join(libs_dir, item)
|
lib_dir = join(storage_dir, item)
|
||||||
if item == "__cores__" or not isdir(lib_dir):
|
if item == "__cores__" or not isdir(lib_dir):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user