forked from fstl-app/fstl
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrebuild
More file actions
executable file
·97 lines (81 loc) · 2.52 KB
/
rebuild
File metadata and controls
executable file
·97 lines (81 loc) · 2.52 KB
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
#!/usr/bin/env bash
MOUNTMON_ROOT="${PWD}"
MAKEDIR="${MOUNTMON_ROOT}"
BUILDDIR="${MAKEDIR}/build"
PROJECTFILE="${MAKEDIR}/mountmon.pro"
rebuild () {
local BUILD=debug
local CLEAN=
local NUKE=
local QMAKE=
if ! getopt -Q -q -n 'rebuild' -o 'cnqrx' -l 'clean,nuke-first,qmake-anyway,release' -- "$@"; then
cat <<HERE
Runs "qmake" to regenerate the Makefile, if necessary, then "make" to
rebuild mountmon.
Usage: rebuild [-cnqrx] [--clean|--nuke-first|--qmake-anyway|--release]
-c, --clean Run "make distclean" before running "make".
-n, -x, --nuke-first Delete and recreate the build directory before
running "make".
-q, --qmake-anyway Run "qmake" even if timestamps suggest it
shouldn't be necessary.
-r, --release Perform a release build instead of a debug
build.
HERE
return
fi
local ARGS=$(getopt -n 'rebuild' -o 'cnqrx' -l 'clean,nuke-first,qmake-anyway,release' -- "$@")
eval set -- "$ARGS"
while [ -n "${1}" ]
do
case "${1}" in
'-c' | '--clean' ) CLEAN=yes ;;
'-n' | '-x' | '--nuke-first' ) NUKE=yes ;;
'-q' | '--qmake-anyway' ) QMAKE=yes ;;
'-r' | '--release' ) BUILD=release ;;
'--' )
shift
break
;;
* )
echo "Unknown option: '${1}'" 1>&2
return
;;
esac
shift
done
if [ -d "${BUILDDIR}" ]
then
if [ ! -f "${BUILDDIR}/.lastbuildmode" ]
then
echo ${BUILD} > ${BUILDDIR}/.lastbuildmode
NUKE=yes
fi
local LASTBUILDMODE="$(<${BUILDDIR}/.lastbuildmode)"
if [ -n "${LASTBUILDMODE}" -a "${BUILD}" != "${LASTBUILDMODE}" ]
then
echo Switching from ${LASTBUILDMODE} to ${BUILD}.
NUKE=yes
fi
if [ -n "${NUKE}" ]
then
unset CLEAN
QMAKE=yes
rm -dr ${BUILDDIR} && mkdir -p ${BUILDDIR}
fi
else
mkdir -p ${BUILDDIR}
fi
cd ${MAKEDIR}
if [ -n "${CLEAN}" ]
then
QMAKE=yes
make distclean
fi
if [ -n "${QMAKE}" -o ! -f Makefile -o ${PROJECTFILE} -nt Makefile ]
then
qmake CONFIG+=${BUILD} ${PROJECTFILE} || return
echo "${BUILD}" > ${BUILDDIR}/.lastbuildmode
fi
make -j${QT_BUILD_JOBS-12}
}
rebuild $*