Skip to content

Commit c257375

Browse files
committed
arduino-cli builder
1 parent 9e2c036 commit c257375

File tree

3 files changed

+64
-55
lines changed

3 files changed

+64
-55
lines changed

.github/workflows/build-ide.yml

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ jobs:
111111
- name: Build Sketches
112112
env:
113113
ESP8266_ARDUINO_BUILDER: "arduino"
114-
ESP8266_ARDUINO_IDE: "${{ runner.temp }}/arduino_ide"
115114
ESP8266_ARDUINO_LWIP: ${{ matrix.lwip }}
116115
run: |
117116
bash ./tests/build.sh 8 ${{ matrix.chunk }}

tests/build.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ESP8266_ARDUINO_BUILD_DIR=${ESP8266_ARDUINO_BUILD_DIR:-$root}
66
ESP8266_ARDUINO_BUILDER=${ESP8266_ARDUINO_BUILDER:-arduino}
77
ESP8266_ARDUINO_PRESERVE_CACHE=${ESP8266_ARDUINO_PRESERVE_CACHE:-}
88

9-
ESP8266_ARDUINO_IDE=${ESP8266_ARDUINO_IDE:-$HOME/arduino_ide}
9+
ESP8266_ARDUINO_CLI=${ESP8266_ARDUINO_CLI:-$HOME/.local/bin/arduino-cli}
1010
ESP8266_ARDUINO_HARDWARE=${ESP8266_ARDUINO_HARDWARE:-$HOME/Arduino/hardware}
1111
ESP8266_ARDUINO_LIBRARIES=${ESP8266_ARDUINO_LIBRARIES:-$HOME/Arduino/libraries}
1212

@@ -22,8 +22,7 @@ ENVIRONMENT:
2222
ESP8266_ARDUINO_SKETCHES - list of .ino files; defaults to **all available examples**
2323
ESP8266_ARDUINO_BUILDER - arduino or platformio
2424
25-
For Arduino IDE:
26-
ESP8266_ARDUINO_IDE - path to the IDE (portable)
25+
For Arduino CLI:
2726
ESP8266_ARDUINO_HARDWARE - path to the hardware directory (usually, containing our repo)
2827
ESP8266_ARDUINO_LIBRATIES - path to the libraries directory (external dependencies)
2928
ESP8266_ARDUINO_DEBUG - debug or nodebug

tests/common.sh

+62-51
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,42 @@ END {
107107
awk -v sketch_name="${elf_name%.*}" "$awk_script" -
108108
}
109109

