Blame | Last modification | View Log | RSS feed
#!/bin/bashecho "Installing Python Wheel ..."pip install wheel > /dev/null 2>&1echo "Installing PlatformIO ..."pip install -U platformio > /dev/null 2>&1echo "PlatformIO has been installed"echo ""function build_pio_sketch(){ # build_pio_sketch <board> <path-to-ino>if [ "$#" -lt 2 ]; thenecho "ERROR: Illegal number of parameters"echo "USAGE: build_pio_sketch <board> <path-to-ino>"return 1filocal board="$1"local sketch="$2"local sketch_dir=$(dirname "$sketch")echo ""echo "Compiling '"$(basename "$sketch")"' ..."python -m platformio ci -l '.' --board "$board" "$sketch_dir" --project-option="board_build.partitions = huge_app.csv" --project-option="lib_compat_mode = strict" --project-option="lib_ldf_mode = chain"}function count_sketches() # count_sketches <examples-path>{local examples="$1"rm -rf sketches.txtif [ ! -d "$examples" ]; thentouch sketches.txtreturn 0filocal sketches=$(find $examples -name *.ino)local sketchnum=0for sketch in $sketches; dolocal sketchdir=$(dirname $sketch)local sketchdirname=$(basename $sketchdir)local sketchname=$(basename $sketch)if [[ "${sketchdirname}.ino" != "$sketchname" ]]; thencontinuefi;if [[ -f "$sketchdir/.test.skip" ]]; thencontinuefiecho $sketch >> sketches.txtsketchnum=$(($sketchnum + 1))donereturn $sketchnum}function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chunk> <total-chunks>{if [ "$#" -lt 2 ]; thenecho "ERROR: Illegal number of parameters"echo "USAGE: build_pio_sketches <board> <examples-path> [<chunk> <total-chunks>]"return 1filocal board=$1local examples=$2local chunk_idex=$3local chunks_num=$4if [ "$#" -lt 4 ]; thenchunk_idex="0"chunks_num="1"fiif [ "$chunks_num" -le 0 ]; thenecho "ERROR: Chunks count must be positive number"return 1fiif [ "$chunk_idex" -ge "$chunks_num" ]; thenecho "ERROR: Chunk index must be less than chunks count"return 1fiset +ecount_sketches "$examples"local sketchcount=$?set -elocal sketches=$(cat sketches.txt)rm -rf sketches.txtlocal chunk_size=$(( $sketchcount / $chunks_num ))local all_chunks=$(( $chunks_num * $chunk_size ))if [ "$all_chunks" -lt "$sketchcount" ]; thenchunk_size=$(( $chunk_size + 1 ))filocal start_index=$(( $chunk_idex * $chunk_size ))if [ "$sketchcount" -le "$start_index" ]; thenecho "Skipping job"return 0filocal end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))if [ "$end_index" -gt "$sketchcount" ]; thenend_index=$sketchcountfilocal 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=0for sketch in $sketches; dolocal sketchdir=$(dirname $sketch)local sketchdirname=$(basename $sketchdir)local sketchname=$(basename $sketch)if [ "${sketchdirname}.ino" != "$sketchname" ] \|| [ -f "$sketchdir/.test.skip" ]; thencontinuefisketchnum=$(($sketchnum + 1))if [ "$sketchnum" -le "$start_index" ] \|| [ "$sketchnum" -gt "$end_index" ]; thencontinuefibuild_pio_sketch "$board" "$sketch"local result=$?if [ $result -ne 0 ]; thenreturn $resultfidonereturn 0}