Files
arduinoWebSockets/travis/common.sh

158 lines
4.2 KiB
Bash
Raw Normal View History

2017-07-20 18:26:04 +02:00
#!/bin/bash
2022-06-24 10:48:51 +02:00
set -x
2022-04-05 19:40:57 +02:00
2017-07-20 18:26:04 +02:00
function build_sketches()
{
local arduino=$1
local srcpath=$2
local platform=$3
local sketches=$(find $srcpath -name *.ino)
for sketch in $sketches; do
local sketchdir=$(dirname $sketch)
if [[ -f "$sketchdir/.$platform.skip" ]]; then
echo -e "\n\n ------------ Skipping $sketch ------------ \n\n";
continue
fi
echo -e "\n\n ------------ Building $sketch ------------ \n\n";
$arduino --verify $sketch;
2017-07-20 18:26:04 +02:00
local result=$?
if [ $result -ne 0 ]; then
echo "Build failed ($sketch) build verbose..."
$arduino --verify --verbose --preserve-temp-files $sketch
result=$?
fi
if [ $result -ne 0 ]; then
echo "Build failed ($1) $sketch"
2017-07-20 18:26:04 +02:00
return $result
fi
done
}
function build_sketch_cli()
{
local sketch=$1
local board=$2
arduino-cli --log --log-level info compile -b "$board" "$sketch"
if [ $result -ne 0 ]; then
echo "Build failed ($sketch) build verbose..."
arduino-cli --log --log-level debug compile -b "$board" "$sketch"
result=$?
fi
if [ $result -ne 0 ]; then
echo "Build failed ($1) $sketch"
return $result
fi
}
2021-01-05 18:35:22 +01:00
function build_sketch()
{
2021-01-05 18:35:22 +01:00
local arduino=$1
local sketch=$2
2022-06-24 10:48:51 +02:00
$arduino --verify --verbose $sketch;
2021-01-05 18:35:22 +01:00
local result=$?
if [ $result -ne 0 ]; then
echo "Build failed ($sketch) build verbose..."
$arduino --verify --verbose --preserve-temp-files $sketch
result=$?
fi
if [ $result -ne 0 ]; then
echo "Build failed ($1) $sketch"
return $result
fi
}
function get_sketches_json()
{
local arduino=$1
local srcpath=$2
local platform=$3
local sketches=($(find $srcpath -name *.ino))
echo -en "["
for sketch in "${sketches[@]}" ; do
local sketchdir=$(dirname $sketch)
if [[ -f "$sketchdir/.$platform.skip" ]]; then
continue
fi
echo -en "\"$sketch\""
if [[ $sketch != ${sketches[-1]} ]] ; then
echo -en ","
fi
2021-01-05 18:35:22 +01:00
done
echo -en "]"
}
function get_sketches_json_matrix()
{
local arduino=$1
local srcpath=$2
local platform=$3
2024-01-05 15:00:16 +01:00
local cliversion=$4
2021-01-05 18:35:22 +01:00
local board=$5
local sketches=($(find $srcpath -name *.ino))
for sketch in "${sketches[@]}" ; do
local sketchdir=$(dirname $sketch)
local sketchname=$(basename $sketch)
if [[ -f "$sketchdir/.$platform.skip" ]]; then
continue
fi
2024-01-05 15:00:16 +01:00
echo -en "{\"name\":\"$sketchname\",\"board\":\"$board\",\"cliversion\":\"$cliversion\",\"cpu\":\"$platform\",\"sketch\":\"$sketch\"}"
2021-01-05 18:35:22 +01:00
if [[ $sketch != ${sketches[-1]} ]] ; then
echo -en ","
fi
done
}
function get_core_cli() {
arduino-cli core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json,https://espressif.github.io/arduino-esp32/package_esp32_index.json,https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
arduino-cli core install esp8266:esp8266
arduino-cli core install esp32:esp32
arduino-cli core install arduino:mbed_rp2040
}
2018-02-06 20:41:36 +01:00
function get_core()
{
2018-02-06 21:10:29 +01:00
echo Setup core for $1
mkdir -p $HOME/arduino_ide/packages/hardware
cd $HOME/arduino_ide/packages/hardware
2018-02-06 20:41:36 +01:00
if [ "$1" = "esp8266" ] ; then
mkdir esp8266com
cd esp8266com
2021-01-06 09:18:27 +01:00
git clone --depth 1 https://github.com/esp8266/Arduino.git esp8266
2021-01-05 18:35:22 +01:00
cd esp8266/
git submodule update --init
2021-01-05 18:35:22 +01:00
rm -rf .git
cd tools
2018-02-06 20:41:36 +01:00
python get.py
fi
if [ "$1" = "esp32" ] ; then
mkdir espressif
cd espressif
2021-01-06 09:18:27 +01:00
git clone --depth 1 https://github.com/espressif/arduino-esp32.git esp32
2021-01-05 18:35:22 +01:00
cd esp32/
rm -rf .git
cd tools
2018-02-06 20:41:36 +01:00
python get.py
fi
2018-02-06 21:10:29 +01:00
2018-02-06 20:41:36 +01:00
}
2021-01-06 09:39:19 +01:00
function clone_library() {
local url=$1
echo clone $(basename $url)
mkdir -p $HOME/Arduino/libraries
cd $HOME/Arduino/libraries
git clone --depth 1 $url
rm -rf */.git
rm -rf */.github
rm -rf */examples
}
function hash_library_names() {
cd $HOME/Arduino/libraries
ls | sha1sum -z | cut -c1-5
2021-01-06 09:39:19 +01:00
}