Skip to content

Commit fed7188

Browse files
Rework use of pico_cmake_set in board headers to make it slightly less magic/confusing (#2397)
* Rework use of pico_cmake_set in board headers to make it slightly less magic/confusing - prefer "pico_cmake_set(var, value)" over "// pico_cmake_set var = value" - prefer "pico_cmake_set_default(var, value)" over "// pico_cmake_set_default var = value" - move these inside the header include guards as CLion complains Note that the macros are defined in "pico.h" however that is not explicitly included by the board headers; this will probably confuse some VS code syntax highligting, so lets see how it looks - i'd prefer to avoid having to include a header just for this * Update check_board_header.py with the new pico_cmake_set formats * Add brackets back around `PICO_FLASH_SIZE_BYTES` settings The python script checks for an exact match between the #define and the pico_cmake_set_default, so fails without the brackets * Rename to pico_board_cmake_set and pico_board_cmake_set_default * Fix support for old versions --------- Co-authored-by: William Vinnicombe <[email protected]>
1 parent 5592322 commit fed7188

File tree

125 files changed

+480
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+480
-439
lines changed

cmake/generic_board.cmake

+15-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,22 @@ if (EXISTS ${PICO_BOARD_HEADER_FILE})
2020

2121
while(HEADER_FILE_CONTENTS)
2222
list(POP_FRONT HEADER_FILE_CONTENTS LINE)
23-
if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
23+
# pico_board_cmake_set(var, value)
24+
if (LINE MATCHES "^[ \t\]*pico_board_cmake_set[ \t\]*\\([ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*,[ \t\]*(.*)[ \t\]*\\)[ \t\]*")
2425
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
25-
endif()
26-
if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set_default[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
26+
# pico_board_cmake_set_default(var, value)
27+
elseif (LINE MATCHES "^[ \t\]*pico_board_cmake_set_default[ \t\]*\\([ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*,[ \t\]*(.*)[ \t\]*\\)[ \t\]*")
28+
if (NOT DEFINED "${CMAKE_MATCH_1}")
29+
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
30+
else()
31+
list(APPEND PICO_BOARD_CMAKE_OVERRIDES ${CMAKE_MATCH_1})
32+
endif()
33+
# continue to support these for now
34+
# // pico_cmake_set var = value
35+
elseif (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
36+
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
37+
# // pico_cmake_set_default var = value
38+
elseif (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set_default[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
2739
if (NOT DEFINED "${CMAKE_MATCH_1}")
2840
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
2941
else()

src/boards/include/boards/0xcb_helios.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
//------------------------------------------------------------------------------------------
1313
// Board definition for the 0xCB Helios
1414

15-
// pico_cmake_set PICO_PLATFORM=rp2040
16-
1715
#ifndef _BOARDS_0XCB_HELIOS_H
1816
#define _BOARDS_0XCB_HELIOS_H
1917

18+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
19+
2020
// For board detection
2121
#define _0XCB_HELIOS
2222

@@ -73,7 +73,7 @@
7373
#endif
7474

7575
// board has 16M onboard flash
76-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
76+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024))
7777
#ifndef PICO_FLASH_SIZE_BYTES
7878
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
7979
#endif

src/boards/include/boards/adafruit_feather_rp2040.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2040
13-
1412
#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2040_H
1513
#define _BOARDS_ADAFRUIT_FEATHER_RP2040_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
16+
1717
// For board detection
1818
#define ADAFRUIT_FEATHER_RP2040
1919

@@ -83,7 +83,7 @@
8383
#define PICO_FLASH_SPI_CLKDIV 4
8484
#endif
8585

86-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
86+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
8787
#ifndef PICO_FLASH_SIZE_BYTES
8888
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
8989
#endif

src/boards/include/boards/adafruit_feather_rp2040_usb_host.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2040
13-
1412
#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2040_USB_HOST_H
1513
#define _BOARDS_ADAFRUIT_FEATHER_RP2040_USB_HOST_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
16+
1717
// For board detection
1818
#define ADAFRUIT_FEATHER_RP2040_USB_HOST
1919

@@ -79,7 +79,7 @@
7979
#define PICO_FLASH_SPI_CLKDIV 4
8080
#endif
8181

82-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
82+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
8383
#ifndef PICO_FLASH_SIZE_BYTES
8484
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
8585
#endif

src/boards/include/boards/adafruit_feather_rp2350.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
// This header may be included by other board headers as "boards/adafruit_feather_rp2350.h"
1313

14-
// pico_cmake_set PICO_PLATFORM=rp2350
15-
1614
#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2350_H
1715
#define _BOARDS_ADAFRUIT_FEATHER_RP2350_H
1816

17+
pico_board_cmake_set(PICO_PLATFORM, rp2350)
18+
1919
// On some samples, the xosc can take longer to stabilize than is usual
2020
#ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER
2121
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
@@ -78,12 +78,12 @@
7878
#define PICO_FLASH_SPI_CLKDIV 2
7979
#endif
8080

81-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
81+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
8282
#ifndef PICO_FLASH_SIZE_BYTES
8383
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
8484
#endif
8585

86-
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
86+
pico_board_cmake_set_default(PICO_RP2350_A2_SUPPORTED, 1)
8787
#ifndef PICO_RP2350_A2_SUPPORTED
8888
#define PICO_RP2350_A2_SUPPORTED 1
8989
#endif

src/boards/include/boards/adafruit_itsybitsy_rp2040.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2040
13-
1412
#ifndef _BOARDS_ADAFRUIT_ITSYBITSY_RP2040_H
1513
#define _BOARDS_ADAFRUIT_ITSYBITSY_RP2040_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
16+
1717
// For board detection
1818
#define ADAFRUIT_ITSYBITSY_RP2040
1919

@@ -86,7 +86,7 @@
8686
#define PICO_FLASH_SPI_CLKDIV 2
8787
#endif
8888

89-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
89+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
9090
#ifndef PICO_FLASH_SIZE_BYTES
9191
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
9292
#endif

src/boards/include/boards/adafruit_kb2040.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2040
13-
1412
#ifndef _BOARDS_ADAFRUIT_KB2040_H
1513
#define _BOARDS_ADAFRUIT_KB2040_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
16+
1717
// For board detection
1818
#define ADAFRUIT_KB2040
1919

@@ -78,7 +78,7 @@
7878
#define PICO_FLASH_SPI_CLKDIV 2
7979
#endif
8080

81-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
81+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
8282
#ifndef PICO_FLASH_SIZE_BYTES
8383
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
8484
#endif

src/boards/include/boards/adafruit_macropad_rp2040.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
#ifndef _BOARDS_ADAFRUIT_MACROPAD_RP2040_H
1313
#define _BOARDS_ADAFRUIT_MACROPAD_RP2040_H
1414

15-
// pico_cmake_set PICO_PLATFORM=rp2040
16-
1715
// For board detection
1816
#define ADAFRUIT_MACROPAD_RP2040
1917

18+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
19+
2020
// On some samples, the xosc can take longer to stabilize than is usual
2121
#ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER
2222
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
@@ -173,7 +173,7 @@
173173
#define PICO_FLASH_SPI_CLKDIV 4
174174
#endif
175175

176-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
176+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
177177
#ifndef PICO_FLASH_SIZE_BYTES
178178
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
179179
#endif

src/boards/include/boards/adafruit_qtpy_rp2040.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2040
13-
1412
#ifndef _BOARDS_ADAFRUIT_QTPY_RP2040_H
1513
#define _BOARDS_ADAFRUIT_QTPY_RP2040_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
16+
1717
// For board detection
1818
#define ADAFRUIT_QTPY_RP2040
1919

@@ -85,7 +85,7 @@
8585
#define PICO_FLASH_SPI_CLKDIV 2
8686
#endif
8787

88-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
88+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
8989
#ifndef PICO_FLASH_SIZE_BYTES
9090
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
9191
#endif

src/boards/include/boards/adafruit_trinkey_qt2040.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2040
13-
1412
#ifndef _BOARDS_ADAFRUIT_TRINKEY_QT2040_H
1513
#define _BOARDS_ADAFRUIT_TRINKEY_QT2040_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
16+
1717
// For board detection
1818
#define ADAFRUIT_TRINKEY_QT2040
1919

@@ -63,7 +63,7 @@
6363
#define PICO_FLASH_SPI_CLKDIV 2
6464
#endif
6565

66-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
66+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
6767
#ifndef PICO_FLASH_SIZE_BYTES
6868
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
6969
#endif

src/boards/include/boards/amethyst_fpga.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2350
13-
1412
#ifndef _BOARDS_AMETHYST_FPGA_H
1513
#define _BOARDS_AMETHYST_FPGA_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2350)
16+
1717
#if !PICO_RP2350
1818
#error "Invalid PICO_PLATFORM for amethyst_fpga.h: must be rp2350 or rp2350-riscv"
1919
#endif
@@ -98,7 +98,7 @@
9898
#define PICO_FLASH_SPI_CLKDIV 2
9999
#endif
100100

101-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
101+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024))
102102
#ifndef PICO_FLASH_SIZE_BYTES
103103
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
104104
#endif

src/boards/include/boards/archi.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
// This header may be included by other board headers as "boards/archi.h"
1313

14-
// pico_cmake_set PICO_PLATFORM=rp2040
15-
1614
#ifndef _BOARDS_ARCHI_H
1715
#define _BOARDS_ARCHI_H
1816

17+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
18+
1919
// For board detection
2020
#define ARCHI
2121

@@ -104,7 +104,7 @@
104104
#define PICO_FLASH_SPI_CLKDIV 4
105105
#endif
106106

107-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024)
107+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (4 * 1024 * 1024))
108108
#ifndef PICO_FLASH_SIZE_BYTES
109109
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
110110
#endif

