2019-09-30 01:01:29 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-09-30 11:10:48 +02:00
|
|
|
export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32"
|
|
|
|
|
2019-10-02 10:58:02 +02:00
|
|
|
echo "Installing Python Wheel ..."
|
2019-09-30 01:01:29 +02:00
|
|
|
pip install wheel > /dev/null 2>&1
|
|
|
|
|
2019-10-02 10:58:02 +02:00
|
|
|
echo "Installing PlatformIO ..."
|
2019-09-30 01:01:29 +02:00
|
|
|
pip install -U https://github.com/platformio/platformio/archive/develop.zip > /dev/null 2>&1
|
|
|
|
|
2019-10-02 10:58:02 +02:00
|
|
|
echo "Installing Platform ESP32 ..."
|
2019-09-30 01:01:29 +02:00
|
|
|
python -m platformio platform install https://github.com/platformio/platform-espressif32.git#feature/stage > /dev/null 2>&1
|
|
|
|
|
2019-10-02 10:58:02 +02:00
|
|
|
echo "Replacing the framework version ..."
|
2019-09-30 01:01:29 +02:00
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
2019-10-02 10:58:02 +02:00
|
|
|
sed 's/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' "$HOME/.platformio/platforms/espressif32/platform.json" > "platform.json"
|
2019-09-30 01:01:29 +02:00
|
|
|
mv -f "platform.json" "$HOME/.platformio/platforms/espressif32/platform.json"
|
|
|
|
else
|
|
|
|
sed -i 's/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' "$HOME/.platformio/platforms/espressif32/platform.json"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
|
2019-10-02 10:58:02 +02:00
|
|
|
echo "Linking Core..."
|
2019-09-30 11:10:48 +02:00
|
|
|
ln -s $GITHUB_WORKSPACE "$PLATFORMIO_ESP32_PATH"
|
2019-09-30 01:01:29 +02:00
|
|
|
else
|
2019-10-02 10:58:02 +02:00
|
|
|
echo "Cloning Core Repository ..."
|
2019-09-30 11:10:48 +02:00
|
|
|
git clone https://github.com/espressif/arduino-esp32.git "$PLATFORMIO_ESP32_PATH" > /dev/null 2>&1
|
2019-09-30 01:01:29 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "PlatformIO for ESP32 has been installed"
|
|
|
|
echo ""
|
|
|
|
|
2019-09-30 11:10:48 +02:00
|
|
|
function build_pio_sketch(){ # build_pio_sketch <board> <path-to-ino>
|
|
|
|
if [ "$#" -lt 2 ]; then
|
|
|
|
echo "ERROR: Illegal number of parameters"
|
|
|
|
echo "USAGE: build_pio_sketch <board> <path-to-ino>"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2019-10-02 10:58:02 +02:00
|
|
|
local board="$1"
|
|
|
|
local sketch="$2"
|
|
|
|
local sketch_dir=$(dirname "$sketch")
|
|
|
|
echo ""
|
|
|
|
echo "Compiling '"$(basename "$sketch")"' ..."
|
|
|
|
python -m platformio ci --board "$board" "$sketch_dir" --project-option="board_build.partitions = huge_app.csv"
|
2019-09-30 01:01:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function count_sketches() # count_sketches <examples-path>
|
|
|
|
{
|
2019-10-02 10:58:02 +02:00
|
|
|
local examples="$1"
|
|
|
|
rm -rf sketches.txt
|
|
|
|
if [ ! -d "$examples" ]; then
|
|
|
|
touch sketches.txt
|
|
|
|
return 0
|
|
|
|
fi
|
2019-09-30 01:01:29 +02:00
|
|
|
local sketches=$(find $examples -name *.ino)
|
|
|
|
local sketchnum=0
|
|
|
|
for sketch in $sketches; do
|
|
|
|
local sketchdir=$(dirname $sketch)
|
|
|
|
local sketchdirname=$(basename $sketchdir)
|
|
|
|
local sketchname=$(basename $sketch)
|
|
|
|
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
|
|
|
|
continue
|
|
|
|
fi;
|
|
|
|
if [[ -f "$sketchdir/.test.skip" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo $sketch >> sketches.txt
|
|
|
|
sketchnum=$(($sketchnum + 1))
|
|
|
|
done
|
|
|
|
return $sketchnum
|
|
|
|
}
|
|
|
|
|
2019-09-30 11:10:48 +02:00
|
|
|
function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chunk> <total-chunks>
|
2019-09-30 01:01:29 +02:00
|
|
|
{
|
2019-09-30 11:10:48 +02:00
|
|
|
if [ "$#" -lt 2 ]; then
|
|
|
|
echo "ERROR: Illegal number of parameters"
|
|
|
|
echo "USAGE: build_pio_sketches <board> <examples-path> [<chunk> <total-chunks>]"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
local board=$1
|
|
|
|
local examples=$2
|
2019-09-30 01:01:29 +02:00
|
|
|
local chunk_idex=$3
|
|
|
|
local chunks_num=$4
|
|
|
|
|
2019-09-30 11:10:48 +02:00
|
|
|
if [ "$#" -lt 4 ]; then
|
|
|
|
chunk_idex="0"
|
|
|
|
chunks_num="1"
|
|
|
|
fi
|
|
|
|
|
2019-10-02 10:58:02 +02:00
|
|
|
if [ "$chunks_num" -le 0 ]; then
|
|
|
|
echo "ERROR: Chunks count must be positive number"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [ "$chunk_idex" -ge "$chunks_num" ]; then
|
|
|
|
echo "ERROR: Chunk index must be less than chunks count"
|
|
|
|
return 1
|
|
|
|
fi
|
2019-09-30 01:01:29 +02:00
|
|
|
|
2019-10-02 10:58:02 +02:00
|
|
|
set +e
|
2019-09-30 01:01:29 +02:00
|
|
|
count_sketches "$examples"
|
|
|
|
local sketchcount=$?
|
2019-10-02 10:58:02 +02:00
|
|
|
set -e
|
2019-09-30 01:01:29 +02:00
|
|
|
local sketches=$(cat sketches.txt)
|
|
|
|
rm -rf sketches.txt
|
|
|
|
|
|
|
|
local chunk_size=$(( $sketchcount / $chunks_num ))
|
|
|
|
local all_chunks=$(( $chunks_num * $chunk_size ))
|
|
|
|
if [ "$all_chunks" -lt "$sketchcount" ]; then
|
2019-10-02 10:58:02 +02:00
|
|
|
chunk_size=$(( $chunk_size + 1 ))
|
2019-09-30 01:01:29 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
local start_index=$(( $chunk_idex * $chunk_size ))
|
|
|
|
if [ "$sketchcount" -le "$start_index" ]; then
|
2019-10-02 10:58:02 +02:00
|
|
|
echo "Skipping job"
|
|
|
|
return 0
|
2019-09-30 01:01:29 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
|
|
|
|
if [ "$end_index" -gt "$sketchcount" ]; then
|
2019-10-02 10:58:02 +02:00
|
|
|
end_index=$sketchcount
|
2019-09-30 01:01:29 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
local start_num=$(( $start_index + 1 ))
|
|
|
|
echo "Found $sketchcount Sketches";
|
|
|
|
echo "Chunk Count : $chunks_num"
|
|
|
|
echo "Chunk Size : $chunk_size"
|
|
|
|
echo "Start Sketch: $start_num"
|
|
|
|
echo "End Sketch : $end_index"
|
|
|
|
|
|
|
|
local sketchnum=0
|
|
|
|
for sketch in $sketches; do
|
|
|
|
local sketchdir=$(dirname $sketch)
|
|
|
|
local sketchdirname=$(basename $sketchdir)
|
|
|
|
local sketchname=$(basename $sketch)
|
|
|
|
if [ "${sketchdirname}.ino" != "$sketchname" ] \
|
|
|
|
|| [ -f "$sketchdir/.test.skip" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
sketchnum=$(($sketchnum + 1))
|
|
|
|
if [ "$sketchnum" -le "$start_index" ] \
|
|
|
|
|| [ "$sketchnum" -gt "$end_index" ]; then
|
2019-10-02 10:58:02 +02:00
|
|
|
continue
|
2019-09-30 01:01:29 +02:00
|
|
|
fi
|
|
|
|
build_pio_sketch "$board" "$sketch"
|
|
|
|
local result=$?
|
|
|
|
if [ $result -ne 0 ]; then
|
|
|
|
return $result
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|