Skip to content

Commit 53d8c55

Browse files
committed
feat(idf): Add ci.json support for IDF examples
1 parent ee6a288 commit 53d8c55

File tree

10 files changed

+68
-83
lines changed

10 files changed

+68
-83
lines changed

.github/scripts/on-push-idf.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
CHECK_REQUIREMENTS="./components/arduino-esp32/.github/scripts/sketch_utils.sh check_requirements"
6+
7+
# Export IDF environment
8+
. ${IDF_PATH}/export.sh
9+
10+
# Find all examples in ./components/arduino-esp32/idf_component_examples
11+
idf_component_examples=$(find ./components/arduino-esp32/idf_component_examples -mindepth 1 -maxdepth 1 -type d)
12+
13+
for example in $idf_component_examples; do
14+
idf.py -C "$example" set-target "$IDF_TARGET"
15+
16+
has_requirements=$(${CHECK_REQUIREMENTS} "$example" "$example/sdkconfig")
17+
if [ "$has_requirements" -eq 0 ]; then
18+
printf "\n\033[93m%s does not meet the requirements for %s. Skipping...\033[0m\n\n" "$example" "$IDF_TARGET"
19+
continue
20+
fi
21+
22+
printf "\n\033[95mBuilding %s\033[0m\n\n" "$example"
23+
idf.py -C "$example" -DEXTRA_COMPONENT_DIRS="$PWD/components" build
24+
done