src/boards/include/boards/arduino_nano_rp2040_connect.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2040
13-
1412
#ifndef _BOARDS_ARDUINO_NANO_RP2040_CONNECT_H
1513
#define _BOARDS_ARDUINO_NANO_RP2040_CONNECT_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
16+
1717
// For board detection
1818
#define ARDUINO_NANO_RP2040_CONNECT
1919

@@ -74,7 +74,7 @@
7474
#define PICO_FLASH_SPI_CLKDIV 2
7575
#endif
7676

77-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
77+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024))
7878
#ifndef PICO_FLASH_SIZE_BYTES
7979
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
8080
#endif

src/boards/include/boards/cytron_maker_pi_rp2040.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
1010
// -----------------------------------------------------
1111

12-
// pico_cmake_set PICO_PLATFORM=rp2040
13-
1412
#ifndef _BOARDS_CYTRON_MAKER_PI_RP2040_H
1513
#define _BOARDS_CYTRON_MAKER_PI_RP2040_H
1614

15+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
16+
1717
// For board detection
1818
#define CYTRON_MAKER_PI_RP2040
1919

@@ -179,7 +179,7 @@
179179
#define PICO_FLASH_SPI_CLKDIV 2
180180
#endif
181181

182-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
182+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (2 * 1024 * 1024))
183183
#ifndef PICO_FLASH_SIZE_BYTES
184184
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
185185
#endif

