-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclone-and-build.sh
executable file
·115 lines (106 loc) · 3.33 KB
/
clone-and-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# This script
# - clones the libigl github repo into a temporary directory
# - updates submodules
# - compiles static library
# - compiles tutorial
# If any steps fail then an email is sent to a list of recipients (add yourself
# if you'd like to be alerted to failures, see below regarding spam filters).
#
# You can set up an automated nightly build-check at 2:30 AM using:
#
# crontab -e
#
# and then add the line:
#
# 30 2 * * * source /Users/ajx/.profile; /usr/local/igl/libigl/scripts/clone-and-build.sh
#
# replace the path above with the **full path** to this file.
#
# Report that a command has failed and list its output
#
# report_error command output
#
# Note: Most mail clients will mark these messages as spam even if the local
# sender (e.g. ajx@luftmatratze.local) is in your contact list. To force these
# message to be not marked as spam, create a filter.
#
# You can test your spam settings with
#
# echo "t3st 3mail" | mail -s "libigl test email" youremail@gmail.com
#
# This will almost certainly end up in your spam, but you can find your default
# email address as the sender and add a filter.
#
function report_error {
subject="$(echo -e "libigl compilation failure: $1 \nContent-Type: text/html")"
recipients="alecjacobson@gmail.com"
pre_style="style='background-color: #c3e0f0; overflow: auto; padding-left: 8px; padding-right: 8px; padding-top: 4px; padding-bottom: 4px; border: 1px solid #999;'";
html_content="
<p>
The following command failed during the last nightly libigl build:
<pre $pre_style><code>$(echo -e "$1" | \
sed \
's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g')
</code></pre>
</p>
<p>
The command produced the following standard output/error before failing:
<pre $pre_style><code>$(echo -e "$2" | \
sed \
's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g')
</code></pre>
</p>
<p>
<a href=https://github.com/libigl/libigl/>libigl github</a> | <a href=https://github.com/libigl/libigl/commits/master>commits</a>
</p>
"
echo -e "$html_content" | mail -s "$subject" $recipients
}
# Runs the arguments as a command as usual, but if the command fails send an
# email using `report_error` and exit without continuing
#
# guard command arg1 arg2 ...
#
function guard {
command="$@"
pwd
echo "$command"
if ! output=$($command 2>&1) ;
then
report_error "$command" "$output"
echo "'$command' failed. Report sent."
exit 1
fi
}
function grep_std_1
{
(! grep -rI "std::__1" *)
}
set -o xtrace
# Clone repo
guard rm -rf /var/tmp/libigl
cd /var/tmp/
guard git clone --recursive git@github.com:libigl/libigl.git
cd libigl
# Build static library
mkdir lib
cd lib
# Redundant paths make it clear which command is failing
guard cmake -DCMAKE_BUILD_TYPE=Debug ../optional/
guard make -C ../lib
# Build tutorial with default settings
mkdir ../tutorial/build
cd ../tutorial/build
guard cmake -DCMAKE_BUILD_TYPE=Debug ../../tutorial/
guard make -C ../../tutorial/build
# Build tutorial with static library
cd ../
mkdir build-use-static
cd build-use-static
guard cmake -DCMAKE_BUILD_TYPE=Debug -DLIBIGL_USE_STATIC_LIBRARY=ON ../../tutorial/
guard make -C ../../tutorial/build-use-static
# check that no files contain `std::__1` often coming from templates copied
# from clang output. These will fail on gcc
cd ../../include/igl
guard grep_std_1