Skip to content

Commit

Permalink
Add Bazel label flag for overriding tusb_config.h
Browse files Browse the repository at this point in the history
This adds `//bazel/config:PICO_TINYUSB_CONFIG`, which is used to select
which tusb_config.h gets linked into the tinyUSB port. This defaults to
the tusb_config.h from the pico_stdio_usb (same as before), but allows
Bazel users to override this config with their own.
  • Loading branch information
mbrase committed Feb 18, 2025
1 parent c757f36 commit 1bf7317
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions bazel/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ int_flag(
build_setting_default = 0,
)

# PICO_BAZEL_CONFIG: PICO_TINYUSB_CONFIG, [Bazel only] The library that provides TinyUSB config header (e.g. tusb_config.h), default=//src/rp2_common/pico_stdio_usb:tusb_config, group=build
label_flag(
name = "PICO_TINYUSB_CONFIG",
build_setting_default = "//src/rp2_common/pico_stdio_usb:tusb_config",
)

# PICO_BAZEL_CONFIG: PICO_TINYUSB_LIB, [Bazel only] The library that provides TinyUSB, default=@tinyusb//:tinyusb, group=build
label_flag(
name = "PICO_TINYUSB_LIB",
Expand Down
7 changes: 3 additions & 4 deletions src/rp2_common/pico_stdio_usb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ cc_library(
hdrs = ["include/tusb_config.h"],
includes = ["include"],
target_compatible_with = compatible_with_rp2(),
deps = [
":pico_stdio_usb_headers",
],
)

pico_sdk_define(
Expand All @@ -43,10 +46,6 @@ cc_library(
hdrs = ["include/pico/stdio_usb.h"],
includes = ["include"],
target_compatible_with = compatible_with_rp2(),
visibility = [
":__pkg__",
"//src/rp2_common/tinyusb:__pkg__",
],
deps = [
":LIB_PICO_STDIO_USB",
":PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS",
Expand Down
2 changes: 1 addition & 1 deletion src/rp2_common/tinyusb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cc_library(
includes = ["include"],
target_compatible_with = compatible_with_rp2(),
deps = [
"//bazel/config:PICO_TINYUSB_CONFIG",
"//src/common/pico_binary_info",
"//src/common/pico_stdlib_headers",
"//src/common/pico_sync",
Expand All @@ -30,7 +31,6 @@ cc_library(
"//src/rp2_common/pico_stdio_semihosting",
"//src/rp2_common/pico_stdio_uart",
"//src/rp2_common/pico_stdio_usb:pico_stdio_usb_headers",
"//src/rp2_common/pico_stdio_usb:tusb_config",
"//src/rp2_common/pico_unique_id",
],
)

0 comments on commit 1bf7317

Please sign in to comment.