forked from paullepoulpe/curriculum-vitae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontMake.sh
executable file
·39 lines (30 loc) · 859 Bytes
/
contMake.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
#!/usr/bin/env sh
# Continuos compile script
# Waiting time in seconds
readonly WAIT_TIME=2
readonly BUILD=build
readonly TOKEN="$BUILD/.token"
readonly OBJ="$BUILD/cv.pdf"
compile() {
# Register new time of compilation
touch "$TOKEN"
# Remove old pdf files
rm "$OBJ"
# Build with error message in red
make "$OBJ" 2>&1 | egrep -i --color=always '[^:]*error.*|$'
echo "[build] Waiting for source changes ..."
}
# Launch clean and compile when run for the first time
make veryclean
compile
while true; do
# Check if anything has changed since last compile
CHANGED_FILES=$(find . -name '*.tex' -newer $TOKEN)
if [ ! -z "$CHANGED_FILES" ]; then
# If anything changed, rebuild
echo "[build] Change detected, recompiling ..."
compile
fi
# Wait for a bit ...
sleep $WAIT_TIME
done