Skip to content

Commit cdcb5c2

Browse files
authored
Update component_manager.py
1 parent 68395eb commit cdcb5c2

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

builder/frameworks/component_manager.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,64 @@ def _convert_lib_name_to_include(self, lib_name: str) -> str:
297297

298298
return cleaned_name
299299

300+
def _has_bt_ble_dependencies(self) -> bool:
301+
"""Check if lib_deps contains any BT/BLE related dependencies."""
302+
try:
303+
# Get lib_deps from current environment
304+
lib_deps = self.env.GetProjectOption("lib_deps", [])
305+
306+
if isinstance(lib_deps, str):
307+
lib_deps = [lib_deps]
308+
elif lib_deps is None:
309+
lib_deps = []
310+
311+
# Convert to string and check for BT/BLE keywords
312+
lib_deps_str = ' '.join(str(dep) for dep in lib_deps).upper()
313+
314+
bt_ble_keywords = ['BLE', 'BT', 'NIMBLE', 'BLUETOOTH']
315+
316+
for keyword in bt_ble_keywords:
317+
if keyword in lib_deps_str:
318+
return True
319+
320+
return False
321+
322+
except Exception:
323+
return False
324+
325+
def _is_bt_related_library(self, lib_name: str) -> bool:
326+
"""Check if a library name is related to Bluetooth/BLE functionality."""
327+
lib_name_upper = lib_name.upper()
328+
329+
bt_related_names = [
330+
'BT',
331+
'BLE',
332+
'BLUETOOTH',
333+
'NIMBLE',
334+
'ESP32_BLE',
335+
'ESP32BLE',
336+
'BLUETOOTHSERIAL',
337+
'BLE_ARDUINO',
338+
'ESP_BLE',
339+
'ESP_BT'
340+
]
341+
342+
for bt_name in bt_related_names:
343+
if bt_name in lib_name_upper:
344+
return True
345+
346+
return False
347+
300348
def _remove_ignored_lib_includes(self) -> None:
301349
"""Remove include entries for ignored libraries from pioarduino-build.py."""
302350
build_py_path = join(self.arduino_libs_mcu, "pioarduino-build.py")
303351

304352
if not os.path.exists(build_py_path):
305353
return
306354

355+
# Check if BT/BLE dependencies exist in lib_deps
356+
bt_ble_protected = self._has_bt_ble_dependencies()
357+
307358
try:
308359
with open(build_py_path, 'r') as f:
309360
content = f.read()
@@ -313,6 +364,11 @@ def _remove_ignored_lib_includes(self) -> None:
313364

314365
# Remove CPPPATH entries for each ignored library
315366
for lib_name in self.ignored_libs:
367+
# Skip BT-related libraries if BT/BLE dependencies are present
368+
if bt_ble_protected and self._is_bt_related_library(lib_name):
369+
print(f"Skipping removal of BT-related library '{lib_name}' due to BT/BLE dependency in lib_deps")
370+
continue
371+
316372
# Multiple patterns to catch different include formats
317373
patterns = [
318374
rf'.*join\([^,]*,\s*"include",\s*"{re.escape(lib_name)}"[^)]*\),?\n',

0 commit comments

Comments
 (0)