Skip to content

Commit c38310b

Browse files
committed
uninstall ourselves if installed by library manager
1 parent d134ae2 commit c38310b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

build_platform.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def install_platform(platform):
9898
ColorPrint.print_pass(CHECK)
9999

100100
def run_or_die(cmd, error):
101+
print(cmd)
101102
if os.system(cmd) != 0:
102103
ColorPrint.print_fail(error)
103104
exit(-1)
@@ -121,9 +122,12 @@ def run_or_die(cmd, error):
121122
os.symlink(BUILD_DIR, os.environ['HOME']+'/Arduino/libraries/Adafruit_Test_Library')
122123

123124
################################ Install dependancies
125+
our_name=None
124126
try:
125127
libprop = open(BUILD_DIR+'/library.properties')
126128
for line in libprop:
129+
if line.startswith("name="):
130+
our_name = line.replace("depends=", "").strip()
127131
if line.startswith("depends="):
128132
deps = line.replace("depends=", "").split(",")
129133
for dep in deps:
@@ -134,6 +138,11 @@ def run_or_die(cmd, error):
134138
except OSError:
135139
pass # no library properties
136140

141+
# Delete the existing library if we somehow downloaded
142+
# due to dependancies
143+
if our_name:
144+
run_or_die("arduino-cli lib uninstall \""+our_name+"\"", "Could not uninstall")
145+
137146
print("Libraries installed: ", glob.glob(os.environ['HOME']+'/Arduino/libraries/*'))
138147

139148
################################ Test platforms

0 commit comments

Comments
 (0)