Skip to content

Commit d0b2c59

Browse files
committed
Revert "feat(support): toll and ci changes"
This reverts commit 857935c.
1 parent c03a574 commit d0b2c59

File tree

8 files changed

+507
-30
lines changed

8 files changed

+507
-30
lines changed

Diff for: .github/ISSUE_TEMPLATE/Issue-report.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ body:
7575
attributes:
7676
label: IDE Name
7777
description: What IDE are you using?
78-
placeholder: eg. Arduino IDE, VSCode, Sloeber...
78+
placeholder: eg. Arduino IDE, PlatformIO, Sloeber...
7979
validations:
8080
required: true
8181
- type: input

Diff for: .github/scripts/install-platformio-esp32.sh

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#!/bin/bash
2+
3+
export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32"
4+
PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git"
5+
6+
TOOLCHAIN_VERSION="12.2.0+20230208"
7+
ESPTOOLPY_VERSION="~1.40501.0"
8+
ESPRESSIF_ORGANIZATION_NAME="espressif"
9+
SDKCONFIG_DIR="$PLATFORMIO_ESP32_PATH/tools/esp32-arduino-libs"
10+
SCRIPTS_DIR="./.github/scripts"
11+
COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count"
12+
CHECK_REQUIREMENTS="${SCRIPTS_DIR}/sketch_utils.sh check_requirements"
13+
14+
echo "Installing Python Wheel ..."
15+
pip install wheel > /dev/null 2>&1
16+
17+
echo "Installing PlatformIO ..."
18+
pip install -U https://github.com/platformio/platformio/archive/master.zip > /dev/null 2>&1
19+
20+
echo "Installing Platform ESP32 ..."
21+
python -m platformio platform install $PLATFORMIO_ESP32_URL > /dev/null 2>&1
22+
23+
echo "Replacing the package versions ..."
24+
replace_script="import json; import os;"
25+
replace_script+="fp=open(os.path.expanduser('~/.platformio/platforms/espressif32/platform.json'), 'r+');"
26+
replace_script+="data=json.load(fp);"
27+
# Use framework sources from the repository
28+
replace_script+="data['packages']['framework-arduinoespressif32']['version'] = '*';"
29+
replace_script+="del data['packages']['framework-arduinoespressif32']['owner'];"
30+
# Use toolchain packages from the "espressif" organization
31+
replace_script+="data['packages']['toolchain-xtensa-esp32']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
32+
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
33+
replace_script+="data['packages']['toolchain-riscv32-esp']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
34+
# Update versions to use the upstream
35+
replace_script+="data['packages']['toolchain-xtensa-esp32']['version']='$TOOLCHAIN_VERSION';"
36+
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['version']='$TOOLCHAIN_VERSION';"
37+
replace_script+="data['packages']['toolchain-xtensa-esp32s3']['version']='$TOOLCHAIN_VERSION';"
38+
replace_script+="data['packages']['toolchain-riscv32-esp']['version']='$TOOLCHAIN_VERSION';"
39+
# Add new "framework-arduinoespressif32-libs" package
40+
# Read "package_esp32_index.template.json" to extract a url to a zip package for "esp32-arduino-libs"
41+
replace_script+="fpackage=open(os.path.join('package', 'package_esp32_index.template.json'), 'r+');"
42+
replace_script+="package_data=json.load(fpackage);"
43+
replace_script+="fpackage.close();"
44+
replace_script+="libs_package_archive_url=next(next(system['url'] for system in tool['systems'] if system['host'] == 'x86_64-pc-linux-gnu') for tool in package_data['packages'][0]['tools'] if tool['name'] == 'esp32-arduino-libs');"
45+
replace_script+="data['packages'].update({'framework-arduinoespressif32-libs':{'type':'framework','optional':False,'version':libs_package_archive_url}});"
46+
replace_script+="data['packages']['toolchain-xtensa-esp32'].update({'optional':False});"
47+
# esptool.py may require an upstream version (for now platformio is the owner)
48+
replace_script+="data['packages']['tool-esptoolpy']['version']='$ESPTOOLPY_VERSION';"
49+
# Save results
50+
replace_script+="fp.seek(0);fp.truncate();json.dump(data, fp, indent=2);fp.close()"
51+
python -c "$replace_script"
52+
53+
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
54+
echo "Linking Core..."
55+
ln -s $GITHUB_WORKSPACE "$PLATFORMIO_ESP32_PATH"
56+
else
57+
echo "Cloning Core Repository ..."
58+
git clone --recursive https://github.com/espressif/arduino-esp32.git "$PLATFORMIO_ESP32_PATH" > /dev/null 2>&1
59+
fi
60+
61+
echo "PlatformIO for ESP32 has been installed"
62+
echo ""
63+
64+
function build_pio_sketch(){ # build_pio_sketch <board> <options> <path-to-ino>
65+
if [ "$#" -lt 3 ]; then
66+
echo "ERROR: Illegal number of parameters"
67+
echo "USAGE: build_pio_sketch <board> <options> <path-to-ino>"
68+
return 1
69+
fi
70+
71+
local board="$1"
72+
local options="$2"
73+
local sketch="$3"
74+
local sketch_dir=$(dirname "$sketch")
75+
echo ""
76+
echo "Compiling '"$(basename "$sketch")"' ..."
77+
python -m platformio ci --board "$board" "$sketch_dir" --project-option="$options"
78+
}
79+
80+
function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-path> <chunk> <total-chunks>
81+
if [ "$#" -lt 3 ]; then
82+
echo "ERROR: Illegal number of parameters"
83+
echo "USAGE: build_pio_sketches <board> <options> <examples-path> [<chunk> <total-chunks>]"
84+
return 1
85+
fi
86+
87+
local board=$1
88+
local options="$2"
89+
local examples=$3
90+
local chunk_idex=$4
91+
local chunks_num=$5
92+
93+
if [ "$#" -lt 5 ]; then
94+
chunk_idex="0"
95+
chunks_num="1"
96+
fi
97+
98+
if [ "$chunks_num" -le 0 ]; then
99+
echo "ERROR: Chunks count must be positive number"
100+
return 1
101+
fi
102+
if [ "$chunk_idex" -ge "$chunks_num" ]; then
103+
echo "ERROR: Chunk index must be less than chunks count"
104+
return 1
105+
fi
106+
107+
set +e
108+
${COUNT_SKETCHES} "$examples" "esp32"
109+
local sketchcount=$?
110+
set -e
111+
local sketches=$(cat sketches.txt)
112+
rm -rf sketches.txt
113+
114+
local chunk_size=$(( $sketchcount / $chunks_num ))
115+
local all_chunks=$(( $chunks_num * $chunk_size ))
116+
if [ "$all_chunks" -lt "$sketchcount" ]; then
117+
chunk_size=$(( $chunk_size + 1 ))
118+
fi
119+
120+
local start_index=$(( $chunk_idex * $chunk_size ))
121+
if [ "$sketchcount" -le "$start_index" ]; then
122+
echo "Skipping job"
123+
return 0
124+
fi
125+
126+
local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
127+
if [ "$end_index" -gt "$sketchcount" ]; then
128+
end_index=$sketchcount
129+
fi
130+
131+
local start_num=$(( $start_index + 1 ))
132+
echo "Found $sketchcount Sketches";
133+
echo "Chunk Count : $chunks_num"
134+
echo "Chunk Size : $chunk_size"
135+
echo "Start Sketch: $start_num"
136+
echo "End Sketch : $end_index"
137+
138+
local sketchnum=0
139+
for sketch in $sketches; do
140+
local sketchdir=$(dirname $sketch)
141+
local sketchdirname=$(basename $sketchdir)
142+
local sketchname=$(basename $sketch)
143+
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
144+
continue
145+
elif [ -f $sketchdir/ci.json ]; then
146+
# If the target is listed as false, skip the sketch. Otherwise, include it.
147+
is_target=$(jq -r '.targets[esp32]' $sketchdir/ci.json)
148+
if [[ "$is_target" == "false" ]]; then
149+
continue
150+
fi
151+
152+
local has_requirements=$(${CHECK_REQUIREMENTS} $sketchdir "$SDKCONFIG_DIR/esp32/sdkconfig")
153+
if [ "$has_requirements" == "0" ]; then
154+
continue
155+
fi
156+
fi
157+
158+
sketchnum=$(($sketchnum + 1))
159+
if [ "$sketchnum" -le "$start_index" ] \
160+
|| [ "$sketchnum" -gt "$end_index" ]; then
161+
continue
162+
fi
163+
build_pio_sketch "$board" "$options" "$sketch"
164+
local result=$?
165+
if [ $result -ne 0 ]; then
166+
return $result
167+
fi
168+
done
169+
return 0
170+
}

