mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Revert "Revert back "Look firstly in built-in library storages""
This reverts commit 4ae302762a
.
This commit is contained in:
@ -27,6 +27,7 @@ PlatformIO 4.0
|
||||
- Save libraries passed to `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__ command into the project dependency list (`lib_deps <http://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__) with a new ``--save`` flag (`issue #1028 <https://github.com/platformio/platformio-core/issues/1028>`_)
|
||||
- Install all project dependencies declared via `lib_deps <http://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__ option using a simple `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__ command (`issue #2147 <https://github.com/platformio/platformio-core/issues/2147>`_)
|
||||
- Use isolated library dependency storage per project build environment (`issue #1696 <https://github.com/platformio/platformio-core/issues/1696>`_)
|
||||
- Look firstly in built-in library storages for a missing dependency instead of PlatformIO Registry (`issue #1654 <https://github.com/platformio/platformio-core/issues/1654>`_)
|
||||
- Override default source and include directories for a library via `library.json <http://docs.platformio.org/page/librarymanager/config.html>`__ manifest using ``includeDir`` and ``srcDir`` fields
|
||||
- Fixed an issue when library keeps reinstalling for non-latin path (`issue #1252 <https://github.com/platformio/platformio-core/issues/1252>`_)
|
||||
|
||||
|
@ -18,7 +18,7 @@ from traceback import format_exc
|
||||
|
||||
import click
|
||||
|
||||
from platformio import __version__, exception, maintenance
|
||||
from platformio import __version__, exception, maintenance, util
|
||||
from platformio.commands import PlatformioCLI
|
||||
from platformio.compat import CYGWIN
|
||||
|
||||
@ -42,6 +42,7 @@ def process_result(ctx, result, force, caller): # pylint: disable=W0613
|
||||
maintenance.on_platformio_end(ctx, result)
|
||||
|
||||
|
||||
@util.memoized()
|
||||
def configure():
|
||||
if CYGWIN:
|
||||
raise exception.CygwinEnvDetected()
|
||||
@ -76,10 +77,17 @@ def configure():
|
||||
click.secho = lambda *args, **kwargs: _safe_echo(1, *args, **kwargs)
|
||||
|
||||
|
||||
def main():
|
||||
def main(argv=None):
|
||||
exit_code = 0
|
||||
prev_sys_argv = sys.argv[:]
|
||||
if argv:
|
||||
assert isinstance(argv, list)
|
||||
sys.argv = argv
|
||||
try:
|
||||
configure()
|
||||
cli(None, None, None)
|
||||
except SystemExit:
|
||||
pass
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
if not isinstance(e, exception.ReturnErrorCode):
|
||||
maintenance.on_platformio_exception(e)
|
||||
@ -105,8 +113,9 @@ An unexpected error occurred. Further steps:
|
||||
============================================================
|
||||
"""
|
||||
click.secho(error_str, fg="red", err=True)
|
||||
return int(str(e)) if str(e).isdigit() else 1
|
||||
return 0
|
||||
exit_code = int(str(e)) if str(e).isdigit() else 1
|
||||
sys.argv = prev_sys_argv
|
||||
return exit_code
|
||||
|
||||
|
||||
def debug_gdb_main():
|
||||
|
@ -16,6 +16,7 @@ from os import environ
|
||||
from os.path import join
|
||||
from time import time
|
||||
|
||||
import click
|
||||
from SCons.Script import ARGUMENTS # pylint: disable=import-error
|
||||
from SCons.Script import COMMAND_LINE_TARGETS # pylint: disable=import-error
|
||||
from SCons.Script import DEFAULT_TARGETS # pylint: disable=import-error
|
||||
@ -95,6 +96,10 @@ env.Replace(
|
||||
for key in list(clivars.keys()) if key in env
|
||||
})
|
||||
|
||||
if int(ARGUMENTS.get("ISATTY", 0)):
|
||||
# pylint: disable=protected-access
|
||||
click._compat.isatty = lambda stream: True
|
||||
|
||||
if env.GetOption('clean'):
|
||||
env.PioClean(env.subst("$BUILD_DIR"))
|
||||
env.Exit(0)
|
||||
|
@ -25,6 +25,7 @@ import sys
|
||||
from os.path import (basename, commonprefix, dirname, expanduser, isdir,
|
||||
isfile, join, realpath, sep)
|
||||
|
||||
import click
|
||||
import SCons.Scanner # pylint: disable=import-error
|
||||
from SCons.Script import ARGUMENTS # pylint: disable=import-error
|
||||
from SCons.Script import COMMAND_LINE_TARGETS # pylint: disable=import-error
|
||||
@ -862,15 +863,15 @@ class ProjectAsLibBuilder(LibBuilderBase):
|
||||
pass
|
||||
|
||||
def process_dependencies(self): # pylint: disable=too-many-branches
|
||||
uris = self.env.GetProjectOption("lib_deps", [])
|
||||
if not uris:
|
||||
lib_deps = self.env.GetProjectOption("lib_deps")
|
||||
if not lib_deps:
|
||||
return
|
||||
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 uris:
|
||||
for uri in lib_deps:
|
||||
found = False
|
||||
for storage_dir in storage_dirs:
|
||||
if found:
|
||||
@ -888,12 +889,26 @@ class ProjectAsLibBuilder(LibBuilderBase):
|
||||
break
|
||||
|
||||
if not found:
|
||||
# look for built-in libraries by a name
|
||||
# which don't have package manifest
|
||||
for lb in self.env.GetLibBuilders():
|
||||
if lb.name != uri:
|
||||
continue
|
||||
if lb not in self.depbuilders:
|
||||
self.depend_recursive(lb)
|
||||
break
|
||||
if lb.name == uri:
|
||||
if lb not in self.depbuilders:
|
||||
self.depend_recursive(lb)
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
lm = LibraryManager(
|
||||
self.env.subst(join("$PROJECTLIBDEPS_DIR", "$PIOENV")))
|
||||
try:
|
||||
lm.install(uri)
|
||||
# delete cached lib builders
|
||||
if "__PIO_LIB_BUILDERS" in DefaultEnvironment():
|
||||
del DefaultEnvironment()['__PIO_LIB_BUILDERS']
|
||||
except (exception.LibNotFound,
|
||||
exception.InternetIsOffline) as e:
|
||||
click.secho("Warning! %s" % e, fg="yellow")
|
||||
|
||||
def build(self):
|
||||
self._is_built = True # do not build Project now
|
||||
@ -917,8 +932,7 @@ def GetLibBuilders(env): # pylint: disable=too-many-branches
|
||||
key=lambda lb: 0 if lb.dependent else 1)
|
||||
|
||||
items = []
|
||||
verbose = int(ARGUMENTS.get("PIOVERBOSE",
|
||||
0)) and not env.GetOption('clean')
|
||||
verbose = int(ARGUMENTS.get("PIOVERBOSE", 0))
|
||||
|
||||
def _check_lib_builder(lb):
|
||||
compat_mode = lb.lib_compat_mode
|
||||
|
@ -18,10 +18,7 @@ from time import time
|
||||
|
||||
import click
|
||||
|
||||
from platformio import exception, util
|
||||
from platformio.commands.lib import (CTX_META_STORAGE_DIRS_KEY,
|
||||
CTX_META_STORAGE_LIBDEPS_KEY)
|
||||
from platformio.commands.lib import lib_install as cmd_lib_install
|
||||
from platformio import util
|
||||
from platformio.project.helpers import (calculate_project_hash,
|
||||
get_project_dir,
|
||||
get_project_libdeps_dir)
|
||||
@ -46,22 +43,6 @@ def handle_legacy_libdeps(project_dir, config):
|
||||
fg="yellow")
|
||||
|
||||
|
||||
def autoinstall_libdeps(ctx, envname, libraries, verbose=False):
|
||||
if not libraries:
|
||||
return
|
||||
libdeps_dir = join(get_project_libdeps_dir(), envname)
|
||||
ctx.meta.update({
|
||||
CTX_META_STORAGE_DIRS_KEY: [libdeps_dir],
|
||||
CTX_META_STORAGE_LIBDEPS_KEY: {
|
||||
libdeps_dir: libraries
|
||||
}
|
||||
})
|
||||
try:
|
||||
ctx.invoke(cmd_lib_install, silent=not verbose)
|
||||
except exception.InternetIsOffline as e:
|
||||
click.secho(str(e), fg="yellow")
|
||||
|
||||
|
||||
def clean_build_dir(build_dir):
|
||||
# remove legacy ".pioenvs" folder
|
||||
legacy_build_dir = join(get_project_dir(), ".pioenvs")
|
||||
|
@ -19,7 +19,7 @@ import click
|
||||
from platformio import exception, telemetry
|
||||
from platformio.commands.platform import \
|
||||
platform_install as cmd_platform_install
|
||||
from platformio.commands.run.helpers import autoinstall_libdeps, print_header
|
||||
from platformio.commands.run.helpers import print_header
|
||||
from platformio.commands.test.processor import (CTX_META_TEST_IS_RUNNING,
|
||||
CTX_META_TEST_RUNNING_NAME)
|
||||
from platformio.managers.platform import PlatformFactory
|
||||
@ -103,10 +103,6 @@ class EnvironmentProcessor(object):
|
||||
# skip monitor target, we call it above
|
||||
if "monitor" in build_targets:
|
||||
build_targets.remove("monitor")
|
||||
if "nobuild" not in build_targets and "lib_deps" in self.options:
|
||||
autoinstall_libdeps(
|
||||
self.cmd_ctx, self.name,
|
||||
self.config.get("env:" + self.name, "lib_deps"), self.verbose)
|
||||
|
||||
try:
|
||||
p = PlatformFactory.newPlatform(self.options['platform'])
|
||||
|
@ -171,6 +171,7 @@ class PkgInstallerMixin(object):
|
||||
if fname and isfile(cache_path):
|
||||
dst_path = join(dest_dir, fname)
|
||||
shutil.copy(cache_path, dst_path)
|
||||
click.echo("Using cache: %s" % cache_path)
|
||||
return dst_path
|
||||
|
||||
with_progress = not app.is_disabled_progressbar()
|
||||
|
@ -407,6 +407,9 @@ class PlatformRunMixin(object):
|
||||
join(util.get_source_dir(), "builder", "main.py")
|
||||
]
|
||||
cmd.append("PIOVERBOSE=%d" % (1 if self.verbose else 0))
|
||||
# pylint: disable=protected-access
|
||||
cmd.append("ISATTY=%d" %
|
||||
(1 if click._compat.isatty(sys.stdout) else 0))
|
||||
cmd += targets
|
||||
|
||||
# encode and append variables
|
||||
|
Reference in New Issue
Block a user