Skip to content

Commit

Permalink
Merge pull request #175 from tyeth/master
Browse files Browse the repository at this point in the history
Update build_platform.py - Don't install installed arduino libs
  • Loading branch information
tyeth authored Jan 9, 2024
2 parents d447332 + 8655eaf commit ffd6b2b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions build_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import glob
import time
import os
import re
import shutil
import subprocess
import collections
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit ffd6b2b

Please sign in to comment.