Skip to content

Commit ffd6b2b

Browse files
authored
Merge pull request #175 from tyeth/master
Update build_platform.py - Don't install installed arduino libs
2 parents d447332 + 8655eaf commit ffd6b2b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

build_platform.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import glob
33
import time
44
import os
5+
import re
56
import shutil
67
import subprocess
78
import collections
@@ -166,6 +167,14 @@ def run_or_die(cmd, error):
166167

167168
print()
168169

170+
def is_library_installed(lib_name):
171+
try:
172+
installed_libs = subprocess.check_output(["arduino-cli", "lib", "list"]).decode("utf-8")
173+
return not all(not item for item in [re.match('^'+dep+'\\s*\\d+\\.', line) for line in installed_libs.split('\n')])
174+
except subprocess.CalledProcessError as e:
175+
print("Error checking installed libraries:", e)
176+
return False
177+
169178
################################ Install dependencies
170179
our_name=None
171180
try:
@@ -180,9 +189,12 @@ def run_or_die(cmd, error):
180189
deps = line.replace("depends=", "").split(",")
181190
for dep in deps:
182191
dep = dep.strip()
183-
print("Installing "+dep)
184-
run_or_die('arduino-cli lib install "'+dep+'" > /dev/null',
185-
"FAILED to install dependency "+dep)
192+
if not is_library_installed(dep):
193+
print("Installing "+dep)
194+
run_or_die('arduino-cli lib install "'+dep+'" > /dev/null',
195+
"FAILED to install dependency "+dep)
196+
else:
197+
print("Skipping already installed lib: "+dep)
186198
except OSError:
187199
print("No library dep or properties found!")
188200
pass # no library properties

0 commit comments

Comments
 (0)