Skip to content

Commit c0fbcc2

Browse files
authored
Merge pull request Aircoookie#11 from willmmiles/master
Collection of fixes for WLED project
2 parents b9349dc + fbc7eb1 commit c0fbcc2

39 files changed

+1963
-1047
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 installed in '$ARDUINO_USR_PATH/hardware/esp8266com'"
29+
echo ""
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
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+
elif [ "$OS_IS_WINDOWS" == "1" ]; then
44+
export ARDUINO_IDE_PATH="$HOME/arduino_ide"
45+
export ARDUINO_USR_PATH="$HOME/Documents/Arduino"
46+
else
47+
export ARDUINO_IDE_PATH="$HOME/arduino_ide"
48+
export ARDUINO_USR_PATH="$HOME/Arduino"
49+
fi
50+
51+
if [ ! -d "$ARDUINO_IDE_PATH" ]; then
52+
echo "Installing Arduino IDE on $OS_NAME ..."
53+
echo "Downloading 'arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT' to 'arduino.$ARCHIVE_FORMAT' ..."
54+
if [ "$OS_IS_LINUX" == "1" ]; then
55+
wget -O "arduino.$ARCHIVE_FORMAT" "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
56+
echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..."
57+
tar xf "arduino.$ARCHIVE_FORMAT" > /dev/null
58+
mv arduino-nightly "$ARDUINO_IDE_PATH"
59+
else
60+
curl -o "arduino.$ARCHIVE_FORMAT" -L "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
61+
echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..."
62+
unzip "arduino.$ARCHIVE_FORMAT" > /dev/null
63+
if [ "$OS_IS_MACOS" == "1" ]; then
64+
mv "Arduino.app" "/Applications/Arduino.app"
65+
else
66+
mv arduino-nightly "$ARDUINO_IDE_PATH"
67+
fi
68+
fi
69+
rm -rf "arduino.$ARCHIVE_FORMAT"
70+
71+
mkdir -p "$ARDUINO_USR_PATH/libraries"
72+
mkdir -p "$ARDUINO_USR_PATH/hardware"
73+
74+
echo "Arduino IDE Installed in '$ARDUINO_IDE_PATH'"
75+
echo ""
76+
fi
77+
78+
function build_sketch(){ # build_sketch <fqbn> <path-to-ino> <build-flags> [extra-options]
79+
if [ "$#" -lt 2 ]; then
80+
echo "ERROR: Illegal number of parameters"
81+
echo "USAGE: build_sketch <fqbn> <path-to-ino> <build-flags> [extra-options]"
82+
return 1
83+
fi
84+
85+
local fqbn="$1"
86+
local sketch="$2"
87+
local build_flags="$3"
88+
local xtra_opts="$4"
89+
local win_opts=""
90+
if [ "$OS_IS_WINDOWS" == "1" ]; then
91+
local ctags_version=`ls "$ARDUINO_IDE_PATH/tools-builder/ctags/"`
92+
local preprocessor_version=`ls "$ARDUINO_IDE_PATH/tools-builder/arduino-preprocessor/"`
93+
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"
94+
fi
95+
96+
echo ""
97+
echo "Compiling '"$(basename "$sketch")"' ..."
98+
mkdir -p "$ARDUINO_BUILD_DIR"
99+
mkdir -p "$ARDUINO_CACHE_DIR"
100+
$ARDUINO_IDE_PATH/arduino-builder -compile -logger=human -core-api-version=10810 \
101+
-fqbn=$fqbn \
102+
-warnings="all" \
103+
-tools "$ARDUINO_IDE_PATH/tools-builder" \
104+
-tools "$ARDUINO_IDE_PATH/tools" \
105+
-built-in-libraries "$ARDUINO_IDE_PATH/libraries" \
106+
-hardware "$ARDUINO_IDE_PATH/hardware" \
107+
-hardware "$ARDUINO_USR_PATH/hardware" \
108+
-libraries "$ARDUINO_USR_PATH/libraries" \
109+
-build-cache "$ARDUINO_CACHE_DIR" \
110+
-build-path "$ARDUINO_BUILD_DIR" \
111+
-prefs=compiler.cpp.extra_flags="$build_flags" \
112+
$win_opts $xtra_opts "$sketch"
113+
}
114+
115+
function count_sketches() # count_sketches <examples-path>
116+
{
117+
local examples="$1"
118+
rm -rf sketches.txt
119+
if [ ! -d "$examples" ]; then
120+
touch sketches.txt
121+
return 0
122+
fi
123+
local sketches=$(find $examples -name *.ino)
124+
local sketchnum=0
125+
for sketch in $sketches; do
126+
local sketchdir=$(dirname $sketch)
127+
local sketchdirname=$(basename $sketchdir)
128+
local sketchname=$(basename $sketch)
129+
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
130+
continue
131+
fi;
132+
if [[ -f "$sketchdir/.test.skip" ]]; then
133+
continue
134+
fi
135+
echo $sketch >> sketches.txt
136+
sketchnum=$(($sketchnum + 1))
137+
done
138+
return $sketchnum
139+
}
140+
141+
function build_sketches() # build_sketches <fqbn> <examples-path> <chunk> <total-chunks> [extra-options]
142+
{
143+
local fqbn=$1
144+
local examples=$2
145+
local chunk_idex=$3
146+
local chunks_num=$4
147+
local xtra_opts=$5
148+
149+
if [ "$#" -lt 2 ]; then
150+
echo "ERROR: Illegal number of parameters"
151+
echo "USAGE: build_sketches <fqbn> <examples-path> [<chunk> <total-chunks>] [extra-options]"
152+
return 1
153+
fi
154+
155+
if [ "$#" -lt 4 ]; then
156+
chunk_idex="0"
157+
chunks_num="1"
158+
xtra_opts=$3
159+
fi
160+
161+
if [ "$chunks_num" -le 0 ]; then
162+
echo "ERROR: Chunks count must be positive number"
163+
return 1
164+
fi
165+
if [ "$chunk_idex" -ge "$chunks_num" ]; then
166+
echo "ERROR: Chunk index must be less than chunks count"
167+
return 1
168+
fi
169+
170+
set +e
171+
count_sketches "$examples"
172+
local sketchcount=$?
173+
set -e
174+
local sketches=$(cat sketches.txt)
175+
rm -rf sketches.txt
176+
177+
local chunk_size=$(( $sketchcount / $chunks_num ))
178+
local all_chunks=$(( $chunks_num * $chunk_size ))
179+
if [ "$all_chunks" -lt "$sketchcount" ]; then
180+
chunk_size=$(( $chunk_size + 1 ))
181+
fi
182+
183+
local start_index=$(( $chunk_idex * $chunk_size ))
184+
if [ "$sketchcount" -le "$start_index" ]; then
185+
echo "Skipping job"
186+
return 0
187+
fi
188+
189+
local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
190+
if [ "$end_index" -gt "$sketchcount" ]; then
191+
end_index=$sketchcount
192+
fi
193+
194+
local start_num=$(( $start_index + 1 ))
195+
echo "Found $sketchcount Sketches";
196+
echo "Chunk Count : $chunks_num"
197+
echo "Chunk Size : $chunk_size"
198+
echo "Start Sketch: $start_num"
199+
echo "End Sketch : $end_index"
200+
201+
local sketchnum=0
202+
for sketch in $sketches; do
203+
local sketchdir=$(dirname $sketch)
204+
local sketchdirname=$(basename $sketchdir)
205+
local sketchname=$(basename $sketch)
206+
if [ "${sketchdirname}.ino" != "$sketchname" ] \
207+
|| [ -f "$sketchdir/.test.skip" ]; then
208+
continue
209+
fi
210+
sketchnum=$(($sketchnum + 1))
211+
if [ "$sketchnum" -le "$start_index" ] \
212+
|| [ "$sketchnum" -gt "$end_index" ]; then
213+
continue
214+
fi
215+
local sketchBuildFlags=""
216+
if [ -f "$sketchdir/.test.build_flags" ]; then
217+
while read line; do
218+
sketchBuildFlags="$sketchBuildFlags $line"
219+
done < "$sketchdir/.test.build_flags"
220+
fi
221+
build_sketch "$fqbn" "$sketch" "$sketchBuildFlags" "$xtra_opts"
222+
local result=$?
223+
if [ $result -ne 0 ]; then
224+
return $result
225+
fi
226+
done
227+
return 0
228+
}

0 commit comments

Comments
 (0)