Skip to content

Commit 118e440

Browse files
committed
Add support for custom CMake flags and positional target arguments in make-libpico.sh
- Refactor `make-libpico.sh` to accept positional arguments for target selection and a `--flags` option to forward custom CMake flags. - Update environment variable exports for clarity. - Add `LIB_PICO_MULTICORE` CMake option to `CMakeLists.txt` and propagate it to target compile definitions. - Preserve backward compatibility and improve build flexibility for local and CI workflows. Closes earlephilhower#3058
1 parent e608439 commit 118e440

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

tools/libpico/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.12)
22

3+
option(LIB_PICO_MULTICORE "Enable multicore support" 0)
4+
35
set(cpu $ENV{CPU})
46
message("Building for CPU ${cpu}")
57

@@ -131,6 +133,7 @@ target_compile_definitions(common-${cpu} INTERFACE
131133
CYW43_WARN=//
132134
CYW43_PIO_CLOCK_DIV_DYNAMIC=1
133135
CYW43_PIN_WL_DYNAMIC=1
136+
LIB_PICO_MULTICORE=${LIB_PICO_MULTICORE}
134137
${xcd}
135138
)
136139

tools/libpico/make-libpico.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
set -e # Exit on error
44
set -x
55

6-
export PICO_SDK_PATH="$(cd ../../pico-sdk/; pwd)"
7-
export PATH="$(cd ../../system/arm-none-eabi/bin; pwd):$PATH"
8-
export PATH="$(cd ../../system/riscv32-unknown-elf/bin; pwd):$PATH"
9-
export PATH="$(cd ../../system/picotool; pwd):$PATH"
6+
PICO_SDK_PATH="$(cd ../../pico-sdk/; pwd)"
7+
export PICO_SDK_PATH
8+
PATH="$(cd ../../system/arm-none-eabi/bin; pwd):$PATH"
9+
PATH="$(cd ../../system/riscv32-unknown-elf/bin; pwd):$PATH"
10+
PATH="$(cd ../../system/picotool; pwd):$PATH"
11+
export PATH
1012

1113
rm -rf build-rp2040
1214
mkdir build-rp2040
@@ -59,9 +61,26 @@ cd build-rp2350
5961
CPU=rp2350 cmake ..
6062
make -j
6163

62-
cd ..
63-
rm -rf build-rp2350-riscv
64-
mkdir build-rp2350-riscv
65-
cd build-rp2350-riscv
66-
CPU=rp2350-riscv cmake ..
67-
make -j
64+
build_rp2350_riscv() {
65+
rm -rf build-rp2350-riscv
66+
mkdir build-rp2350-riscv
67+
cd build-rp2350-riscv
68+
CPU=rp2350-riscv cmake "${flags[@]}" ..
69+
make -j
70+
cd ..
71+
}
72+
73+
if [[ ${#targets[@]} -eq 0 ]]; then
74+
build_rp2040
75+
build_rp2350
76+
build_rp2350_riscv
77+
else
78+
for t in "${targets[@]}"; do
79+
case $t in
80+
rp2040) build_rp2040 ;;
81+
rp2350) build_rp2350 ;;
82+
rp2350-riscv) build_rp2350_riscv ;;
83+
*) echo "Unknown target: $t"; exit 1 ;;
84+
esac
85+
done
86+
fi

0 commit comments

Comments
 (0)