Skip to content

Commit f7f9ae6

Browse files
committed
Properly handle possible foreign files for STM32Cube // Resolve #531
1 parent 472c5ca commit f7f9ae6

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

builder/frameworks/stm32cube.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ def generate_hal_config_file():
137137

138138

139139
def build_custom_lib(lib_path, lib_manifest=None):
140+
if not os.path.isdir(lib_path):
141+
return
140142
if board.get("build.stm32cube.disable_embedded_libs", "no") == "yes":
141143
return
142144
if lib_path:
@@ -255,8 +257,9 @@ def build_usb_libs(usb_libs_root):
255257

256258
bsp_dir = os.path.join(FRAMEWORK_DIR, "Drivers", "BSP")
257259
components_dir = os.path.join(bsp_dir, "Components")
258-
for component in os.listdir(components_dir):
259-
build_custom_lib(os.path.join(components_dir, component))
260+
if os.path.isdir(components_dir):
261+
for component in os.listdir(components_dir):
262+
build_custom_lib(os.path.join(components_dir, component))
260263

261264
if os.path.isdir(os.path.join(bsp_dir, "Adafruit_Shield")):
262265
build_custom_lib(os.path.join(bsp_dir, "Adafruit_Shield"))
@@ -266,19 +269,25 @@ def build_usb_libs(usb_libs_root):
266269
#
267270

268271
utils_dir = os.path.join(FRAMEWORK_DIR, "Utilities")
269-
for util in os.listdir(utils_dir):
270-
util_dir = os.path.join(utils_dir, util)
271-
# Some of utilities is not meant to be built
272-
if not any(f.endswith((".c", ".h")) for f in os.listdir(util_dir)):
273-
continue
274-
build_custom_lib(
275-
os.path.join(utils_dir, util),
276-
{
277-
"name": "Util-%s" % util,
278-
"dependencies": [{"name": "FrameworkVariantBSP"}],
279-
"build": {"flags": ["-I $PROJECT_SRC_DIR", "-I $PROJECT_INCLUDE_DIR"], "libLDFMode": "deep"},
280-
},
281-
)
272+
if os.path.isdir(utils_dir):
273+
for util in os.listdir(utils_dir):
274+
util_dir = os.path.join(utils_dir, util)
275+
# Some of utilities is not meant to be built
276+
if not os.path.isdir(util_dir) or not any(
277+
f.endswith((".c", ".h")) for f in os.listdir(util_dir)
278+
):
279+
continue
280+
build_custom_lib(
281+
os.path.join(utils_dir, util),
282+
{
283+
"name": "Util-%s" % util,
284+
"dependencies": [{"name": "FrameworkVariantBSP"}],
285+
"build": {
286+
"flags": ["-I $PROJECT_SRC_DIR", "-I $PROJECT_INCLUDE_DIR"],
287+
"libLDFMode": "deep",
288+
},
289+
},
290+
)
282291

283292
#
284293
# USB libraries from ST

0 commit comments

Comments
 (0)