Skip to content

Commit d2377a8

Browse files
committed
added missing script for travis
1 parent d82f159 commit d2377a8

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

src/travis/common.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
function build_examples()
4+
{
5+
# track the exit code for this platform
6+
local exit_code=0
7+
# loop through results and add them to the array
8+
examples=($(find $PWD/examples/ -name "*.pde" -o -name "*.ino"))
9+
10+
# get the last example in the array
11+
local last="${examples[@]:(-1)}"
12+
13+
# loop through example sketches
14+
for example in "${examples[@]}"; do
15+
16+
# store the full path to the example's sketch directory
17+
local example_dir=$(dirname $example)
18+
19+
# store the filename for the example without the path
20+
local example_file=$(basename $example)
21+
22+
echo "$example_file: "
23+
local sketch="$example_dir/$example_file"
24+
echo "$sketch"
25+
#arduino -v --verbose-build --verify $sketch
26+
27+
# verify the example, and save stdout & stderr to a variable
28+
# we have to avoid reading the exit code of local:
29+
# "when declaring a local variable in a function, the local acts as a command in its own right"
30+
local build_stdout
31+
build_stdout=$(arduino --verify $sketch 2>&1)
32+
33+
# echo output if the build failed
34+
if [ $? -ne 0 ]; then
35+
# heavy X
36+
echo -e "\xe2\x9c\x96"
37+
echo -e "----------------------------- DEBUG OUTPUT -----------------------------\n"
38+
echo "$build_stdout"
39+
echo -e "\n------------------------------------------------------------------------\n"
40+
41+
# mark as fail
42+
exit_code=1
43+
44+
else
45+
# heavy checkmark
46+
echo -e "\xe2\x9c\x93"
47+
fi
48+
done
49+
50+
return $exit_code
51+
}

0 commit comments

Comments
 (0)