Skip to content

Commit a30ad25

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 a30ad25

File tree

26 files changed

+53
-31
lines changed

26 files changed

+53
-31
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ jobs:
1515
path: 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 Arduino-Zephyr-API/
2120
west update
2221
git clone https://github.com/arduino/ArduinoCore-API.git ArduinoCore-API
23-
cp -r ArduinoCore-API/api modules/lib/Arduino-Zephyr-API/cores/arduino/.
22+
cp -r ArduinoCore-API/api Arduino-Zephyr-API/cores/arduino/
23+
mkdir modules/lib
24+
cp -rfp Arduino-Zephyr-API modules/lib/
2425
2526
- name: Build fade
2627
working-directory: Arduino-Zephyr-API
@@ -41,4 +42,4 @@ jobs:
4142
uses: actions/upload-artifact@v4
4243
with:
4344
name: firmware
44-
path: Arduino-Zephyr-API/build/zephyr/zephyr.*
45+
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)