Skip to content

Commit af518de

Browse files
authored
add missing libraries to test/kitchen_sink and auto-gen includes (#2567)
* add missing libraries to test/kitchen_sink and auto-gen includes * bazel fix
1 parent d32d315 commit af518de

File tree

2 files changed

+78
-139
lines changed

2 files changed

+78
-139
lines changed

test/kitchen_sink/CMakeLists.txt

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,32 @@ add_library(kitchen_sink_libs INTERFACE)
22

33
set(KITCHEN_SINK_LIBS
44
hardware_adc
5+
hardware_boot_lock
6+
hardware_claim
57
hardware_clocks
8+
hardware_dcp
69
hardware_divider
710
hardware_dma
811
hardware_exception
912
hardware_flash
1013
hardware_gpio
14+
hardware_hazard3
1115
hardware_i2c
1216
hardware_interp
1317
hardware_irq
1418
hardware_pio
15-
hardware_powman
1619
hardware_pll
20+
hardware_powman
1721
hardware_pwm
22+
hardware_rcp
1823
hardware_resets
24+
hardware_riscv
25+
hardware_riscv_platform_timer
1926
hardware_rtc
27+
hardware_sha256
2028
hardware_spi
2129
hardware_sync
30+
hardware_sync_spin_lock
2231
hardware_ticks
2332
hardware_timer
2433
hardware_uart
@@ -41,25 +50,60 @@ set(KITCHEN_SINK_LIBS
4150
pico_mem_ops
4251
pico_multicore
4352
pico_platform
53+
pico_printf
4454
pico_rand
55+
pico_runtime
56+
pico_runtime_init
4557
pico_sha256
58+
pico_stdio
4659
pico_stdlib
4760
pico_sync
4861
pico_time
4962
pico_unique_id
5063
pico_util
5164
)
5265

66+
set(KITCHEN_SINK_NO_HEADER_LIBS
67+
hardware_dcp
68+
pico_bootsel_via_double_reset
69+
pico_int64_ops # currently empty, and only included by _pico variant
70+
pico_mem_ops # currently empty, and only included by _pico variant
71+
)
72+
73+
set(KITCHEN_SINK_INCLUDES "#pragma once\n")
5374
foreach(LIB IN LISTS KITCHEN_SINK_LIBS)
5475
if (TARGET ${LIB})
5576
target_link_libraries(kitchen_sink_libs INTERFACE ${LIB})
77+
string(REGEX MATCH "([a-z]+)_(.+)" HAS_MATCH ${LIB})
78+
if (HAS_MATCH AND NOT LIB IN_LIST KITCHEN_SINK_NO_HEADER_LIBS)
79+
# these are few, so just hack fixing for now
80+
if (LIB STREQUAL "pico_util")
81+
string(APPEND KITCHEN_SINK_INCLUDES "#include \"pico/util/datetime.h\"\n")
82+
string(APPEND KITCHEN_SINK_INCLUDES "#include \"pico/util/pheap.h\"\n")
83+
string(APPEND KITCHEN_SINK_INCLUDES "#include \"pico/util/queue.h\"\n")
84+
else()
85+
if ("${CMAKE_MATCH_2}" STREQUAL "fix_rp2040_usb_device_enumeration")
86+
set(CMAKE_MATCH_2 "fix/rp2040_usb_device_enumeration")
87+
elseif ("${CMAKE_MATCH_2}" STREQUAL "sync_spin_lock")
88+
set(CMAKE_MATCH_2 "sync/spin_lock")
89+
endif()
90+
string(APPEND KITCHEN_SINK_INCLUDES "#include \"${CMAKE_MATCH_1}/${CMAKE_MATCH_2}.h\"\n")
91+
endif()
92+
endif()
5693
endif()
5794
endforeach ()
95+
set(KITCHEN_SINK_INCLUDE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kitchen_sink_includes.h")
96+
file(GENERATE OUTPUT ${KITCHEN_SINK_INCLUDE_HEADER} CONTENT ${KITCHEN_SINK_INCLUDES})
5897

5998
add_library(kitchen_sink_options INTERFACE)
6099

61-
target_compile_options(kitchen_sink_options INTERFACE
100+
if (NOT KITCHEN_SINK_NO_WERROR)
101+
target_compile_options(kitchen_sink_options INTERFACE
62102
-Werror
103+
)
104+
endif()
105+
106+
target_compile_options(kitchen_sink_options INTERFACE
63107
-Wall
64108
-Wextra
65109
# -pedantic
@@ -97,6 +141,7 @@ target_compile_definitions(kitchen_sink_libs INTERFACE
97141
PICO_FORBID_ARM_HEADERS_ON_RISCV=1
98142
PARAM_ASSERTIONS_ENABLE_ALL=1 # want to check all the assertions for compilation warnings
99143
PICO_AUDIO_DMA_IRQ=1
144+
KITCHEN_SINK_INCLUDE_HEADER="${KITCHEN_SINK_INCLUDE_HEADER}"
100145
)
101146

102147
add_executable(kitchen_sink ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c)
@@ -147,25 +192,27 @@ target_link_libraries(kitchen_sink_printf_none kitchen_sink_libs kitchen_sink_op
147192
pico_add_extra_outputs(kitchen_sink_printf_none)
148193
pico_set_printf_implementation(kitchen_sink_printf_none none)
149194

150-
add_executable(kitchen_sink_copy_to_ram ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c)
151-
pico_set_binary_type(kitchen_sink_copy_to_ram copy_to_ram)
152-
target_link_libraries(kitchen_sink_copy_to_ram kitchen_sink_libs kitchen_sink_options)
153-
pico_add_extra_outputs(kitchen_sink_copy_to_ram)
154-
target_compile_definitions(kitchen_sink_copy_to_ram PRIVATE KITCHEN_SINK_ID="copy-to-ram binary")
155-
156-
add_executable(kitchen_sink_no_flash ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c)
157-
pico_set_binary_type(kitchen_sink_no_flash no_flash)
158-
target_link_libraries(kitchen_sink_no_flash kitchen_sink_libs kitchen_sink_options)
159-
pico_add_extra_outputs(kitchen_sink_no_flash)
160-
target_compile_definitions(kitchen_sink_no_flash PRIVATE KITCHEN_SINK_ID="no-flash binary")
161-
162-
if (NOT PICO_RP2350)
163-
# RP2350 does not have blocked ram
164-
add_executable(kitchen_sink_blocked_ram ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c)
165-
pico_set_binary_type(kitchen_sink_blocked_ram blocked_ram)
166-
target_link_libraries(kitchen_sink_blocked_ram kitchen_sink_libs kitchen_sink_options)
167-
pico_add_extra_outputs(kitchen_sink_blocked_ram)
168-
target_compile_definitions(kitchen_sink_blocked_ram PRIVATE KITCHEN_SINK_ID="blocked-ram binary")
195+
if (NOT KITCHEN_SINK_NO_BINARY_TYPE_VARIANTS)
196+
add_executable(kitchen_sink_copy_to_ram ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c)
197+
pico_set_binary_type(kitchen_sink_copy_to_ram copy_to_ram)
198+
target_link_libraries(kitchen_sink_copy_to_ram kitchen_sink_libs kitchen_sink_options)
199+
pico_add_extra_outputs(kitchen_sink_copy_to_ram)
200+
target_compile_definitions(kitchen_sink_copy_to_ram PRIVATE KITCHEN_SINK_ID="copy-to-ram binary")
201+
202+
add_executable(kitchen_sink_no_flash ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c)
203+
pico_set_binary_type(kitchen_sink_no_flash no_flash)
204+
target_link_libraries(kitchen_sink_no_flash kitchen_sink_libs kitchen_sink_options)
205+
pico_add_extra_outputs(kitchen_sink_no_flash)
206+
target_compile_definitions(kitchen_sink_no_flash PRIVATE KITCHEN_SINK_ID="no-flash binary")
207+
208+
if (PICO_RP2040)
209+
# RP2040 has blocked ram
210+
add_executable(kitchen_sink_blocked_ram ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c)
211+
pico_set_binary_type(kitchen_sink_blocked_ram blocked_ram)
212+
target_link_libraries(kitchen_sink_blocked_ram kitchen_sink_libs kitchen_sink_options)
213+
pico_add_extra_outputs(kitchen_sink_blocked_ram)
214+
target_compile_definitions(kitchen_sink_blocked_ram PRIVATE KITCHEN_SINK_ID="blocked-ram binary")
215+
endif()
169216
endif()
170217

171218
add_executable(kitchen_sink_cpp ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink_cpp.cpp)

test/kitchen_sink/kitchen_sink.c

Lines changed: 10 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -5,134 +5,26 @@
55
*/
66

77
#include <stdio.h>
8-
// Include all headers to check for compiler warnings
9-
#include "hardware/adc.h"
10-
#include "hardware/claim.h"
11-
#include "hardware/clocks.h"
12-
#include "hardware/divider.h"
8+
9+
#ifndef KITCHEN_SINK_INCLUDE_HEADER
10+
// provided for backwards compatibility for non CMake build systems - just includes enough to compile
1311
#include "hardware/dma.h"
14-
#include "hardware/exception.h"
15-
#include "hardware/flash.h"
16-
#include "hardware/gpio.h"
17-
#include "hardware/i2c.h"
18-
#include "hardware/interp.h"
19-
#include "hardware/irq.h"
20-
#include "hardware/pio.h"
21-
#include "hardware/pio_instructions.h"
22-
#include "hardware/pll.h"
23-
#include "hardware/pwm.h"
24-
#include "hardware/resets.h"
25-
#if PICO_RP2040
26-
#include "hardware/rtc.h"
27-
#endif
28-
#if !PICO_RP2040
29-
#include "hardware/sha256.h"
30-
#endif
31-
#include "hardware/spi.h"
32-
#include "hardware/sync.h"
33-
#include "hardware/timer.h"
34-
#include "hardware/ticks.h"
35-
#include "hardware/uart.h"
36-
#include "hardware/vreg.h"
37-
#include "hardware/watchdog.h"
38-
#include "hardware/xosc.h"
39-
#include "pico/aon_timer.h"
40-
#include "pico/binary_info.h"
41-
#include "pico/bit_ops.h"
42-
#include "pico/bootrom.h"
43-
#if LIB_PICO_CYW43_ARCH
44-
#include "pico/cyw43_arch.h"
45-
#endif
46-
#include "pico/divider.h"
47-
// todo we should have this but right now double.h is only present with double_implementation == pico
48-
#if PICO_RP2040
49-
#include "pico/double.h"
50-
#endif
51-
#include "pico/fix/rp2040_usb_device_enumeration.h"
52-
#include "pico/flash.h"
53-
// todo we should have this but right now float.h is only present with float_implementation == pico
54-
#if PICO_RP2040
55-
#include "pico/float.h"
56-
#endif
57-
#include "pico/i2c_slave.h"
58-
#if LIB_PICO_INT64_OPS_PICO
59-
#include "pico/int64_ops.h"
60-
#endif
61-
#include "pico/malloc.h"
62-
#include "pico/multicore.h"
63-
#include "pico/platform.h"
64-
#include "pico/printf.h"
65-
#include "pico/rand.h"
66-
#include "pico/runtime.h"
67-
#if LIB_PICO_SHA256
68-
#include "pico/sha256.h"
69-
#endif
70-
#include "pico/stdio.h"
71-
#include "pico/stdlib.h"
7212
#include "pico/sync.h"
73-
#include "pico/time.h"
74-
#include "pico/unique_id.h"
75-
#include "pico/util/datetime.h"
76-
#include "pico/util/pheap.h"
77-
#include "pico/util/queue.h"
78-
79-
#include "hardware/structs/adc.h"
80-
#include "hardware/structs/busctrl.h"
81-
#include "hardware/structs/clocks.h"
82-
#include "hardware/structs/dma.h"
83-
#include "hardware/structs/i2c.h"
84-
#include "hardware/structs/interp.h"
85-
#include "hardware/structs/io_bank0.h"
86-
#include "hardware/structs/io_qspi.h"
87-
#ifndef __riscv
88-
#include "hardware/structs/mpu.h"
89-
#include "hardware/structs/nvic.h"
90-
#endif
91-
#include "hardware/structs/pads_bank0.h"
92-
#include "hardware/structs/pads_qspi.h"
93-
#include "hardware/structs/pio.h"
94-
#include "hardware/structs/pll.h"
95-
#if PICO_RP2350
96-
#include "hardware/structs/powman.h"
97-
#endif
98-
#include "hardware/structs/psm.h"
99-
#include "hardware/structs/pwm.h"
100-
#include "hardware/structs/resets.h"
101-
#include "hardware/structs/rosc.h"
102-
#if PICO_RP2040
103-
#include "hardware/structs/rtc.h"
104-
#endif
105-
#ifndef __riscv
106-
#include "hardware/structs/scb.h"
107-
#endif
108-
#include "hardware/structs/sio.h"
109-
#if !PICO_RP2040
110-
#include "hardware/structs/sha256.h"
111-
#endif
112-
#include "hardware/structs/spi.h"
113-
#if PICO_RP2040
114-
#include "hardware/structs/ssi.h"
115-
#endif
116-
#include "hardware/structs/syscfg.h"
117-
#ifndef __riscv
118-
#include "hardware/structs/systick.h"
13+
#include "pico/stdlib.h"
14+
#if LIB_PICO_BINARY_INFO
15+
#include "pico/binary_info.h"
11916
#endif
120-
#include "hardware/structs/timer.h"
121-
#include "hardware/structs/uart.h"
122-
#include "hardware/structs/usb.h"
123-
#if PICO_RP2040
124-
#include "hardware/structs/vreg_and_chip_reset.h"
17+
#else
18+
#include KITCHEN_SINK_INCLUDE_HEADER
12519
#endif
126-
#include "hardware/structs/watchdog.h"
127-
#include "hardware/structs/xip_ctrl.h"
128-
#include "hardware/structs/xosc.h"
12920

13021
#if LIB_PICO_MBEDTLS
13122
#include "mbedtls/ssl.h"
13223
#include "lwip/altcp_tcp.h"
13324
#include "lwip/altcp_tls.h"
13425
#endif
13526

27+
#if LIB_PICO_BINARY_INFO
13628
bi_decl(bi_block_device(
13729
BINARY_INFO_MAKE_TAG('K', 'S'),
13830
"foo",
@@ -141,6 +33,7 @@ bi_decl(bi_block_device(
14133
NULL,
14234
BINARY_INFO_BLOCK_DEV_FLAG_READ | BINARY_INFO_BLOCK_DEV_FLAG_WRITE |
14335
BINARY_INFO_BLOCK_DEV_FLAG_PT_UNKNOWN));
36+
#endif
14437

14538
uint32_t *foo = (uint32_t *) 200;
14639

@@ -167,7 +60,6 @@ float __attribute__((noinline)) foox(float x, float b) {
16760
return x * b;
16861
}
16962

170-
17163
int main(void) {
17264
spiggle();
17365

0 commit comments

Comments
 (0)