forked from fstl-app/fstl
-
Notifications
You must be signed in to change notification settings - Fork 4
/
rebuild
executable file
·180 lines (151 loc) · 5.12 KB
/
rebuild
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/bash
LIGHTFIELD_ROOT="${PWD}"
#########################################################
## ##
## No user-serviceable parts below this point. ##
## ##
#########################################################
#########################################################
## ##
## No user-serviceable parts below this point. ##
## ##
#########################################################
# shellcheck disable=SC1090
source "${LIGHTFIELD_ROOT}/shared-stuff.sh"
[ -z "${BUILDDIR}" ] && export BUILDDIR="${LIGHTFIELD_ROOT}/build"
function usage () {
cat <<HERE
Usage: rebuild [-cnqrx] [--clean|--nuke-first|--qmake-anyway|--release]
Runs "qmake" to regenerate the Makefile, if necessary, then "make" to
rebuild LightField.
-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
}
function rebuild () {
local BUILD=debug
local CLEAN=
local NUKE=
local QMAKE=
local ARGS=
local LASTBUILDMODE=
local ADDTOCONFIG=
local PROJECTOR_TYPE=
case "${RELEASE_TRAIN}" in
'base' )
PROJECTOR_TYPE=dlpc350
;;
'xbase' )
ADDTOCONFIG=" experimental"
PROJECTOR_TYPE=dlpc350
;;
'dlp4710' )
ADDTOCONFIG=" dlp4710"
PROJECTOR_TYPE=dlp4710
;;
'xdlp4710' )
ADDTOCONFIG=" dlp4710 experimental"
PROJECTOR_TYPE=dlp4710
;;
'xdlp4710-20um' )
ADDTOCONFIG=" xdlp4710-20um experimental"
PROJECTOR_TYPE=dlp4710
;;
esac
if ! getopt -Q -q -n 'rebuild' -o 'cnqrx' -l 'clean,nuke-first,qmake-anyway,release' -- "$@"; then
usage
return
fi
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
;;
* )
return
;;
esac
shift
done
if [ -d "${BUILDDIR}" ]
then
if [ ! -f "${BUILDDIR}/.lastbuildmode" ]
then
echo "${BUILD}:${RELEASE_TRAIN}" > "${BUILDDIR}/.lastbuildmode"
NUKE=yes
fi
LASTBUILDMODE="$(<${BUILDDIR}/.lastbuildmode)"
if [ -n "${LASTBUILDMODE}" ] && [ "${LASTBUILDMODE}" != "${BUILD}:${RELEASE_TRAIN}" ]
then
echo Switching from "${LASTBUILDMODE}" to "${BUILD}:${RELEASE_TRAIN}".
NUKE=yes
fi
if [ -n "${NUKE}" ]
then
unset CLEAN
QMAKE=yes
rm -dr "${BUILDDIR}" && mkdir -p "${BUILDDIR}"
fi
else
mkdir -p "${BUILDDIR}"
fi
if [ ! -f "${LIGHTFIELD_ROOT}/src/version.h" ]
then
if [ -n "${RELEASE_TRAIN}" ] && [ -n "${VERSION}" ]
then
if ! "${LIGHTFIELD_ROOT}/change-version-number.sh" -t "${RELEASE_TRAIN}" "${VERSION}"
then
red-bar "Unable to generate missing src/version.h."
red-bar "Run change-version-number.sh manually."
exit 1
fi
else
red-bar "src/version.h does not exist, and the version number is unconfigured."
red-bar "Run change-version-number.sh manually."
exit 1
fi
fi
# shellcheck disable=SC2164
cd "${BUILDDIR}"
if [ -n "${CLEAN}" ]
then
QMAKE=yes
make distclean
fi
if [ -n "${QMAKE}" ] || [ ! -f Makefile ] || [ ../qt/lf.pro -nt Makefile ]
then
qmake CONFIG+="${BUILD}${ADDTOCONFIG}" ../qt/lf.pro || return
echo "${BUILD}:${RELEASE_TRAIN}" > "${BUILDDIR}/.lastbuildmode"
fi
if [ "${PROJECTOR_TYPE}" = "dlpc350" ]
then
cp -a ../images/dlpc350-focus-image.png ../images/focus-image.png
cp -a ../images/dlpc350-white-field.png ../images/white-field.png
elif [ "${PROJECTOR_TYPE}" = "dlp4710" ]
then
cp -a ../images/dlp4710-focus-image.png ../images/focus-image.png
cp -a ../images/dlp4710-white-field.png ../images/white-field.png
fi
if make -q 1>/dev/null 2>&1
then
echo "make: Nothing to be done for 'first'."
return
fi
# shellcheck disable=SC2015
[ -f buildinfo.o ] && rm buildinfo.o 1>/dev/null 2>&1 || true
make -j"${QT_BUILD_JOBS-3}"
}
rebuild "$@"