Diff for: .github/scripts/on-push.sh

+52-29
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ CHUNK_INDEX=$1
5454
CHUNKS_CNT=$2
5555
BUILD_LOG=$3
5656
SKETCHES_FILE=$4
57+
BUILD_PIO=0
5758
if [ "$#" -lt 2 ] || [ "$CHUNKS_CNT" -le 0 ]; then
5859
CHUNK_INDEX=0
5960
CHUNKS_CNT=1
6061
elif [ "$CHUNK_INDEX" -gt "$CHUNKS_CNT" ] && [ "$CHUNKS_CNT" -ge 2 ]; then
6162
CHUNK_INDEX=$CHUNKS_CNT
63+
elif [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then
64+
BUILD_PIO=1
6265
fi
6366

6467
if [ -z "$BUILD_LOG" ] || [ "$BUILD_LOG" -le 0 ]; then
@@ -69,34 +72,54 @@ fi
6972
#git -C "$GITHUB_WORKSPACE" submodule update --init --recursive > /dev/null 2>&1
7073

7174
SCRIPTS_DIR="./.github/scripts"
72-
source ${SCRIPTS_DIR}/install-arduino-cli.sh
73-
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
74-
75-
SKETCHES_ESP32="\
76-
$ARDUINO_ESP32_PATH/libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino\
77-
$ARDUINO_ESP32_PATH/libraries/BLE/examples/Server/Server.ino\
78-
$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino\
79-
$ARDUINO_ESP32_PATH/libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino\
80-
"
81-
#create sizes_file
82-
sizes_file="$GITHUB_WORKSPACE/cli_compile_$CHUNK_INDEX.json"
83-
84-
if [ "$BUILD_LOG" -eq 1 ]; then
85-
#create sizes_file and echo start of JSON array with "boards" key
86-
echo "{\"boards\": [" > $sizes_file
87-
fi
75+
if [ "$BUILD_PIO" -eq 0 ]; then
76+
source ${SCRIPTS_DIR}/install-arduino-cli.sh
77+
source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh
78+
79+
SKETCHES_ESP32="\
80+
$ARDUINO_ESP32_PATH/libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino\
81+
$ARDUINO_ESP32_PATH/libraries/BLE/examples/Server/Server.ino\
82+
$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino\
83+
$ARDUINO_ESP32_PATH/libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino\
84+
"
85+
#create sizes_file
86+
sizes_file="$GITHUB_WORKSPACE/cli_compile_$CHUNK_INDEX.json"
87+
88+
if [ "$BUILD_LOG" -eq 1 ]; then
89+
#create sizes_file and echo start of JSON array with "boards" key
90+
echo "{\"boards\": [" > $sizes_file
91+
fi
8892

89-
#build sketches for different targets
90-
build "esp32s3" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
91-
build "esp32s2" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
92-
build "esp32c3" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
93-
build "esp32c6" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
94-
build "esp32h2" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
95-
build "esp32" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
96-
97-
if [ "$BUILD_LOG" -eq 1 ]; then
98-
#remove last comma from the last JSON object
99-
sed -i '$ s/,$//' "$sizes_file"
100-
#echo end of JSON array
101-
echo "]}" >> $sizes_file
93+
#build sketches for different targets
94+
build "esp32s3" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
95+
build "esp32s2" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
96+
build "esp32c3" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
97+
build "esp32c6" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
98+
build "esp32h2" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
99+
build "esp32" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$SKETCHES_FILE" "$SKETCHES_ESP32"
100+
101+
if [ "$BUILD_LOG" -eq 1 ]; then
102+
#remove last comma from the last JSON object
103+
sed -i '$ s/,$//' "$sizes_file"
104+
#echo end of JSON array
105+
echo "]}" >> $sizes_file
106+
fi
107+
else
108+
source ${SCRIPTS_DIR}/install-platformio-esp32.sh
109+
# PlatformIO ESP32 Test
110+
BOARD="esp32dev"
111+
OPTIONS="board_build.partitions = huge_app.csv"
112+
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient/WiFiClient.ino" && \
113+
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/NetworkClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
114+
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino" && \
115+
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/BLE/examples/Server/Server.ino" && \
116+
build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
117+
118+
# Basic sanity testing for other series
119+
for board in "esp32-c3-devkitm-1" "esp32-s2-saola-1" "esp32-s3-devkitc-1"
120+
do
121+
python -m platformio ci --board "$board" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient" --project-option="board_build.partitions = huge_app.csv"
122+
done
123+
124+
#build_pio_sketches "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries"
102125
fi

Diff for: .github/scripts/on-release.sh

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ cp -f "$GITHUB_WORKSPACE/tools/gen_insights_package.py" "$PKG_DIR/tools/"
207207
cp -f "$GITHUB_WORKSPACE/tools/gen_insights_package.exe" "$PKG_DIR/tools/"
208208
cp -Rf "$GITHUB_WORKSPACE/tools/partitions" "$PKG_DIR/tools/"
209209
cp -Rf "$GITHUB_WORKSPACE/tools/ide-debug" "$PKG_DIR/tools/"
210+
cp -f "$GITHUB_WORKSPACE/tools/platformio-build.py" "$PKG_DIR/tools/"
210211

211212
# Remove unnecessary files in the package folder
212213
echo "Cleaning up folders ..."

Diff for: .github/scripts/set_push_chunks.sh

+1
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ echo "build_all=$build_all" >> $GITHUB_OUTPUT
7878
echo "build_libraries=$BUILD_LIBRARIES" >> $GITHUB_OUTPUT
7979
echo "build_static_sketches=$BUILD_STATIC_SKETCHES" >> $GITHUB_OUTPUT
8080
echo "build_idf=$BUILD_IDF" >> $GITHUB_OUTPUT
81+
echo "build_platformio=$BUILD_PLATFORMIO" >> $GITHUB_OUTPUT
8182
echo "chunk_count=$chunks_count" >> $GITHUB_OUTPUT
8283
echo "chunks=$chunks" >> $GITHUB_OUTPUT

Diff for: .github/workflows/push.yml

+30
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
build_libraries: ${{ steps.set-chunks.outputs.build_libraries }}
6262
build_static_sketches: ${{ steps.set-chunks.outputs.build_static_sketches }}
6363
build_idf: ${{ steps.set-chunks.outputs.build_idf }}
64+
build_platformio: ${{ steps.set-chunks.outputs.build_platformio }}
6465
chunk_count: ${{ steps.set-chunks.outputs.chunk_count }}
6566
chunks: ${{ steps.set-chunks.outputs.chunks }}
6667
steps:
@@ -76,9 +77,11 @@ jobs:
7677
files_yaml: |
7778
core:
7879
- '.github/**'
80+
- '!.github/scripts/install-platformio-esp32.sh'
7981
- 'cores/**'
8082
- 'package/**'
8183
- 'tools/**'
84+
- '!tools/platformio-build.py'
8285
- 'platform.txt'
8386
- 'programmers.txt'
8487
- "variants/esp32/**/*"
@@ -107,13 +110,18 @@ jobs:
107110
- 'Kconfig.projbuild'
108111
- 'CMakeLists.txt'
109112
- "variants/esp32c2/**/*"
113+
platformio:
114+
- 'package.json'
115+
- '.github/scripts/install-platformio-esp32.sh'
116+
- 'tools/platformio-build.py'
110117
111118
- name: Set chunks
112119
id: set-chunks
113120
env:
114121
LIB_FILES: ${{ steps.changed-files.outputs.libraries_all_changed_files }}
115122
IS_PR: ${{ github.event_name == 'pull_request' }}
116123
MAX_CHUNKS: ${{ env.MAX_CHUNKS }}
124+
BUILD_PLATFORMIO: ${{ steps.changed-files.outputs.platformio_any_changed == 'true' }}
117125
BUILD_IDF: ${{ steps.changed-files.outputs.idf_any_changed == 'true' }}
118126
BUILD_LIBRARIES: ${{ steps.changed-files.outputs.libraries_any_changed == 'true' }}
119127
BUILD_STATIC_SKETCHES: ${{ steps.changed-files.outputs.static_sketeches_any_changed == 'true' }}
@@ -204,6 +212,28 @@ jobs:
204212
- name: Build Sketches
205213
run: bash ./.github/scripts/on-push.sh
206214

215+
# PlatformIO on Windows, Ubuntu and Mac
216+
build-platformio:
217+
name: PlatformIO on ${{ matrix.os }}
218+
needs: gen-chunks
219+
if: |
220+
needs.gen-chunks.outputs.build_all == 'true' ||
221+
needs.gen-chunks.outputs.build_static_sketches == 'true' ||
222+
needs.gen-chunks.outputs.build_platformio == 'true'
223+
runs-on: ${{ matrix.os }}
224+
strategy:
225+
fail-fast: false
226+
matrix:
227+
os: [ubuntu-latest, windows-latest, macOS-latest]
228+
229+
steps:
230+
- uses: actions/checkout@v4
231+
- uses: actions/setup-python@v5
232+
with:
233+
python-version: '3.x'
234+
- name: Build Sketches
235+
run: bash ./.github/scripts/on-push.sh 1 1 #equal and non-zero to trigger PIO
236+
207237
build-esp-idf-component:
208238
name: Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
209239
needs: gen-chunks

Diff for: platform.txt

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ compiler.warning_flags.more=-Wall
4747
compiler.warning_flags.all=-Wall -Wextra
4848

4949
# Additional flags specific to Arduino (not based on IDF flags).
50+
# Update tools/platformio-build.py when changing these flags.
5051
compiler.common_werror_flags=-Werror=return-type
5152

5253
# Compile Flags

0 commit comments

Comments
 (0)