.github/scripts/sketch_utils.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function check_requirements { # check_requirements <sketchdir> <sdkconfig_path>
1616
local requirements_or
1717

1818
if [ ! -f "$sdkconfig_path" ] || [ ! -f "$sketchdir/ci.json" ]; then
19-
echo "ERROR: sdkconfig or ci.json not found" 1>&2
19+
echo "WARNING: sdkconfig or ci.json not found. Assuming requirements are met." 1>&2
2020
# Return 1 on error to force the sketch to be built and fail. This way the
2121
# CI will fail and the user will know that the sketch has a problem.
2222
else

.github/workflows/push.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ on:
3131
- "!libraries/**.properties"
3232
- "!libraries/**.py"
3333
- "package/**"
34+
- "idf_component_examples/**"
3435
- "tools/**.py"
3536
- "platform.txt"
3637
- "programmers.txt"
@@ -125,6 +126,7 @@ jobs:
125126
- 'Kconfig.projbuild'
126127
- 'CMakeLists.txt'
127128
- "variants/esp32c2/**/*"
129+
- "idf_component_examples/**"
128130
129131
- name: Set chunks
130132
id: set-chunks
@@ -267,15 +269,16 @@ jobs:
267269
submodules: recursive
268270
path: components/arduino-esp32
269271

272+
- name: Setup jq
273+
uses: dcarbone/install-jq-action@e397bd87438d72198f81efd21f876461183d383a # v3.0.1
274+
270275
- name: Build
271276
env:
272277
IDF_TARGET: ${{ matrix.idf_target }}
273278
shell: bash
274279
run: |
275-
. ${IDF_PATH}/export.sh
276-
idf.py -C ./components/arduino-esp32/idf_component_examples/hello_world -DEXTRA_COMPONENT_DIRS=$PWD/components build
277-
idf.py -C ./components/arduino-esp32/idf_component_examples/hw_cdc_hello_world -DEXTRA_COMPONENT_DIRS=$PWD/components build
278-
idf.py -C ./components/arduino-esp32/idf_component_examples/esp_matter_light -DEXTRA_COMPONENT_DIRS=$PWD/components build
280+
chmod a+x ./components/arduino-esp32/.github/scripts/*
281+
./components/arduino-esp32/.github/scripts/on-push-idf.sh
279282
280283
# Save artifacts to gh-pages
281284
save-master-artifacts:

idf_component_examples/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/
2+
managed_components/
3+
dependencies.lock

idf_component_examples/esp_matter_light/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(PROJECT_VER_NUMBER 1)
88
# This should be done before using the IDF_TARGET variable.
99
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
1010

11+
idf_build_set_property(MINIMAL_BUILD ON)
1112
project(arduino_managed_component_light)
1213

1314
# WARNING: This is just an example for using key for decrypting the encrypted OTA image
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"requires": [
3+
"CONFIG_SOC_WIFI_SUPPORTED=y",
4+
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
5+
]
6+
}

idf_component_examples/esp_matter_light/main/Kconfig.projbuild

+18-78
Original file line numberDiff line numberDiff line change
@@ -3,100 +3,40 @@ menu "Light Matter Accessory"
33
config BUTTON_PIN
44
int
55
prompt "Button 1 GPIO"
6-
default ENV_GPIO_BOOT_BUTTON
6+
default 9 if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C6
7+
default 0
78
range -1 ENV_GPIO_IN_RANGE_MAX
89
help
910
The GPIO pin for button that will be used to turn on/off the Matter Light. It shall be connected to a push button. It can use the BOOT button of the development board.
1011
endmenu
1112

12-
1313
menu "LEDs"
1414
config WS2812_PIN
1515
int
1616
prompt "WS2812 RGB LED GPIO"
17-
default ENV_GPIO_RGB_LED
17+
default 8 if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C6
18+
default 48
1819
range -1 ENV_GPIO_OUT_RANGE_MAX
1920
help
2021
The GPIO pin for the Matter Light that will be driven by RMT. It shall be connected to one single WS2812 RGB LED.
2122
endmenu
2223

23-
# TARGET CONFIGURATION
24-
if IDF_TARGET_ESP32C3
25-
config ENV_GPIO_RANGE_MIN
26-
int
27-
default 0
28-
29-
config ENV_GPIO_RANGE_MAX
30-
int
31-
default 19
32-
# GPIOs 20/21 are always used by UART in examples
33-
34-
config ENV_GPIO_IN_RANGE_MAX
35-
int
36-
default ENV_GPIO_RANGE_MAX
37-
38-
config ENV_GPIO_OUT_RANGE_MAX
39-
int
40-
default ENV_GPIO_RANGE_MAX
41-
42-
config ENV_GPIO_BOOT_BUTTON
43-
int
44-
default 9
45-
46-
config ENV_GPIO_RGB_LED
47-
int
48-
default 8
49-
endif
50-
if IDF_TARGET_ESP32C6
51-
config ENV_GPIO_RANGE_MIN
52-
int
53-
default 0
24+
config ENV_GPIO_RANGE_MIN
25+
int
26+
default 0
5427

55-
config ENV_GPIO_RANGE_MAX
56-
int
57-
default 30
58-
# GPIOs 16/17 are always used by UART in examples
28+
config ENV_GPIO_RANGE_MAX
29+
int
30+
default 19 if IDF_TARGET_ESP32C3
31+
default 30 if IDF_TARGET_ESP32C6
32+
default 48
5933

60-
config ENV_GPIO_IN_RANGE_MAX
61-
int
62-
default ENV_GPIO_RANGE_MAX
34+
config ENV_GPIO_IN_RANGE_MAX
35+
int
36+
default ENV_GPIO_RANGE_MAX
6337

64-
config ENV_GPIO_OUT_RANGE_MAX
65-
int
66-
default ENV_GPIO_RANGE_MAX
67-
68-
config ENV_GPIO_BOOT_BUTTON
69-
int
70-
default 9
71-
72-
config ENV_GPIO_RGB_LED
73-
int
74-
default 8
75-
endif
76-
if IDF_TARGET_ESP32S3
77-
config ENV_GPIO_RANGE_MIN
78-
int
79-
default 0
80-
81-
config ENV_GPIO_RANGE_MAX
82-
int
83-
default 48
84-
85-
config ENV_GPIO_IN_RANGE_MAX
86-
int
87-
default ENV_GPIO_RANGE_MAX
88-
89-
config ENV_GPIO_OUT_RANGE_MAX
90-
int
91-
default ENV_GPIO_RANGE_MAX
92-
93-
config ENV_GPIO_BOOT_BUTTON
94-
int
95-
default 0
96-
97-
config ENV_GPIO_RGB_LED
98-
int
99-
default 48
100-
endif
38+
config ENV_GPIO_OUT_RANGE_MAX
39+
int
40+
default ENV_GPIO_RANGE_MAX
10141

10242
endmenu

idf_component_examples/hello_world/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
cmake_minimum_required(VERSION 3.16)
66

77
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
8+
9+
idf_build_set_property(MINIMAL_BUILD ON)
810
project(main)

idf_component_examples/hw_cdc_hello_world/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
99
list(APPEND compile_definitions "ARDUINO_USB_CDC_ON_BOOT=1")
1010
list(APPEND compile_definitions "ARDUINO_USB_MODE=1")
1111

12+
idf_build_set_property(MINIMAL_BUILD ON)
1213
project(hw_cdc_hello_world)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"requires": [
3+
"CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED=y"
4+
]
5+
}

0 commit comments

Comments
 (0)