From 8655eaf78a93c1245d4480a3b2798caeeaf72315 Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Tue, 9 Jan 2024 14:40:40 +0000 Subject: [PATCH] Update build_platform.py - Don't install installed arduino libs This allows us to override the dependencies from latest version to a manually installed version (as a precursor build step) Needed to allow specifying version 6.x of ArduinoJson rather than latest 7 (breaking changes) --- build_platform.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/build_platform.py b/build_platform.py index 2ea3679..a042de6 100755 --- a/build_platform.py +++ b/build_platform.py @@ -2,6 +2,7 @@ import glob import time import os +import re import shutil import subprocess import collections @@ -166,6 +167,14 @@ def run_or_die(cmd, error): print() +def is_library_installed(lib_name): + try: + installed_libs = subprocess.check_output(["arduino-cli", "lib", "list"]).decode("utf-8") + return not all(not item for item in [re.match('^'+dep+'\\s*\\d+\\.', line) for line in installed_libs.split('\n')]) + except subprocess.CalledProcessError as e: + print("Error checking installed libraries:", e) + return False + ################################ Install dependencies our_name=None try: @@ -180,9 +189,12 @@ def run_or_die(cmd, error): deps = line.replace("depends=", "").split(",") for dep in deps: dep = dep.strip() - print("Installing "+dep) - run_or_die('arduino-cli lib install "'+dep+'" > /dev/null', - "FAILED to install dependency "+dep) + if not is_library_installed(dep): + print("Installing "+dep) + run_or_die('arduino-cli lib install "'+dep+'" > /dev/null', + "FAILED to install dependency "+dep) + else: + print("Skipping already installed lib: "+dep) except OSError: print("No library dep or properties found!") pass # no library properties