110+
function format_fqbn()
111+
{
112+
local board_name=$1
113+
local flash_size=$2
114+
local lwip=$3
115+
116+
echo "esp8266com:esp8266:${board_name}:"\
117+
"eesz=${flash_size},"\
118+
"ip=${lwip}"
119+
}
120+
110121
function build_sketches()
111122
{
112123
local core_path=$1
113-
local ide_path=$2
114-
local hardware_path=$3
115-
local library_path=$4
116-
local build_mod=$5
117-
local build_rem=$6
118-
local lwip=$7
124+
local cli_path=$2
125+
local library_path=$3
126+
local build_mod=$4
127+
local build_rem=$5
128+
local lwip=$6
119129

120130
local build_dir="$cache_dir"/build
121131
mkdir -p "$build_dir"
122132

123-
local build_cache="$cache_dir"/cache
124-
mkdir -p "$build_cache"
133+
local build_out="$cache_dir"/out
134+
mkdir -p "$build_out"
135+
136+
local fqbn=$(format_fqbn "generic" "4M1M" "$lwip")
137+
echo $fqbn
125138

126139
local build_cmd
127-
build_cmd="python3 tools/build.py"\
128-
" --build_cache $build_cache"\
129-
" --build_path $build_dir"\
130-
" --hardware_path $hardware_path"\
131-
" --ide_path $ide_path"\
132-
" --library_path $library_path"\
133-
" --lwIP $lwip"\
134-
" --board_name generic --verbose --warnings all"\
135-
" --flash_size 4M1M --keep"
140+
build_cmd+=${cli_path}
141+
build_cmd+=" compile"\
142+
" --build-path $build_dir"\
143+
" --fqbn $fqbn"\
144+
" --libraries $library_path"\
145+
" --output-dir $build_out"
136146

137147
print_size_info_header >"$cache_dir"/size.log
138148

@@ -165,15 +175,15 @@ function build_sketches()
165175
rm -rf "$build_dir/core/build.opt" "$build_dir"/core/*.ino.globals.h
166176
fi
167177

168-
if [ -e $cache_dir/core/*.a ]; then
178+
if [ -e ${build_dir}/core/*.a ]; then
169179
# We need to preserve the build.options.json file and replace the last .ino
170180
# with this sketch's ino file, or builder will throw everything away.
171181
jq '."sketchLocation" = "'$sketch'"' $build_dir/build.options.json \
172182
> "$build_dir"/build.options.json.tmp
173183
mv "$build_dir"/build.options.json.tmp "$build_dir"/build.options.json
174184
if [ $mk_clean_core -ne 0 ]; then
175185
# Hack workaround for CI not handling core rebuild for global options
176-
rm $cache_dir/core/*.a
186+
rm ${build_dir}/core/*.a
177187
fi
178188
fi
179189

@@ -305,40 +315,42 @@ function install_libraries()
305315
popd
306316
}
307317

308-
function install_ide()
318+
function install_arduino_cli()
309319
{
310-
# TODO replace ide distribution + arduino-builder with arduino-cli
311-
local idever='1.8.19'
312-
local ideurl="https://downloads.arduino.cc/arduino-$idever"
320+
local path=$1
313321

314-
echo "Arduino IDE ${idever}"
322+
local ver='1.2.2'
323+
local urlbase="https://github.com/arduino/arduino-cli/releases/download/v${ver}/arduino-cli_${ver}_"
315324

316-
local core_path=$1
317-
local ide_path=$2
325+
echo "Arduino CLI ${ver}"
318326

319-
mkdir -p ${core_path}/tools/dist
320-
pushd ${core_path}/tools/dist
327+
mkdir -p ${cache_dir}/cli
328+
pushd ${cache_dir}/cli
321329

322-
if [ "${RUNNER_OS-}" = "Windows" ]; then
323-
fetch_and_unpack "arduino-windows.zip" \
324-
"c4072d808aea3848bceff5772f9d1e56a0fde02366b5aa523d10975c54eee2ca8def25ee466abbc88995aa323d475065ad8eb30bf35a2aaf07f9473f9168e2da" \
325-
"${ideurl}-windows.zip"
326-
mv arduino-$idever arduino-distrib
327-
elif [ "${RUNNER_OS-}" = "macOS" ]; then
328-
fetch_and_unpack "arduino-macos.zip" \
329-
"053b0c1e70da9176680264e40fcb9502f45ca5a879aeb8b6f71282b38bfdb87c63ebc6b88e35ea70a73720ad439d828cc8cb110e4c6ab07357126a36ee396325" \
330-
"${ideurl}-macosx.zip"
331-
# Hack to place arduino-builder in the same spot as sane OSes
332-
mv Arduino.app arduino-distrib
333-
mv arduino-distrib/Contents/Java/* arduino-distrib/.
334-
else
335-
fetch_and_unpack "arduino-linux.tar.xz" \
336-
"9328abf8778200019ed40d4fc0e6afb03a4cee8baaffbcea7dd3626477e14243f779eaa946c809fb153a542bf2ed60cf11a5f135c91ecccb1243c1387be95328" \
337-
"${ideurl}-linux64.tar.xz"
338-
mv arduino-$idever arduino-distrib
339-
fi
330+
case "${RUNNER_OS-}" in
331+
("Linux")
332+
fetch_and_unpack "Linux_64bit.tar.gz" \
333+
"d421e2b1cbef59c41e46cf06d077214a1d24cb784030462763781c9d3911cc55257fbcc02a7ee6a2ddda5b459101dc83aeda6b3b5198805bfdce856f82774c93" \
334+
"${urlbase}Linux_64bit.tar.gz"
335+
;;
336+
("Windows")
337+
fetch_and_unpack "Windows_64bit.zip" \
338+
"05b4eb5820fbaf670de00399d40513ecf2de9d0c2c5593a1227be03b2d11ba53e9d14cf6f934110447d6fd15c6a09769606a34fcab32ec3c2dbaa42f4627b072" \
339+
"${urlbase}Windows_64bit.zip"
340+
;;
341+
("macOS")
342+
fetch_and_unpack "macOS_ARM64.tar.gz" \
343+
"672693418b730d8ebc57cae2c892553e821706bee06312cc77a598e834afcba7d380df4d337138ecc03a4013a349d89b744b2a3b97fafc214b619856d9162827" \
344+
"${urlbase}macOS_ARM64.tar.gz"
345+
;;
346+
(*)
347+
echo 'Unknown ${RUNNER_OS} = "' ${RUNNER_OS} '"'
348+
exit 2
349+
esac
350+
351+
cp -v arduino-cli $path
352+
chmod +x $path
340353

341-
mv arduino-distrib "$ide_path"
342354
popd
343355
}
344356

@@ -388,8 +400,8 @@ function install_arduino()
388400
echo ::group::Install arduino
389401
local debug=$1
390402

391-
test -d "$ESP8266_ARDUINO_IDE" \
392-
|| install_ide "$ESP8266_ARDUINO_BUILD_DIR" "$ESP8266_ARDUINO_IDE"
403+
command -v "${ESP8266_ARDUINO_CLI}" \
404+
|| install_arduino_cli "${ESP8266_ARDUINO_CLI}"
393405

394406
local hardware_core_path="$ESP8266_ARDUINO_HARDWARE/esp8266com/esp8266"
395407
test -d "$hardware_core_path" \
@@ -421,8 +433,7 @@ function build_sketches_with_arduino()
421433
lwip=$(arduino_lwip_menu_option $3)
422434

423435
build_sketches "$ESP8266_ARDUINO_BUILD_DIR" \
424-
"$ESP8266_ARDUINO_IDE" \
425-
"$ESP8266_ARDUINO_HARDWARE" \
436+
"$ESP8266_ARDUINO_CLI" \
426437
"$ESP8266_ARDUINO_LIBRARIES" \
427438
"$build_mod" "$build_rem" "$lwip"
428439
step_summary "Size report" "$cache_dir/size.log"

0 commit comments

Comments
 (0)