src/boards/include/boards/datanoisetv_rp2040_dsp.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
//
1515
// This header may be included by other board headers as "boards/datanoisetv_rp2040_dsp.h"
1616

17-
// pico_cmake_set PICO_PLATFORM=rp2040
18-
1917
#ifndef _BOARDS_DATANOISETV_RP2040_DSP_H
2018
#define _BOARDS_DATANOISETV_RP2040_DSP_H
2119

20+
pico_board_cmake_set(PICO_PLATFORM, rp2040)
21+
2222
// For board detection
2323
#define DATANOISETV_RP2040_DSP
2424

@@ -40,7 +40,7 @@
4040
#define PICO_FLASH_SPI_CLKDIV 2
4141
#endif
4242

43-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
43+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024))
4444
#ifndef PICO_FLASH_SIZE_BYTES
4545
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
4646
#endif

src/boards/include/boards/datanoisetv_rp2350_dsp.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
//
1515
// This header may be included by other board headers as "boards/datanoisetv_rp2350_dsp.h"
1616

17-
// pico_cmake_set PICO_PLATFORM=rp2350
18-
1917
#ifndef _BOARDS_DATANOISETV_RP2350_DSP_H
2018
#define _BOARDS_DATANOISETV_RP2350_DSP_H
2119

20+
pico_board_cmake_set(PICO_PLATFORM, rp2350)
21+
2222
// For board detection
2323
#define DATANOISETV_RP2350_DSP
2424

@@ -43,12 +43,12 @@
4343
#define PICO_FLASH_SPI_CLKDIV 2
4444
#endif
4545

46-
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
46+
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
4747
#ifndef PICO_FLASH_SIZE_BYTES
4848
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
4949
#endif
5050

51-
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
51+
pico_board_cmake_set_default(PICO_RP2350_A2_SUPPORTED, 1)
5252
#ifndef PICO_RP2350_A2_SUPPORTED
5353
#define PICO_RP2350_A2_SUPPORTED 1
5454
#endif

0 commit comments

Comments
 (0)