8000 Ci update (#610) · Rzyq-git/ESPAsyncWebServer@3c6f5f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c6f5f9

Browse files
authored
Ci update (me-no-dev#610)
1 parent 2f37037 commit 3c6f5f9

File tree

11 files changed

+537
-327
lines changed

11 files changed

+537
-327
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
export ARDUINO_ESP32_PATH="$ARDUINO_USR_PATH/hardware/espressif/esp32"
4+
if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
5+
echo "Installing ESP32 Arduino Core ..."
6+
script_init_path="$PWD"
7+
mkdir -p "$ARDUINO_USR_PATH/hardware/espressif"
8+
cd "$ARDUINO_USR_PATH/hardware/espressif"
9+
10+
echo "Installing Python Serial ..."
11+
pip install pyserial > /dev/null
12+
13+
if [ "$OS_IS_WINDOWS" == "1" ]; then
14+
echo "Installing Python Requests ..."
15+
pip install requests > /dev/null
16+
fi
17+
18+
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
19+
echo "Linking Core..."
20+
ln -s $GITHUB_WORKSPACE esp32
21+
else
22+
echo "Cloning Core Repository..."
23+
git clone https://github.com/espressif/arduino-esp32.git esp32 > /dev/null 2>&1
24+
fi
25+
26+
echo "Updating Submodules ..."
27+
cd esp32
28+
git submodule update --init --recursive > /dev/null 2>&1
29+
30+
echo "Installing Platform Tools ..."
31+
cd tools && python get.py
32+
cd $script_init_path
33+
34+
echo "ESP32 Arduino has been installed in '$ARDUINO_ESP32_PATH'"
35+
echo ""
36+
fi
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
echo "Installing ESP8266 Arduino Core ..."
4+
script_init_path="$PWD"
5+
mkdir -p "$ARDUINO_USR_PATH/hardware/esp8266com"
6+
cd "$ARDUINO_USR_PATH/hardware/esp8266com"
7+
8+
echo "Installing Python Serial ..."
9+
pip install pyserial > /dev/null
10+
11+
if [ "$OS_IS_WINDOWS" == "1" ]; then
12+
echo "Installing Python Requests ..."
13+
pip install requests > /dev/null
14+
fi
15+
16+
echo "Cloning Core Repository ..."
17+
git clone https://github.com/esp8266/Arduino.git esp8266 > /dev/null 2>&1
18+
19+
echo "Updating submodules ..."
20+
cd esp8266
21+
git submodule update --init --recursive > /dev/null 2>&1
22+
23+
echo "Installing Platform Tools ..."
24+
cd tools
25+
python get.py > /dev/null
26+
cd $script_init_path
27+
28+
echo "ESP8266 Arduino has been inst F438 alled in '$ARDUINO_USR_PATH/hardware/esp8266com'"
29+
echo ""
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
#!/bin/bash
2+
3+
#OSTYPE: 'linux-gnu', ARCH: 'x86_64' => linux64
4+
#OSTYPE: 'msys', ARCH: 'x86_64' => win32
5+
#OSTYPE: 'darwin18', ARCH: 'i386' => macos
6+
7+
OSBITS=`arch`
8+
if [[ "$OSTYPE" == "linux"* ]]; then
9+
export OS_IS_LINUX="1"
10+
ARCHIVE_FORMAT="tar.xz"
11+
if [[ "$OSBITS" == "i686" ]]; then
12+
OS_NAME="linux32"
13+
elif [[ "$OSBITS" == "x86_64" ]]; then
14+
OS_NAME="linux64"
15+
elif [[ "$OSBITS" == "armv7l" || "$OSBITS" == "aarch64" ]]; then
16+
OS_NAME="linuxarm"
17+
else
18+
OS_NAME="$OSTYPE-$OSBITS"
19+
echo "Unknown OS '$OS_NAME'"
20+
exit 1
21+
fi
22+
elif [[ "$OSTYPE" == "darwin"* ]]; then
23+
export OS_IS_MACOS="1"
24+
ARCHIVE_FORMAT="zip"
25+
OS_NAME="macosx"
26+
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
27+
export OS_IS_WINDOWS="1"
28+
ARCHIVE_FORMAT="zip"
29+
OS_NAME="windows"
30+
else
31+
OS_NAME="$OSTYPE-$OSBITS"
32+
echo "Unknown OS '$OS_NAME'"
33+
exit 1
34+
fi
35+
export OS_NAME
36+
37+
ARDUINO_BUILD_DIR="$HOME/.arduino/build.tmp"
38+
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
39+
40+
if [ "$OS_IS_MACOS" == "1" ]; then
41+
export ARDUINO_IDE_PATH="/Applications/Arduino.app/Contents/Java"
42+
export ARDUINO_USR_PATH="$HOME/Documents/Arduino"
43+
else
44+
export ARDUINO_IDE_PATH="$HOME/arduino_ide"
45+
export ARDUINO_USR_PATH="$HOME/Arduino"
46+
fi
47+
48+
if [ ! -d "$ARDUINO_IDE_PATH" ]; then
49+
echo "Installing Arduino IDE on $OS_NAME ..."
50+
echo "Downloading 'arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT' to 'arduino.$ARCHIVE_FORMAT' ..."
51+
if [ "$OS_IS_LINUX" == "1" ]; then
52+
wget -O "arduino.$ARCHIVE_FORMAT" "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
53+
echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..."
54+
tar xf "arduino.$ARCHIVE_FORMAT" > /dev/null
55+
mv arduino-nightly "$ARDUINO_IDE_PATH"
56+
else
57+
curl -o "arduino.$ARCHIVE_FORMAT" -L "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
58+
echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..."
59+
unzip "arduino.$ARCHIVE_FORMAT" > /dev/null
60+
if [ "$OS_IS_MACOS" == "1" ]; then
61+
mv "Arduino.app" "/Applications/Arduino.app"
62+
else
63+
mv arduino-nightly "$ARDUINO_IDE_PATH"
64+
fi
65+
fi
66+
rm -rf "arduino.$ARCHIVE_FORMAT"
67+
68+
mkdir -p "$ARDUINO_USR_PATH/libraries"
69+
mkdir -p "$ARDUINO_USR_PATH/hardware"
70+
71+
echo "Arduino IDE Installed in '$ARDUINO_IDE_PATH'"
72+
echo ""
73+
fi
74+
75+
function build_sketch(){ # build_sketch <fqbn> <path-to-ino> [extra-options]
76+
if [ "$#" -lt 2 ]; then
77+
echo "ERROR: Illegal number of parameters"
78+
echo "USAGE: build_sketch <fqbn> <path-to-ino> [extra-options]"
79+
return 1
80+
fi
81+
82+
local fqbn="$1"
83+
local sketch="$2"
84+
local xtra_opts="$3"
85+
local win_opts=""
86+
if [ "$OS_IS_WINDOWS" == "1" ]; then
87+
local ctags_version=`ls "$ARDUINO_IDE_PATH/tools-builder/ctags/"`
88+
local preprocessor_version=`ls "$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/"`
89+
win_opts="-prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH/tools-builder/ctags/$ctags_version -prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/$preprocessor_version"
90+
fi
91+
92+
echo ""
93+
echo "Compiling '"$(basename "$sketch")"' ..."
94+
mkdir -p "$ARDUINO_BUILD_DIR"
95+
mkdir -p "$ARDUINO_CACHE_DIR"
96+
$ARDUINO_IDE_PATH/arduino-builder -compile -logger=human -core-api-version=10810 \
97+
-fqbn=$fqbn \
98+
-warnings="all" \
99+
-tools "$ARDUINO_IDE_PATH/tools-builder" \
100+
-tools "$ARDUINO_IDE_PATH/tools" \
101+
-built-in-libraries "$ARDUINO_IDE_PATH/libraries" \
102+
-hardware "$ARDUINO_IDE_PATH/hardware" \
103+
-hardware "$ARDUINO_USR_PATH/hardware" \
104+
-libraries "$ARDUINO_USR_PATH/libraries" \
105+
-build-cache "$ARDUINO_CACHE_DIR" \
106+
-build-path "$ARDUINO_BUILD_DIR" \
107+
$win_opts $xtra_opts "$sketch"
108+
}
109+
110+
function count_sketches() # count_sketches <examples-path>
111+
{
112+
local examples="$1"
113+
local sketches=$(find $examples -name *.ino)
114+
local sketchnum=0
115+
rm -rf sketches.txt
116+
for sketch in $sketches; do
117+
local sketchdir=$(dirname $sketch)
118+
local sketchdirname=$(basename $sketchdir)
119+
local sketchname=$(basename $sketch)
120+
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
121+
continue
122+
fi;
123+
if [[ -f "$sketchdir/.test.skip" ]]; then
124+
continue
125+
fi
126+
echo $sketch >> sketches.txt
127+
sketchnum=$(($sketchnum + 1))
128+
done
129+
return $sketchnum
130+
}
131+
132+
function build_sketches() # build_sketches <fqbn> <examples-path> <chunk> <total-chunks> [extra-options]
133+
{
134+
local fqbn=$1
135+
local examples=$2
B41A 136+
local chunk_idex=$3
137+
local chunks_num=$4
138+
local xtra_opts=$5
139+
140+
if [ "$#" -lt 2 ]; then
141+
echo "ERROR: Illegal number of parameters"
142+
echo "USAGE: build_sketches <fqbn> <examples-path> [<chunk> <total-chunks>] [extra-options]"
143+
return 1
144+
fi
145+
146+
if [ "$#" -lt 4 ]; then
147+
chunk_idex="0"
148+
chunks_num="1"
149+
xtra_opts=$3
150+
fi
151+
152+
if [ "$chunks_num" -le 0 ]; then
153+
echo "ERROR: Chunks count must be positive number"
154+
return 1
155+
fi
156+
if [ "$chunk_idex" -ge "$chunks_num" ]; then
157+
echo "ERROR: Chunk index must be less than chunks count"
158+
return 1
159+
fi
160+
161+
set +e
162+
count_sketches "$examples"
163+
local sketchcount=$?
164+
set -e
165+
local sketches=$(cat sketches.txt)
166+
rm -rf sketches.txt
167+
168+
local chunk_size=$(( $sketchcount / $chunks_num ))
169+
local all_chunks=$(( $chunks_num * $chunk_size ))
170+
if [ "$all_chunks" -lt "$sketchcount" ]; then
171+
chunk_size=$(( $chunk_size + 1 ))
172+
fi
173+
174+
local start_index=$(( $chunk_idex * $chunk_size ))
175+
if [ "$sketchcount" -le "$start_index" ]; then
176+
echo "Skipping job"
177+
return 0
178+
fi
179+
180+
local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
181+
if [ "$end_index" -gt "$sketchcount" ]; then
182+
end_index=$sketchcount
183+
fi
184+
185+
local start_num=$(( $start_index + 1 ))
186+
echo "Found $sketchcount Sketches";
187+
echo "Chunk Count : $chunks_num"
188+
echo "Chunk Size : $chunk_size"
189+
echo "Start Sketch: $start_num"
190+
echo "End Sketch : $end_index"
191+
192+
local sketchnum=0
193+
for sketch in $sketches; do
194+
local sketchdir=$(dirname $sketch)
195+
local sketchdirname=$(basename $sketchdir)
196+
local sketchname=$(basename $sketch)
197+
if [ "${sketchdirname}.ino" != "$sketchname" ] \
198+
|| [ -f "$sketchdir/.test.skip" ]; then
199+
continue
200+
fi
201+
sketchnum=$(($sketchnum + 1))
202+
if [ "$sketchnum" -le "$start_index" ] \
203+
|| [ "$sketchnum" -gt "$end_index" ]; then
204+
continue
205+
fi
206+
build_sketch "$fqbn" "$sketch" "$xtra_opts"
207+
local result=$?
208+
if [ $result -ne 0 ]; then
209+
return $result
210+
fi
211+
done
212+
return 0
213+
}

0 commit comments

Comments
 (0)
0