From 290c32074fad495f64877d95ed495aef7a07cdbc Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Sat, 21 Jan 2023 03:11:19 +0200 Subject: [PATCH] Backport some fixes from esp-idf-v5.1 --- .github/scripts/install-arduino-cli.sh | 46 ++++++++++++++++++ .github/scripts/on-push.sh | 14 +++--- .github/scripts/on-release.sh | 8 ++-- .github/scripts/sketch_utils.sh | 64 +++++++++++++++++++------- platform.txt | 10 ++-- 5 files changed, 110 insertions(+), 32 deletions(-) create mode 100755 .github/scripts/install-arduino-cli.sh diff --git a/.github/scripts/install-arduino-cli.sh b/.github/scripts/install-arduino-cli.sh new file mode 100755 index 00000000000..ba7547ccc28 --- /dev/null +++ b/.github/scripts/install-arduino-cli.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +OSBITS=`arch` +if [[ "$OSTYPE" == "linux"* ]]; then + export OS_IS_LINUX="1" + if [[ "$OSBITS" == "i686" ]]; then + OS_NAME="linux32" + elif [[ "$OSBITS" == "x86_64" ]]; then + OS_NAME="linux64" + elif [[ "$OSBITS" == "armv7l" || "$OSBITS" == "aarch64" ]]; then + OS_NAME="linuxarm" + else + OS_NAME="$OSTYPE-$OSBITS" + echo "Unknown OS '$OS_NAME'" + exit 1 + fi +elif [[ "$OSTYPE" == "darwin"* ]]; then + export OS_IS_MACOS="1" + OS_NAME="macosx" +elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then + export OS_IS_WINDOWS="1" + OS_NAME="windows" +else + OS_NAME="$OSTYPE-$OSBITS" + echo "Unknown OS '$OS_NAME'" + exit 1 +fi +export OS_NAME + +if [ "$OS_IS_MACOS" == "1" ]; then + export ARDUINO_IDE_PATH="$HOME/bin" + export ARDUINO_USR_PATH="$HOME/Documents/Arduino" +elif [ "$OS_IS_WINDOWS" == "1" ]; then + export ARDUINO_IDE_PATH="$HOME/bin" + export ARDUINO_USR_PATH="$HOME/Documents/Arduino" +else + export ARDUINO_IDE_PATH="$HOME/bin" + export ARDUINO_USR_PATH="$HOME/Arduino" +fi + +if [ ! -d "$ARDUINO_IDE_PATH" ] || [ ! -f "$ARDUINO_IDE_PATH/arduino-cli" ]; then + echo "Installing Arduino CLI on $OS_NAME ..." + mkdir -p "$ARDUINO_IDE_PATH" + curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR="$ARDUINO_IDE_PATH" sh +fi + diff --git a/.github/scripts/on-push.sh b/.github/scripts/on-push.sh index 71a92a1021a..0ca5a648fd0 100755 --- a/.github/scripts/on-push.sh +++ b/.github/scripts/on-push.sh @@ -9,7 +9,8 @@ function build(){ local fqbn=$2 local chunk_index=$3 local chunks_cnt=$4 - local sketches=$5 + shift; shift; shift; shift; + local sketches=$* local BUILD_SKETCH="${SCRIPTS_DIR}/sketch_utils.sh build" local BUILD_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh chunk_build" @@ -24,15 +25,15 @@ function build(){ ${BUILD_SKETCHES} ${args} else for sketch in ${sketches}; do - args+=" -s $(dirname $sketch)" - if [ "$OS_IS_WINDOWS" == "1" ]; then + local sargs="$args -s $(dirname $sketch)" + if [ "$OS_IS_WINDOWS" == "1" ] && [ -d "$ARDUINO_IDE_PATH/tools-builder" ]; then local ctags_version=`ls "$ARDUINO_IDE_PATH/tools-builder/ctags/"` local preprocessor_version=`ls "$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/"` win_opts="-prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH/tools-builder/ctags/$ctags_version -prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/$preprocessor_version" - args+=" ${win_opts}" + sargs+=" ${win_opts}" fi - ${BUILD_SKETCH} ${args} + ${BUILD_SKETCH} ${sargs} done fi } @@ -59,7 +60,8 @@ fi SCRIPTS_DIR="./.github/scripts" if [ "$BUILD_PIO" -eq 0 ]; then - source ${SCRIPTS_DIR}/install-arduino-ide.sh + #source ${SCRIPTS_DIR}/install-arduino-ide.sh + source ${SCRIPTS_DIR}/install-arduino-cli.sh source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh FQBN_ESP32="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app" diff --git a/.github/scripts/on-release.sh b/.github/scripts/on-release.sh index fb595b4df2c..947146ec492 100755 --- a/.github/scripts/on-release.sh +++ b/.github/scripts/on-release.sh @@ -197,10 +197,10 @@ find "$PKG_DIR" -name '*.git*' -type f -delete echo "Generating platform.txt..." cat "$GITHUB_WORKSPACE/platform.txt" | \ sed "s/version=.*/version=$ver$extent/g" | \ -sed 's/runtime.tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32-elf//g' | \ -sed 's/runtime.tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s2-elf//g' | \ -sed 's/runtime.tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s3-elf//g' | \ -sed 's/runtime.tools.riscv32-esp-elf-gcc.path={runtime.platform.path}\/tools\/riscv32-esp-elf//g' | \ +sed 's/tools.xtensa-esp32-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32-elf/tools.xtensa-esp32-elf-gcc.path=\{runtime.tools.xtensa-esp32-elf-gcc.path\}/g' | \ +sed 's/tools.xtensa-esp32s2-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s2-elf/tools.xtensa-esp32s2-elf-gcc.path=\{runtime.tools.xtensa-esp32s2-elf-gcc.path\}/g' | \ +sed 's/tools.xtensa-esp32s3-elf-gcc.path={runtime.platform.path}\/tools\/xtensa-esp32s3-elf/tools.xtensa-esp32s3-elf-gcc.path=\{runtime.tools.xtensa-esp32s3-elf-gcc.path\}/g' | \ +sed 's/tools.riscv32-esp-elf-gcc.path={runtime.platform.path}\/tools\/riscv32-esp-elf/tools.riscv32-esp-elf-gcc.path=\{runtime.tools.riscv32-esp-elf-gcc.path\}/g' | \ sed 's/tools.esptool_py.path={runtime.platform.path}\/tools\/esptool/tools.esptool_py.path=\{runtime.tools.esptool_py.path\}/g' | \ sed 's/debug.server.openocd.path={runtime.platform.path}\/tools\/openocd-esp32\/bin\/openocd/debug.server.openocd.path=\{runtime.tools.openocd-esp32.path\}\/bin\/openocd/g' | \ sed 's/debug.server.openocd.scripts_dir={runtime.platform.path}\/tools\/openocd-esp32\/share\/openocd\/scripts\//debug.server.openocd.scripts_dir=\{runtime.tools.openocd-esp32.path\}\/share\/openocd\/scripts\//g' | \ diff --git a/.github/scripts/sketch_utils.sh b/.github/scripts/sketch_utils.sh index 3a856202e51..4a8d500bcbc 100755 --- a/.github/scripts/sketch_utils.sh +++ b/.github/scripts/sketch_utils.sh @@ -121,34 +121,65 @@ function build_sketch(){ # build_sketch [ex if [ -n "$ARDUINO_BUILD_DIR" ]; then build_dir="$ARDUINO_BUILD_DIR" elif [ $len -eq 1 ]; then - build_dir="$sketchdir/build" + # build_dir="$sketchdir/build" + build_dir="$HOME/.arduino/build.tmp" fi mkdir -p "$ARDUINO_CACHE_DIR" for i in `seq 0 $(($len - 1))` do if [ $len -ne 1 ]; then - build_dir="$sketchdir/build$i" + # build_dir="$sketchdir/build$i" + build_dir="$HOME/.arduino/build$i.tmp" fi rm -rf $build_dir mkdir -p $build_dir currfqbn=`echo $fqbn | jq -r --argjson i $i '.[$i]'` sketchname=$(basename $sketchdir) - echo "Building $sketchname with FQBN=$currfqbn" - $ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \ - -fqbn=\"$currfqbn\" \ - -warnings="all" \ - -tools "$ide_path/tools-builder" \ - -tools "$ide_path/tools" \ - -built-in-libraries "$ide_path/libraries" \ - -hardware "$ide_path/hardware" \ - -hardware "$user_path/hardware" \ - -libraries "$user_path/libraries" \ - -build-cache "$ARDUINO_CACHE_DIR" \ - -build-path "$build_dir" \ - $xtra_opts "${sketchdir}/${sketchname}.ino" + + if [ -f "$ide_path/arduino-cli" ]; then + echo "Building $sketchname with arduino-cli and FQBN=$currfqbn" + + curroptions=`echo "$currfqbn" | cut -d':' -f4` + currfqbn=`echo "$currfqbn" | cut -d':' -f1-3` + $ide_path/arduino-cli compile \ + --fqbn "$currfqbn" \ + --board-options "$curroptions" \ + --warnings "all" \ + --build-cache-path "$ARDUINO_CACHE_DIR" \ + --build-path "$build_dir" \ + $xtra_opts "${sketchdir}" + elif [ -f "$ide_path/arduino-builder" ]; then + echo "Building $sketchname with arduino-builder and FQBN=$currfqbn" + + $ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \ + -fqbn=\"$currfqbn\" \ + -warnings="all" \ + -tools "$ide_path/tools-builder" \ + -hardware "$user_path/hardware" \ + -libraries "$user_path/libraries" \ + -build-cache "$ARDUINO_CACHE_DIR" \ + -build-path "$build_dir" \ + $xtra_opts "${sketchdir}/${sketchname}.ino" + + # $ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \ + # -fqbn=\"$currfqbn\" \ + # -warnings="all" \ + # -tools "$ide_path/tools-builder" \ + # -tools "$ide_path/tools" \ + # -built-in-libraries "$ide_path/libraries" \ + # -hardware "$ide_path/hardware" \ + # -hardware "$user_path/hardware" \ + # -libraries "$user_path/libraries" \ + # -build-cache "$ARDUINO_CACHE_DIR" \ + # -build-path "$build_dir" \ + # $xtra_opts "${sketchdir}/${sketchname}.ino" + fi done + unset fqbn + unset xtra_opts + unset options } function count_sketches(){ # count_sketches [target] @@ -294,8 +325,7 @@ function build_sketches(){ # build_sketches