pico_btstack: use PICO_BTSTACK_PATH for compile_gatt.py #2950

Merged
anoshyn merged 1 commit from fix-btstack-compile-gatt-path into develop 2026-05-21 05:40:54 -05:00
anoshyn commented 2026-05-16 14:33:55 -05:00 (Migrated from github.com)

Summary

Fixes #2901. pico_btstack_make_gatt_header() in src/rp2_common/pico_btstack/CMakeLists.txt was invoking the bundled compile_gatt.py via ${PICO_SDK_PATH}/lib/btstack/tool/... even when the user had supplied an out-of-tree BTstack via -DPICO_BTSTACK_PATH=.... The rest of the file already routes everything (sources, include dirs, suppress-warnings list, etc.) through PICO_BTSTACK_PATH; only this one invocation didn't.

Switch the add_custom_command at line 342 to use ${PICO_BTSTACK_PATH}/tool/compile_gatt.py to match.

Compatibility

In the default case, PICO_BTSTACK_PATH is set to ${PICO_SDK_PATH}/lib/btstack (line 9 of the same file), so ${PICO_BTSTACK_PATH}/tool/compile_gatt.py resolves to exactly the same path the old code produced. The change is therefore a no-op for builds that don't override the variable.

For builds that do override it (the case the issue is about), the user's compile_gatt.py is now used as intended.

Test plan

  • grep -n 'PICO_SDK_PATH' src/rp2_common/pico_btstack/CMakeLists.txt: only line 9 (default for PICO_BTSTACK_PATH) and line 12 (submodule-init hint message) remain. No other stray references.
  • Full SDK build clean: cmake --build build for PICO_PLATFORM=rp2040 PICO_BOARD=pico. The SDK itself doesn't ship a GATT-using example, so the function definition is exercised only by configure; no in-tree behaviour change.
  • End-to-end test with an out-of-tree BTstack: details below.

End-to-end verification with an out-of-tree BTstack

Set up a separate BTstack root (/tmp/btstack-oot), a minimal consumer project that calls pico_btstack_make_gatt_header() on a tiny .gatt file, and configured with PICO_BOARD=pico2_w -DPICO_BTSTACK_PATH=/tmp/btstack-oot.

Configured twice: once with the file at origin/develop (no fix), once with this branch. The generated gatt_consumer_gatt_header build rule encodes the literal python3 <path>/compile_gatt.py ... command, so the path used is visible without running the command.

Generated command (compile_gatt.py path)
origin/develop (no fix) /home/andrii/pico-sdk/lib/btstack/tool/compile_gatt.py ← bundled, override ignored
this branch (fix) /tmp/btstack-oot/tool/compile_gatt.py ← user's PICO_BTSTACK_PATH respected

Then built the target on the fix branch: python3 runs from the override path, produces test.h, and the generated header self-documents the invocation in a comment - // To generate test.h: /tmp/btstack-oot/tool/compile_gatt.py ....

## Summary Fixes #2901. `pico_btstack_make_gatt_header()` in `src/rp2_common/pico_btstack/CMakeLists.txt` was invoking the bundled `compile_gatt.py` via `${PICO_SDK_PATH}/lib/btstack/tool/...` even when the user had supplied an out-of-tree BTstack via `-DPICO_BTSTACK_PATH=...`. The rest of the file already routes everything (sources, include dirs, suppress-warnings list, etc.) through `PICO_BTSTACK_PATH`; only this one invocation didn't. Switch the `add_custom_command` at line 342 to use `${PICO_BTSTACK_PATH}/tool/compile_gatt.py` to match. ## Compatibility In the default case, `PICO_BTSTACK_PATH` is set to `${PICO_SDK_PATH}/lib/btstack` (line 9 of the same file), so `${PICO_BTSTACK_PATH}/tool/compile_gatt.py` resolves to exactly the same path the old code produced. The change is therefore a no-op for builds that don't override the variable. For builds that *do* override it (the case the issue is about), the user's `compile_gatt.py` is now used as intended. ## Test plan - [x] `grep -n 'PICO_SDK_PATH' src/rp2_common/pico_btstack/CMakeLists.txt`: only line 9 (default for `PICO_BTSTACK_PATH`) and line 12 (submodule-init hint message) remain. No other stray references. - [x] Full SDK build clean: `cmake --build build` for `PICO_PLATFORM=rp2040 PICO_BOARD=pico`. The SDK itself doesn't ship a GATT-using example, so the function definition is exercised only by configure; no in-tree behaviour change. - [x] End-to-end test with an out-of-tree BTstack: details below. ### End-to-end verification with an out-of-tree BTstack Set up a separate BTstack root (`/tmp/btstack-oot`), a minimal consumer project that calls `pico_btstack_make_gatt_header()` on a tiny `.gatt` file, and configured with `PICO_BOARD=pico2_w -DPICO_BTSTACK_PATH=/tmp/btstack-oot`. Configured **twice**: once with the file at `origin/develop` (no fix), once with this branch. The generated `gatt_consumer_gatt_header` build rule encodes the literal `python3 <path>/compile_gatt.py ...` command, so the path used is visible without running the command. | | Generated command (compile_gatt.py path) | |---|---| | `origin/develop` (no fix) | `/home/andrii/pico-sdk/lib/btstack/tool/compile_gatt.py` ← bundled, override ignored | | this branch (fix) | `/tmp/btstack-oot/tool/compile_gatt.py` ← user's `PICO_BTSTACK_PATH` respected | Then built the target on the fix branch: `python3` runs from the override path, produces `test.h`, and the generated header self-documents the invocation in a comment - `// To generate test.h: /tmp/btstack-oot/tool/compile_gatt.py ...`.
peterharperuk commented 2026-05-18 11:10:42 -05:00 (Migrated from github.com)

I've fixed this internally - but it hasn't made it to the develop branch.
Please remove "Co-Authored-By: Claude" line.

I've fixed this internally - but it hasn't made it to the develop branch. Please remove "Co-Authored-By: Claude" line.
anoshyn commented 2026-05-18 14:17:41 -05:00 (Migrated from github.com)

Force-pushed to drop the Co-Authored-By trailer. New HEAD: ea7d803c.

Force-pushed to drop the `Co-Authored-By` trailer. New HEAD: ea7d803c.
kilograham (Migrated from github.com) approved these changes 2026-05-20 17:25:21 -05:00
kilograham commented 2026-05-20 17:25:45 -05:00 (Migrated from github.com)

@peterharperuk please merge if u r happy

@peterharperuk please merge if u r happy
peterharperuk (Migrated from github.com) approved these changes 2026-05-21 05:40:31 -05:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!2950
No description provided.