forked from SmartisanTech/Wrench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-linux.sh
executable file
·195 lines (165 loc) · 4.86 KB
/
build-linux.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/usr/bin/env bash
set -e
echo Entering directory \`$PWD\'
## start code-generator "^\\s *#\\s *"
# generate-getopts r:release_dir=Wrench-debian b:build-dir=~/.cache/build-wrench ddo-debug sstart-it
## end code-generator
## start generated code
TEMP=$(POSIXLY_CORRECT=true getopt -o b:dr:sh \
--long build-dir:,do-debug,release_dir:,start-it,help,no-do-debug,no-start-it \
-n $(basename -- $0) -- "$@")
declare build_dir=~/.cache/build-wrench
declare do_debug=false
declare release_dir=Wrench-debian
declare start_it=false
eval set -- "$TEMP"
while true; do
case "$1" in
-b|--build-dir)
build_dir=$2
shift 2
;;
-d|--do-debug|--no-do-debug)
if test "$1" = --no-do-debug; then
do_debug=false
else
do_debug=true
fi
shift
;;
-r|--release_dir)
release_dir=$2
shift 2
;;
-s|--start-it|--no-start-it)
if test "$1" = --no-start-it; then
start_it=false
else
start_it=true
fi
shift
;;
-h|--help)
set +x
echo -e
echo
echo Options and arguments:
printf %6s '-b, '
printf %-24s '--build-dir=BUILD_DIR'
echo
printf %6s '-d, '
printf %-24s '--[no-]do-debug'
echo
printf %6s '-r, '
printf %-24s '--release_dir=RELEASE_DIR'
echo
printf %6s '-s, '
printf %-24s '--[no-]start-it'
echo
exit
shift
;;
--)
shift
break
;;
*)
die "internal error: $(. bt; echo; bt | indent-stdin)"
;;
esac
done
## end generated code
cd $(dirname $(readlink -f $0))
if test "$do_debug" = true; then
build_dir=~/.cache/build-wrench-debug
fi
mkdir -p $build_dir
chmod u+w $build_dir
if type relative-link >/dev/null 2>&1; then
system_config=true
else
system_config=false
function relative-link() {
true
}
fi
relative-link -f $build_dir/Wrench ~/system-config/bin/overide
mkdir -p $build_dir
if test -f "$build_dir"/wrenchmainwindow.ui -a ! -L "$build_dir"/wrenchmainwindow.ui; then
mv "$build_dir"/wrenchmainwindow.ui "$build_dir"/wrenchmainwindow.ui.bak
fi
ln -sf $PWD/* "$build_dir"
if test "$SYSTEM_CONFIG_INITED" = true; then
rm "$build_dir"/wrenchmainwindow.ui
export Wrench_GIT_HASH=$(git log --pretty=%h -1 HEAD)
if git-any-changes -r HEAD; then
Wrench_GIT_HASH=${Wrench_GIT_HASH}-dirty
fi
perl -npe 's!<string>(Wrench\s*.*?)\(.*?\)</string>!<string>$1($ENV{Wrench_GIT_HASH})</string>!' \
wrenchmainwindow.ui > "$build_dir"/wrenchmainwindow.ui
if test -e "$build_dir"/wrenchmainwindow.ui.bak &&
diff -q "$build_dir"/wrenchmainwindow.ui "$build_dir"/wrenchmainwindow.ui.bak; then
mv "$build_dir"/wrenchmainwindow.ui.bak "$build_dir"/wrenchmainwindow.ui
fi
fi
oldpwd=$PWD
cd $build_dir
set -o pipefail
qmake_args=
if test "$do_debug" = true; then
qmake_args='WRENCH_DEBUG=1'
fi
for x in .; do
(
cd $x
qmake $qmake_args && make -j8 | perl -npe "s|$PWD|$oldpwd|g"
)
done
(
set -o pipefail
(
ln -sf $oldpwd/release/* $oldpwd/$(uname | perl -ne 'print lc $_')/binaries/* .
) 2>&1 |
if echo $SHELLOPTS | grep -q xtrace; then
cat
else
cat &>/dev/null
fi
)
(
if test "$DOING_WRENCH_RELEASE"; then
mkdir -p ~/src/github/$release_dir
command rsync -L $oldpwd/$(uname | perl -ne 'print lc $_')/binaries/* Wrench $oldpwd/release/ $oldpwd/*.lua ~/src/github/$release_dir -av --delete --exclude-from=$HOME/src/github/Wrench/release-exclude.txt
(
cd ~/src/github/$release_dir
git-mark-need-merge
)
exit
fi
if test "${start_it}" != true; then
exit
fi
if test "$system_config" = false; then
killall Wrench || true
./Wrench&
exit
fi
destroy-windows Wrench || true
(
cd $(dirname $(readlink -f $(which Wrench)))
ln -s $(which the-true-adb) . -f
) || true
ps-killall -p "$build_dir"/Wrench Wrench || true
if test $# = 1 && [[ "$1" =~ debug ]]; then
ps-killall gdb.Wrench
myscr bash -c 'LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu gdb ./Wrench'
find-or-exec konsole
else
rm $build_dir-debug/Wrench -f || true
mkfifo /tmp/build-linux.$$
chmod a-w $build_dir
myscr bash -c "echo Wrench; PATH=$build_dir:$PATH BUILDING_WRENCH=true Wrench.sh > /tmp/build-linux.$$ 2>&1"
cat /tmp/build-linux.$$
rm /tmp/build-linux.$$
fi
)