From 3287dbcee79034b03c1c3383f4f91d01b82f3e38 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 15 Dec 2020 01:02:45 +0300 Subject: [PATCH] pio: small helper to use libdeps installer --- code/scripts/pio_pre.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/code/scripts/pio_pre.py b/code/scripts/pio_pre.py index ded05876..a58e7319 100644 --- a/code/scripts/pio_pre.py +++ b/code/scripts/pio_pre.py @@ -38,7 +38,7 @@ def log(message, verbose=False, file=sys.stderr): # Most portable way, without depending on platformio internals -def subprocess_libdeps(lib_deps, storage=None, silent=True): +def subprocess_libdeps(lib_deps, storage=None, verbose=False): import subprocess args = [env.subst("$PYTHONEXE"), "-mplatformio", "lib"] @@ -47,7 +47,7 @@ def subprocess_libdeps(lib_deps, storage=None, silent=True): else: args.extend(["-d", storage]) args.append("install") - if silent: + if not verbose: args.append("-s") args.extend(lib_deps) @@ -137,7 +137,7 @@ if os.environ.get("ESPURNA_PIO_SHARED_LIBRARIES"): storage = get_shared_libdeps_dir("common", "shared_libdeps_dir") log("using shared library storage: {}".format(storage)) - subprocess_libdeps(env.GetProjectOption("lib_deps"), storage) + subprocess_libdeps(env.GetProjectOption("lib_deps"), storage, verbose=VERBOSE) # tweak build system to ignore espurna.ino, but include user code # ref: platformio-core/platformio/tools/piomisc.py::ConvertInoToCpp() @@ -163,3 +163,15 @@ if "1" == os.environ.get("ESPURNA_BUILD_SINGLE_SOURCE", "0"): relpath = os.path.relpath(abspath, "espurna") cpp_files.append(relpath) merge_cpp(cpp_files, "espurna/espurna_single_source.cpp") + +# make sure to register as a valid command. however, it is always called right here +# (--list-targets is a kind-of inefficient for finding this, though, since it *will* install libs into .pio/ anyways...) +def install_libs_dummy(target, source, env): + pass +env.AddCustomTarget("install-libs", None, install_libs_dummy) + +from SCons.Script import COMMAND_LINE_TARGETS +if "install-libs" in COMMAND_LINE_TARGETS: + storage = get_shared_libdeps_dir("common", "shared_libdeps_dir") + subprocess_libdeps(env.GetProjectOption("lib_deps"), storage, verbose=VERBOSE) + sys.exit(0)