-
Notifications
You must be signed in to change notification settings - Fork 11
/
build-libsass.sh
86 lines (73 loc) · 1.66 KB
/
build-libsass.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
#!/usr/bin/env bash
PRINT_USAGE() {
echo ""
echo "[LibSass Build Script Help]"
echo ""
echo "build-libsass.sh [options]"
echo ""
echo "options:"
echo " -d, --debug Debug build (by default Release build)"
echo " -h, --help Show help"
echo " -j [N], --jobs[=N] Multicore build, allow N jobs at once"
echo " -v, --verbose Display verbose output"
echo ""
echo "example:"
echo " ./build-libsass.sh"
echo "debug build:"
echo " ./build-libsass.sh --debug"
echo ""
}
_LOG_FILE_NAME="build-libsass.log"
_MULTICORE_BUILD=""
_VERBOSE=0
export DEBUG=0
while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
PRINT_USAGE
exit
;;
-d | --debug)
DEBUG=1
;;
-v | --verbose)
_VERBOSE=1
;;
-j | --jobs)
if [[ "$1" == "-j" && "$2" =~ ^[^-] ]]; then
_MULTICORE_BUILD="-j $2"
shift
else
_MULTICORE_BUILD="-j $(nproc)"
fi
;;
-j=* | --jobs=*)
_MULTICORE_BUILD=$1
if [[ "$1" =~ ^-j= ]]; then
_MULTICORE_BUILD="-j ${_MULTICORE_BUILD:3}"
else
_MULTICORE_BUILD="-j ${_MULTICORE_BUILD:7}"
fi
;;
*)
echo "Unknown option $1"
PRINT_USAGE
exit -1
;;
esac
shift
done
echo "Building LibSass ..."
_MAKE_ARGS="-C src/libsass ${_MULTICORE_BUILD}"
if [[ $_VERBOSE == 1 ]]; then
make $_MAKE_ARGS
else
make $_MAKE_ARGS >$_LOG_FILE_NAME 2>&1
fi
_RET=${PIPESTATUS[0]}
if [[ $_RET == 0 ]]; then
echo "Succeeded!"
else
echo "*** Error: Build failed!"
fi
exit $_RET