Skip to content

Commit 0db425c

Browse files
massonalfpistm
authored andcommitted
fix: harden cmake_easy_setup
Now detects and warns when arduino-cli is misconfigured, and falls back to a sensible default value for userlibs.
1 parent a06ddd7 commit 0db425c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

cmake/scripts/cmake_easy_setup.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,24 @@ def get_boards(boardstxt):
122122
libpaths[line["location"]] = pathlib.Path(line["dir"])
123123

124124
# platform lib path is already known, obviously, since that's where this script resides
125-
userlibs = pathlib.Path(libpaths["user"])
126-
if userlibs.exists():
127-
userlibs = userlibs.resolve()
128-
libs = [u.name for u in userlibs.iterdir() if u.is_dir()]
125+
if "user" in libpaths.keys():
126+
userlibs = pathlib.Path(libpaths["user"])
127+
if userlibs.exists():
128+
userlibs = userlibs.resolve()
129+
libs = [u.name for u in userlibs.iterdir() if u.is_dir()]
130+
else:
131+
print(
132+
f"""Warning: Cannot find {userlibs}.
133+
This has likely to do with your arduino-cli configuration.
134+
Please refer to the following link for setup details:
135+
https://arduino.github.io/arduino-cli/latest/getting-started/#create-a-configuration-file
136+
"""
137+
)
138+
libs = list()
129139
else:
140+
userlibs = pathlib.Path.home() / "Arduino/libraries"
130141
print(
131-
f"""Warning: Cannot find {userlibs}.
142+
f"""No user library path found through arduino-cli (falling back to {userlibs}).
132143
This has likely to do with your arduino-cli configuration.
133144
Please refer to the following link for setup details:
134145
https://arduino.github.io/arduino-cli/latest/getting-started/#create-a-configuration-file
@@ -197,7 +208,7 @@ def get_boards(boardstxt):
197208
For details, please refer to
198209
https://github.com/stm32duino/wiki/wiki/Arduino-%28in%29compatibility#library-management
199210
"""
200-
)
211+
)
201212

202213
if shargs.fire:
203214
if not (shargs.sketch and shargs.board):

0 commit comments

Comments
 (0)