Skip to content

Commit eb569ae

Browse files
soburipillo79
andcommitted
samples: get the variant name from the Zephyr build system
Get the variant name (NORMALIZED_BOARD_TARGET) from the Zephyr build system as early as possible. This allows to have per-target build directories. Note that a bug with the shield specifiers does not currently allow to reuse the same build directory multiple times. Signed-off-by: TOKITA Hiroshi <[email protected]> Co-authored-by: Luca Burelli <[email protected]>
1 parent 8faf90b commit eb569ae

File tree

26 files changed

+54
-34
lines changed

26 files changed

+54
-34
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,32 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v4
1414
with:
15-
path: Arduino-Zephyr-API
15+
path: modules/lib/Arduino-Zephyr-API
1616

1717
- name: Initialize
18-
working-directory: Arduino-Zephyr-API
1918
run: |
20-
west init -m https://github.com/zephyrproject-rtos/gsoc-2022-arduino-core.git
19+
west init -l modules/lib/Arduino-Zephyr-API/
2120
west update
2221
git clone https://github.com/arduino/ArduinoCore-API.git ArduinoCore-API
2322
cp -r ArduinoCore-API/api modules/lib/Arduino-Zephyr-API/cores/arduino/.
2423
2524
- name: Build fade
26-
working-directory: Arduino-Zephyr-API
25+
working-directory: modules/lib/Arduino-Zephyr-API
2726
run: |
2827
west build -p -b arduino_nano_33_ble/nrf52840/sense samples/fade
2928
3029
- name: Build i2cdemo
31-
working-directory: Arduino-Zephyr-API
30+
working-directory: modules/lib/Arduino-Zephyr-API
3231
run: |
3332
west build -p -b arduino_nano_33_ble/nrf52840/sense samples/i2cdemo
3433
3534
- name: Build adc
36-
working-directory: Arduino-Zephyr-API
35+
working-directory: modules/lib/Arduino-Zephyr-API
3736
run: |
3837
west build -p -b beagleconnect_freedom/cc1352p7 samples/analog_input
3938
4039
- name: Archive firmware
4140
uses: actions/upload-artifact@v4
4241
with:
4342
name: firmware
44-
path: Arduino-Zephyr-API/build/zephyr/zephyr.*
43+
path: modules/lib/Arduino-Zephyr-API/build/zephyr/zephyr.*

samples/analog_input/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
911
project(analog_input)

samples/attach_interrupt/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
911
project(attach_interrupt)

samples/blinky_arduino/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
911
project(blinky)

samples/button_press_led/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9-
project(blinky)
11+
project(button_press_led)
1012

1113
target_sources(app PRIVATE src/main.cpp)
1214

samples/fade/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
911
project(fade)

samples/hello_arduino/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
911
project(hello_world)

samples/i2cdemo/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9-
project(blinky)
11+
project(i2cdemo)
1012

1113
target_sources(app PRIVATE src/main.cpp)
14+
1215
zephyr_compile_options(-Wno-unused-variable -Wno-comment)

samples/serial_event/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
911
project(serial_event)

samples/spi_controller/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
cmake_minimum_required(VERSION 3.20.0)
44

5-
cmake_path(SET ZephyrBase $ENV{ZEPHYR_BASE})
6-
set(DTC_OVERLAY_FILE ${ZephyrBase}/../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay)
5+
# get value of NORMALIZED_BOARD_TARGET early
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} COMPONENTS yaml boards)
7+
8+
set(DTC_OVERLAY_FILE ${CMAKE_CURRENT_LIST_DIR}/../../variants/${NORMALIZED_BOARD_TARGET}/${NORMALIZED_BOARD_TARGET}.overlay)
79

810
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
911
project(spi_controller)

0 commit comments

Comments
 (0)