22
33export PLATFORMIO_ESP32_PATH=" $HOME /.platformio/packages/framework-arduinoespressif32"
44
5- echo " Installing Python Wheel..."
5+ echo " Installing Python Wheel ..."
66pip install wheel > /dev/null 2>&1
7- if [ $? -ne 0 ]; then echo " ERROR: Install failed" ; exit 1; fi
87
9- echo " Installing PlatformIO..."
8+ echo " Installing PlatformIO ..."
109pip install -U https://github.com/platformio/platformio/archive/develop.zip > /dev/null 2>&1
11- if [ $? -ne 0 ]; then echo " ERROR: Install failed" ; exit 1; fi
1210
13- echo " Installing Platform ESP32..."
11+ echo " Installing Platform ESP32 ..."
1412python -m platformio platform install https://github.com/platformio/platform-espressif32.git#feature/stage > /dev/null 2>&1
15- if [ $? -ne 0 ]; then echo " ERROR: Install failed" ; exit 1; fi
1613
17- echo " Replacing the framework version..."
14+ echo " Replacing the framework version ..."
1815if [[ " $OSTYPE " == " darwin" * ]]; then
19- sed ' s/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' " $HOME /.platformio/platforms/espressif32/platform.json" > " platform.json" && \
16+ sed ' s/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' " $HOME /.platformio/platforms/espressif32/platform.json" > " platform.json"
2017 mv -f " platform.json" " $HOME /.platformio/platforms/espressif32/platform.json"
2118else
2219 sed -i ' s/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' " $HOME /.platformio/platforms/espressif32/platform.json"
2320fi
24- if [ $? -ne 0 ]; then echo " ERROR: Replace failed" ; exit 1; fi
2521
2622if [ " $GITHUB_REPOSITORY " == " espressif/arduino-esp32" ]; then
27- echo " Linking Core..." && \
23+ echo " Linking Core..."
2824 ln -s $GITHUB_WORKSPACE " $PLATFORMIO_ESP32_PATH "
2925else
30- echo " Cloning Core Repository..." && \
26+ echo " Cloning Core Repository ..."
3127 git clone https://github.com/espressif/arduino-esp32.git " $PLATFORMIO_ESP32_PATH " > /dev/null 2>&1
32- if [ $? -ne 0 ]; then echo " ERROR: GIT clone failed" ; exit 1; fi
3328fi
3429
3530echo " PlatformIO for ESP32 has been installed"
3631echo " "
3732
38-
3933function build_pio_sketch(){ # build_pio_sketch <board> <path-to-ino>
4034 if [ " $# " -lt 2 ]; then
4135 echo " ERROR: Illegal number of parameters"
4236 echo " USAGE: build_pio_sketch <board> <path-to-ino>"
4337 return 1
4438 fi
4539
46- local board=" $1 "
47- local sketch=" $2 "
48- local sketch_dir=$( dirname " $sketch " )
49- echo " "
50- echo " Compiling '" $( basename " $sketch " ) " '..."
51- python -m platformio ci --board " $board " " $sketch_dir " --project-option=" board_build.partitions = huge_app.csv"
40+ local board=" $1 "
41+ local sketch=" $2 "
42+ local sketch_dir=$( dirname " $sketch " )
43+ echo " "
44+ echo " Compiling '" $( basename " $sketch " ) " ' ..."
45+ python -m platformio ci --board " $board " " $sketch_dir " --project-option=" board_build.partitions = huge_app.csv"
5246}
5347
5448function count_sketches() # count_sketches <examples-path>
5549{
56- local examples=" $1 "
50+ local examples=" $1 "
51+ rm -rf sketches.txt
52+ if [ ! -d " $examples " ]; then
53+ touch sketches.txt
54+ return 0
55+ fi
5756 local sketches=$( find $examples -name * .ino)
5857 local sketchnum=0
59- rm -rf sketches.txt
6058 for sketch in $sketches ; do
6159 local sketchdir=$( dirname $sketch )
6260 local sketchdirname=$( basename $sketchdir )
@@ -91,35 +89,37 @@ function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chun
9189 chunks_num=" 1"
9290 fi
9391
94- if [ " $chunks_num " -le 0 ]; then
95- echo " ERROR: Chunks count must be positive number"
96- return 1
97- fi
98- if [ " $chunk_idex " -ge " $chunks_num " ]; then
99- echo " ERROR: Chunk index must be less than chunks count"
100- return 1
101- fi
92+ if [ " $chunks_num " -le 0 ]; then
93+ echo " ERROR: Chunks count must be positive number"
94+ return 1
95+ fi
96+ if [ " $chunk_idex " -ge " $chunks_num " ]; then
97+ echo " ERROR: Chunk index must be less than chunks count"
98+ return 1
99+ fi
102100
101+ set +e
103102 count_sketches " $examples "
104103 local sketchcount=$?
104+ set -e
105105 local sketches=$( cat sketches.txt)
106106 rm -rf sketches.txt
107107
108108 local chunk_size=$(( $sketchcount / $chunks_num ))
109109 local all_chunks=$(( $chunks_num * $chunk_size ))
110110 if [ " $all_chunks " -lt " $sketchcount " ]; then
111- chunk_size=$(( $chunk_size + 1 ))
111+ chunk_size=$(( $chunk_size + 1 ))
112112 fi
113113
114114 local start_index=$(( $chunk_idex * $chunk_size ))
115115 if [ " $sketchcount " -le " $start_index " ]; then
116- echo " Skipping job"
117- return 0
116+ echo " Skipping job"
117+ return 0
118118 fi
119119
120120 local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
121121 if [ " $end_index " -gt " $sketchcount " ]; then
122- end_index=$sketchcount
122+ end_index=$sketchcount
123123 fi
124124
125125 local start_num=$(( $start_index + 1 ))
@@ -141,7 +141,7 @@ function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chun
141141 sketchnum=$(( $sketchnum + 1 ))
142142 if [ " $sketchnum " -le " $start_index " ] \
143143 || [ " $sketchnum " -gt " $end_index " ]; then
144- continue
144+ continue
145145 fi
146146 build_pio_sketch " $board " " $sketch "
147147 local result=$?
0 commit comments