Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel build: Fix compilation bugs for Pico-W support #1797

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions src/rp2_common/pico_cyw43_driver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,55 @@ cc_library(
cc_library(
name = "pico_cyw43_driver",
srcs = [
"btstack_chipset_cyw43.c",
"btstack_cyw43.c",
"btstack_hci_transport_cyw43.c",
"cyw43_bus_pio_spi.c",
"cyw43_driver.c",
],
hdrs = [
"include/pico/btstack_chipset_cyw43.h",
"include/pico/btstack_cyw43.h",
"include/pico/btstack_hci_transport_cyw43.h",
"include/pico/cyw43_driver.h",
],
includes = ["include"],
target_compatible_with = compatible_with_pico_w(),
deps = [
":cyw43_bus_pio",
":cyw43_configport",
"//bazel/config:PICO_BTSTACK_CONFIG",
"//src/rp2_common:pico_platform",
"//src/rp2_common/hardware_clocks",
"//src/rp2_common/hardware_dma",
"//src/rp2_common/hardware_irq",
"//src/rp2_common/hardware_pio",
"//src/rp2_common/hardware_sync",
"//src/rp2_common/pico_async_context",
"//src/rp2_common/pico_unique_id",
"@cyw43-driver//:cyw43_driver",
] +
# Only depend on the btstack if its configuration is set up.
select({
"//bazel/constraint:pico_btstack_config_unset": [],
"//conditions:default": [":pico_cyw43_btstack"],
}),
)

cc_library(
name = "pico_cyw43_btstack",
srcs = [
"btstack_chipset_cyw43.c",
"btstack_cyw43.c",
"btstack_hci_transport_cyw43.c",
],
hdrs = [
"include/pico/btstack_chipset_cyw43.h",
"include/pico/btstack_cyw43.h",
"include/pico/btstack_hci_transport_cyw43.h",
],
includes = ["include"],
deps = [
":cyw43_bus_pio",
":cyw43_configport",
"//bazel/config:PICO_BTSTACK_CONFIG",
"//src/rp2_common/pico_btstack:btstack_run_loop_async_context",
"//src/rp2_common/pico_btstack:pico_btstack_base",
"//src/rp2_common/pico_btstack:pico_btstack_flash_bank",
"//src/rp2_common/pico_unique_id",
"//src/rp2_common/pico_cyw43_driver/cybt_shared_bus:cybt_shared_bus_driver",
"@cyw43-driver//:cyw43_driver",
],
)
Expand Down
9 changes: 8 additions & 1 deletion src/rp2_common/pico_cyw43_driver/cyw43-driver.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ cc_library(
"src/cyw43_stats.c",
],
hdrs = glob(["**/*.h"]),
defines = ["CYW43_ENABLE_BLUETOOTH=1"],
defines = select({
"@pico-sdk//bazel/constraint:pico_btstack_config_unset": [
"CYW43_ENABLE_BLUETOOTH=0",
],
"//conditions:default": [
"CYW43_ENABLE_BLUETOOTH=1",
],
}),
includes = [
"firmware",
"src",
Expand Down
36 changes: 27 additions & 9 deletions src/rp2_common/pico_lwip/lwip.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@ load("@pico-sdk//bazel:defs.bzl", "incompatible_with_config")

package(default_visibility = ["//visibility:public"])

# Some of the LWIP sys_arch.h and the lwip headers depend circularly on one
# another. Include them all in the same target.
cc_library(
name = "pico_lwip_headers",
hdrs = glob(["**/*.h"]),
includes = [
"contrib/ports/freertos/include/arch",
"src/include",
],
deps = [
"@pico-sdk//bazel/config:PICO_LWIP_CONFIG",
"@pico-sdk//src/rp2_common/pico_lwip:pico_lwip_config",
],
visibility = ["//visibility:private"],
)
jaguilar marked this conversation as resolved.
Show resolved Hide resolved

cc_library(
name = "pico_lwip_core",
srcs = glob(["src/core/*.c"]),
hdrs = glob(["**/*.h"]),
includes = ["src/include"],
target_compatible_with = incompatible_with_config(
"@pico-sdk//bazel/constraint:pico_lwip_config_unset",
),
deps = [
"@pico-sdk//bazel/config:PICO_LWIP_CONFIG",
"@pico-sdk//src/rp2_common/pico_lwip:pico_lwip_config",
],
":pico_lwip_headers",
] + select({
"@pico-sdk//bazel/constraint:pico_freertos_unset": [],
"//conditions:default": [
":pico_lwip_contrib_freertos",
],
}),
)

cc_library(
Expand Down Expand Up @@ -151,13 +169,13 @@ cc_library(

cc_library(
name = "pico_lwip_contrib_freertos",
srcs = ["ports/freertos/sys_arch.c"],
includes = ["ports/freertos/include"],
srcs = ["contrib/ports/freertos/sys_arch.c"],
includes = ["contrib/ports/freertos/include"],
target_compatible_with = incompatible_with_config(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May also need hdrs = ["contrib/ports/freertos/include/arch/sys_arch.h"],

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That header is probably getting picked up by the glob pattern in pico_lwip_core, so it might work without this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't working with or without, so I reverted this change for some more investigation.

"@pico-sdk//bazel/constraint:pico_freertos_unset",
),
deps = [
":pico_lwip_core",
"//bazel/config:PICO_FREERTOS_LIB",
":pico_lwip_headers",
"@pico-sdk//bazel/config:PICO_FREERTOS_LIB",
],
)
Loading