2
2
3
3
export PLATFORMIO_ESP32_PATH=" $HOME /.platformio/packages/framework-arduinoespressif32"
4
4
5
- echo " Installing Python Wheel..."
5
+ echo " Installing Python Wheel ..."
6
6
pip install wheel > /dev/null 2>&1
7
- if [ $? -ne 0 ]; then echo " ERROR: Install failed" ; exit 1; fi
8
7
9
- echo " Installing PlatformIO..."
8
+ echo " Installing PlatformIO ..."
10
9
pip 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
12
10
13
- echo " Installing Platform ESP32..."
11
+ echo " Installing Platform ESP32 ..."
14
12
python -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
16
13
17
- echo " Replacing the framework version..."
14
+ echo " Replacing the framework version ..."
18
15
if [[ " $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"
20
17
mv -f " platform.json" " $HOME /.platformio/platforms/espressif32/platform.json"
21
18
else
22
19
sed -i ' s/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' " $HOME /.platformio/platforms/espressif32/platform.json"
23
20
fi
24
- if [ $? -ne 0 ]; then echo " ERROR: Replace failed" ; exit 1; fi
25
21
26
22
if [ " $GITHUB_REPOSITORY " == " espressif/arduino-esp32" ]; then
27
- echo " Linking Core..." && \
23
+ echo " Linking Core..."
28
24
ln -s $GITHUB_WORKSPACE " $PLATFORMIO_ESP32_PATH "
29
25
else
30
- echo " Cloning Core Repository..." && \
26
+ echo " Cloning Core Repository ..."
31
27
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
33
28
fi
34
29
35
30
echo " PlatformIO for ESP32 has been installed"
36
31
echo " "
37
32
38
-
39
33
function build_pio_sketch(){ # build_pio_sketch <board> <path-to-ino>
40
34
if [ " $# " -lt 2 ]; then
41
35
echo " ERROR: Illegal number of parameters"
42
36
echo " USAGE: build_pio_sketch <board> <path-to-ino>"
43
37
return 1
44
38
fi
45
39
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"
52
46
}
53
47
54
48
function count_sketches() # count_sketches <examples-path>
55
49
{
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
57
56
local sketches=$( find $examples -name * .ino)
58
57
local sketchnum=0
59
- rm -rf sketches.txt
60
58
for sketch in $sketches ; do
61
59
local sketchdir=$( dirname $sketch )
62
60
local sketchdirname=$( basename $sketchdir )
@@ -91,35 +89,37 @@ function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chun
91
89
chunks_num=" 1"
92
90
fi
93
91
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
102
100
101
+ set +e
103
102
count_sketches " $examples "
104
103
local sketchcount=$?
104
+ set -e
105
105
local sketches=$( cat sketches.txt)
106
106
rm -rf sketches.txt
107
107
108
108
local chunk_size=$(( $sketchcount / $chunks_num ))
109
109
local all_chunks=$(( $chunks_num * $chunk_size ))
110
110
if [ " $all_chunks " -lt " $sketchcount " ]; then
111
- chunk_size=$(( $chunk_size + 1 ))
111
+ chunk_size=$(( $chunk_size + 1 ))
112
112
fi
113
113
114
114
local start_index=$(( $chunk_idex * $chunk_size ))
115
115
if [ " $sketchcount " -le " $start_index " ]; then
116
- echo " Skipping job"
117
- return 0
116
+ echo " Skipping job"
117
+ return 0
118
118
fi
119
119
120
120
local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
121
121
if [ " $end_index " -gt " $sketchcount " ]; then
122
- end_index=$sketchcount
122
+ end_index=$sketchcount
123
123
fi
124
124
125
125
local start_num=$(( $start_index + 1 ))
@@ -141,7 +141,7 @@ function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chun
141
141
sketchnum=$(( $sketchnum + 1 ))
142
142
if [ " $sketchnum " -le " $start_index " ] \
143
143
|| [ " $sketchnum " -gt " $end_index " ]; then
144
- continue
144
+ continue
145
145
fi
146
146
build_pio_sketch " $board " " $sketch "
147
147
local result=$?
0 commit comments