1load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag")
2
3package(default_visibility = ["//visibility:public"])
4
5# PICO_BAZEL_CONFIG: PICO_TOOLCHAIN, The toolchain to use, type=string, default=gcc, group=build
6string_flag(
7    name = "PICO_TOOLCHAIN",
8    build_setting_default = "gcc",
9    values = [
10        "gcc",
11        "clang",
12    ],
13)
14
15# PICO_BAZEL_CONFIG: PICO_BOARD, Board name being built for, type=string, default=pico or pico2, group=build, docref=cmake-platform-board-config
16string_flag(
17    name = "PICO_BOARD",
18    build_setting_default = "pico",
19)
20
21# PICO_BAZEL_CONFIG: PICO_BARE_METAL, Flag to exclude anything except base headers from the build, type=bool, default=0, group=build
22bool_flag(
23    name = "PICO_BARE_METAL",
24    build_setting_default = False,
25)
26
27# PICO_BAZEL_CONFIG: PICO_NO_GC_SECTIONS, Disable `-ffunction-sections` `-fdata-sections` and `--gc-sections`, type=bool, default=0, advanced=true, group=pico_standard_link
28bool_flag(
29    name = "PICO_NO_GC_SECTIONS",
30    build_setting_default = False,
31)
32
33# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2_FILE, Boot stage 2 file to use; this should point to a filegroup with the .S file to use, type=string, group=build
34label_flag(
35    name = "PICO_DEFAULT_BOOT_STAGE2_FILE",
36    build_setting_default = "//src/rp2_common:build_selected_boot2",
37)
38
39# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2, Simpler alternative to specifying PICO_DEFAULT_BOOT_STAGE2_FILE where the latter is set to src/rp2_common/boot_stage2/{PICO_DEFAULT_BOOT_STAGE2}.S, type=string, default=compile_time_choice, group=build
40string_flag(
41    name = "PICO_DEFAULT_BOOT_STAGE2",
42    build_setting_default = "compile_time_choice",
43)
44
45# PICO_BAZEL_CONFIG: PICO_BOOT_STAGE2_LINK_IMAGE, [Bazel only] The final boot_stage2 image target to link in. Use this to fully override/replace boot_stage2, default=@pico-sdk//src/rp2_common:boot_stage2, group=build
46label_flag(
47    name = "PICO_BOOT_STAGE2_LINK_IMAGE",
48    build_setting_default = "//src/rp2_common:boot_stage2",
49)
50
51# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_EXCEPTIONS, Enable CXX exception handling, type=bool, default=0, group=pico_cxx_options
52bool_flag(
53    name = "PICO_CXX_ENABLE_EXCEPTIONS",
54    build_setting_default = False,
55)
56
57# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_RTTI, Enable CXX rtti, type=bool, default=0, group=pico_cxx_options
58bool_flag(
59    name = "PICO_CXX_ENABLE_RTTI",
60    build_setting_default = False,
61)
62
63# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_CXA_ATEXIT, Enable cxa-atexit, type=bool, default=0, group=pico_cxx_options
64bool_flag(
65    name = "PICO_CXX_ENABLE_CXA_ATEXIT",
66    build_setting_default = False,
67)
68
69# PICO_BAZEL_CONFIG: PICO_STDIO_UART, Option to globally enable stdio UART for all targets by default, type=bool, default=1, group=pico_stdlib
70bool_flag(
71    name = "PICO_STDIO_UART",
72    build_setting_default = True,
73)
74
75# PICO_BAZEL_CONFIG: PICO_DEFAULT_UART_BAUD_RATE, Define the default UART baudrate, type=int, max=921600, default=115200, group=hardware_uart
76int_flag(
77    name = "PICO_DEFAULT_UART_BAUD_RATE",
78    build_setting_default = 115200,
79)
80
81# PICO_BAZEL_CONFIG: PICO_STDIO_USB, Option to globally enable stdio USB for all targets by default, type=bool, default=0, group=pico_stdlib
82bool_flag(
83    name = "PICO_STDIO_USB",
84    build_setting_default = False,
85)
86
87# PICO_BAZEL_CONFIG: PICO_STDIO_SEMIHOSTING, Option to globally enable stdio semi-hosting for all targets by default, type=bool, default=0, group=pico_stdlib
88bool_flag(
89    name = "PICO_STDIO_SEMIHOSTING",
90    build_setting_default = False,
91)
92
93# PICO_BAZEL_CONFIG: PICO_STDIO_RTT, Option to globally enable stdio RTT for all targets by default, type=bool, default=0, group=pico_stdlib
94bool_flag(
95    name = "PICO_STDIO_RTT",
96    build_setting_default = False,
97)
98
99# PICO_BAZEL_CONFIG: PICO_MULTICORE_ENABLED, OPTION: Enable multicore handling, type=bool, default=1, group=pico_stdlib
100bool_flag(
101    name = "PICO_MULTICORE_ENABLED",
102    build_setting_default = True,
103)
104
105# PICO_BAZEL_CONFIG: PICO_DEFAULT_DOUBLE_IMPL, The default implementation for pico_double to link. auto selects an appropriate default for the current platform. rp2040 is only supported on the rp2040. dcp is only supported on rp2350, type=string, default=auto, group=build
106string_flag(
107    name = "PICO_DEFAULT_DOUBLE_IMPL",
108    build_setting_default = "auto",
109    values = [
110        "auto",
111        "compiler",
112        "dcp",
113        "rp2040",
114        "none",
115    ],
116)
117
118# PICO_BAZEL_CONFIG: PICO_DEFAULT_FLOAT_IMPL, The default implementation for pico_float to link. auto selects an appropriate default for the current platform. rp2040 is only supported on the rp2040. vfp and dcp are only supported on rp2350, type=string, default=auto, group=build
119string_flag(
120    name = "PICO_DEFAULT_FLOAT_IMPL",
121    build_setting_default = "auto",
122    values = [
123        "auto",
124        "compiler",
125        "dcp",
126        "rp2040",
127        "vfp",
128        "none",
129    ],
130)
131
132# PICO_BAZEL_CONFIG: PICO_DEFAULT_DIVIDER_IMPL, The default implementation for pico_divider to link. hardware uses accelerated divide instructions while compiler allows the compiler to decide how to handle divide instructions. auto uses the platform default (hardware on RP2040 and compiler on RP2350), type=string, default=auto, group=build
133string_flag(
134    name = "PICO_DEFAULT_DIVIDER_IMPL",
135    build_setting_default = "auto",
136    values = [
137        "auto",
138        "hardware",
139        "compiler",
140    ],
141)
142
143# PICO_BAZEL_CONFIG: PICO_DEFAULT_PRINTF_IMPL, The default implementation for pico_printf to link. compiler lets the compiler control printf behavior while pico provides a pico-specific implementation, type=string, default=double, group=build
144string_flag(
145    name = "PICO_DEFAULT_PRINTF_IMPL",
146    build_setting_default = "pico",
147    values = [
148        "pico",
149        "compiler",
150        "none",
151    ],
152)
153
154# PICO_BAZEL_CONFIG: PICO_ASYNC_CONTEXT_IMPL, The default implementation for pico_async_context to link, type=string, default=threadsafe_background, group=build
155string_flag(
156    name = "PICO_ASYNC_CONTEXT_IMPL",
157    build_setting_default = "threadsafe_background",
158    values = [
159        "poll",
160        "threadsafe_background",
161        "freertos",
162    ],
163)
164
165# PICO_BAZEL_CONFIG: PICO_BINARY_INFO_ENABLED, Whether to include binary info in final firmware, type=bool, default=1, group=pico_stdlib
166bool_flag(
167    name = "PICO_BINARY_INFO_ENABLED",
168    build_setting_default = True,
169)
170
171# PICO_BAZEL_CONFIG: PICO_CMSIS_PATH, Label of a cc_ibrary providing CMSIS core,  type=string, default="included stub CORE only impl", group=build
172label_flag(
173    name = "PICO_CMSIS_PATH",
174    build_setting_default = "//src/rp2_common/cmsis:cmsis_core",
175)
176
177# PICO_BAZEL_CONFIG: PICO_USE_DEFAULT_MAX_PAGE_SIZE, Don't shrink linker max page to 4096, type=bool, default=0, advanced=true, group=pico_standard_link
178bool_flag(
179    name = "PICO_USE_DEFAULT_MAX_PAGE_SIZE",
180    build_setting_default = False,
181)
182
183# PICO_BAZEL_CONFIG: PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS, Maximum number of milliseconds to wait during initialization for a CDC connection from the host (negative means indefinite) during initialization, type=int, default=0, group=pico_stdio_usb
184int_flag(
185    name = "PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS",
186    build_setting_default = 0,
187)
188
189# PICO_BAZEL_CONFIG: PICO_TINYUSB_LIB, [Bazel only] The library that provides TinyUSB, default=@tinyusb//:tinyusb, group=build
190label_flag(
191    name = "PICO_TINYUSB_LIB",
192    build_setting_default = "@tinyusb//:tinyusb",
193)
194
195# TODO: Bazel build for mbedtls at @mbedtls//:mbedtls.
196# PICO_BAZEL_CONFIG: PICO_MBEDTLS_LIB, [Bazel only] The library that provides mbedtls, default=@mbedtls//:mbedtls, group=build
197label_flag(
198    name = "PICO_MBEDTLS_LIB",
199    build_setting_default = "//bazel:incompatible_cc_lib",
200)
201
202# PICO_BAZEL_CONFIG: PICO_DEFAULT_BINARY_INFO, [Bazel only] The library that provides custom_pico_binary_info to link into all binaries, default=//src/rp2_common/pico_standard_binary_info:default_binary_info, group=pico_standard_link
203label_flag(
204    name = "PICO_DEFAULT_BINARY_INFO",
205    build_setting_default = "//src/rp2_common/pico_standard_binary_info:default_binary_info",
206)
207
208# PICO_BAZEL_CONFIG: PICO_BAZEL_BUILD_TYPE, The type of build (e.g. Debug or Release) to embed in binary info, type=string, default=pico, group=build
209string_flag(
210    name = "PICO_BAZEL_BUILD_TYPE",
211    build_setting_default = "Debug",
212)
213
214# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_crt0:default_linker_script, group=pico_standard_link
215label_flag(
216    name = "PICO_DEFAULT_LINKER_SCRIPT",
217    build_setting_default = "//src/rp2_common/pico_crt0:default_linker_script",
218)
219
220# PICO_BAZEL_CONFIG: PICO_NO_TARGET_NAME, Don't define PICO_TARGET_NAME, type=bool, default=0, group=build
221bool_flag(
222    name = "PICO_NO_TARGET_NAME",
223    build_setting_default = False,
224)
225
226# PICO_BAZEL_CONFIG: PICO_CONFIG_EXTRA_HEADER, [Bazel only] The cc_library that provides "pico_config_extra_headers.h", default=//bazel:no_extra_headers, group=pico_base
227label_flag(
228    name = "PICO_CONFIG_EXTRA_HEADER",
229    build_setting_default = "//bazel:no_extra_headers",
230)
231
232# PICO_BAZEL_CONFIG: PICO_CONFIG_PLATFORM_HEADER, [Bazel only] The cc_library that provides "pico_config_platform_headers.h" and defines PICO_BOARD, default=//src/common/pico_base_headers:default_platform_headers, group=pico_base
233label_flag(
234    name = "PICO_CONFIG_PLATFORM_HEADER",
235    build_setting_default = "//src/boards:default",
236)
237
238# PICO_BAZEL_CONFIG: PICO_CONFIG_HEADER, [Bazel only] The cc_library that defines PICO_CONFIG_HEADER or pico/config_autogen.h and other SDK critical defines (overrides PICO_BOARD setting), default=//bazel:generate_config_header, group=pico_base
239label_flag(
240    name = "PICO_CONFIG_HEADER",
241    build_setting_default = "//bazel:generate_config_header",
242)
243
244# PICO_BAZEL_CONFIG: PICO_CLIB, [Bazel only] The flavor of libc porting layer to use. auto infers the correct value to use from PICO_TOOLCHAIN, group=pico_standard_link
245string_flag(
246    name = "PICO_CLIB",
247    build_setting_default = "auto",
248    values = [
249        "auto",
250        "llvm_libc",
251        "newlib",
252        "picolibc",
253    ],
254)
255
256# PICO_BAZEL_CONFIG: PICO_BTSTACK_CONFIG, [Bazel only] The cc_library that provides btstack_config.h, default=//bazel:empty_cc_lib, group=wireless
257label_flag(
258    name = "PICO_BTSTACK_CONFIG",
259    build_setting_default = "//bazel:empty_cc_lib",
260)
261
262# PICO_BAZEL_CONFIG: PICO_BT_ENABLE_BLE, [Bazel only] Whether or not to link in BLE portions of the btstack as part of //src/rp2_common/pico_btstack. Also defines ENABLE_BLE=1, type=bool, default=False, group=wireless
263bool_flag(
264    name = "PICO_BT_ENABLE_BLE",
265    build_setting_default = False,
266)
267
268# PICO_BAZEL_CONFIG: PICO_BT_ENABLE_CLASSIC, [Bazel only] Whether or not to link in classic BT portions of the btstack as part of //src/rp2_common/pico_btstack. Also defines ENABLE_CLASSIC=1, type=bool, default=False, group=wireless
269bool_flag(
270    name = "PICO_BT_ENABLE_CLASSIC",
271    build_setting_default = False,
272)
273
274# PICO_BAZEL_CONFIG: PICO_BT_ENABLE_MESH, [Bazel only] Whether or not to link in mesh BT portions of the btstack as part of //src/rp2_common/pico_btstack. Also defines ENABLE_MESH=1, type=bool, default=False, group=wireless
275bool_flag(
276    name = "PICO_BT_ENABLE_MESH",
277    build_setting_default = False,
278)
279
280# PICO_BAZEL_CONFIG: PICO_LWIP_CONFIG, [Bazel only] The cc_library that provides lwipopts.h, default=//bazel:empty_cc_lib, group=wireless
281label_flag(
282    name = "PICO_LWIP_CONFIG",
283    build_setting_default = "//bazel:empty_cc_lib",
284)
285
286# PICO_BAZEL_CONFIG: PICO_FREERTOS_LIB, [Bazel only] The cc_library that provides FreeRTOS, default=//bazel:empty_cc_lib, group=wireless
287label_flag(
288    name = "PICO_FREERTOS_LIB",
289    build_setting_default = "//bazel:empty_cc_lib",
290)
291