forked from evpo/EncryptPad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·210 lines (193 loc) · 5.38 KB
/
configure.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/usr/bin/env bash
set -e
set -o pipefail
USAGE="USAGE:\n\
configure.sh <command> [option]\n\n\
COMMANDS:\n\
-a, --all build everything required to run the application\n\
-c, --clean clean the application build files\n\
-r, --run run the application\n\
-b, --botan build Botan\n\
-o, --clean-botan clean Botan\n\
-e, --back-end build the back end with CLI\n\
-u, --tests build the unit tests\n\
-t, --run-tests run the unit tests\n\
-f, --run-func-tests run functional tests\n\
-n, --clean-tests clean the unit tests\n\
--culture-res build qm files from ts files to update culture resources\n\
--appimage build AppImage (requires AppImageKit and binaries)\n\
--docs build docs directory from markdown files (requres the markdown utility)\n\
--update-htm update htm files (README.htm and CHANGES.htm)\n\
-h, --help help\n\n\
OPTIONS:\n\
--debug debug configuration. If not specified, the release configuration is used. The unit tests\n\
are always built with the debug configuration.\n\
--use-system-libs use botan, zlib and other shared libraries installed on the system."
TARGET=encryptpad
OSX_APP=EncryptPad.app
TEST_TARGET=encrypt_pad_tests
if [[ $# > 3 ]] || [[ $# < 1 ]]
then
echo Invalid parameters >&2
echo -e "$USAGE"
exit -1
fi
UNAME=`uname`
MAKE="${MAKE:-make}"
if [[ $UNAME == *MINGW* ]]
then
MAKE=mingw32-make
fi
pushd ./build >/dev/null
SUBDIR=`./get_subdir.sh`
RELEASE=on
QT_BIN_SUB=release
while [[ $# > 0 ]]
do
case $1 in
-d|--debug)
RELEASE=
QT_BIN_SUB=debug
;;
--use-system-libs)
if [[ $UNAME == *MINGW* ]]
then
echo "--use-system-libs is not supported in MINGW"
exit -1
fi
USE_SYSTEM_LIBS=on
;;
*)
COMMAND=$1
;;
esac
shift
done
CONFIG_DIR=release
if [[ ! "$RELEASE" == "on" ]]
then
CONFIG_DIR=debug
fi
function build_all {
if [[ ! "$USE_SYSTEM_LIBS" == "on" ]]
then
$MAKE -f Makefile.botan
fi
$MAKE -f Makefile RELEASE=$RELEASE USE_SYSTEM_LIBS=$USE_SYSTEM_LIBS LOCALIZATION=$LOCALIZATION
if [[ $SUBDIR == *MACOS* ]]
then
pushd ../macos_deployment > /dev/null
./prepare_bundle.sh ../bin/${CONFIG_DIR}/${OSX_APP}
popd
fi
}
case $COMMAND in
-a|--all)
mkdir -p qt_build
build_all
;;
--culture-res)
for TSFILE in ../qt_ui/encryptpad_*.ts ../qt_ui/qt_excerpt_*.ts
do
CULTUREFILE=$(echo -n "$TSFILE" | sed -n -e "s/..\/qt_ui\///" -e "s/\.ts$//p")
if [[ $CULTUREFILE == encryptpad_en_gb ]]
then
continue
fi
echo $CULTUREFILE
lrelease $TSFILE -qm ../qt_ui/${CULTUREFILE}.qm
done
;;
--appimage)
USE_SYSTEM_LIBS=on
build_all
../linux_deployment/prepare-appimage.sh ./qt_deployment
mkdir -p ../bin
mv ./qt_deployment/encryptpad.AppImage ../bin/
;;
-c|--clean)
$MAKE -f Makefile.qt_ui clean RELEASE=$RELEASE
$MAKE -f Makefile clean RELEASE=$RELEASE
if [[ $SUBDIR == *MACOS* ]]
then
rm -Rf ../bin/${CONFIG_DIR}/${OSX_APP}
rm -f ../bin/${CONFIG_DIR}/encryptcli
elif [[ $UNAME == *MINGW* ]]
then
rm -f ../bin/${CONFIG_DIR}/${TARGET}.exe
rm -f ../bin/${CONFIG_DIR}/encryptcli.exe
else
rm -f ../bin/${CONFIG_DIR}/${TARGET}
rm -f ../bin/${CONFIG_DIR}/encryptcli
fi
;;
-r|--run)
if [[ $SUBDIR == *MACOS* ]]
then
../bin/${CONFIG_DIR}/${OSX_APP}/Contents/MacOS/${TARGET} &
else
../bin/${CONFIG_DIR}/${TARGET} &
fi
;;
-b|--botan) $MAKE -f Makefile.botan ;;
-o|--clean-botan) $MAKE -f Makefile.botan clean ;;
-e|--back-end)
$MAKE -f Makefile.back_end RELEASE=$RELEASE USE_SYSTEM_LIBS=$USE_SYSTEM_LIBS
$MAKE -f Makefile.cli RELEASE=$RELEASE USE_SYSTEM_LIBS=$USE_SYSTEM_LIBS
;;
-u|--tests) $MAKE -f Makefile.unit_tests USE_SYSTEM_LIBS=$USE_SYSTEM_LIBS;;
-n|--clean-tests)
$MAKE -f Makefile.unit_tests clean
rm -f ../bin/debug/${TEST_TARGET}
;;
-f|--run-func-tests)
pushd ../func_tests >/dev/null
./run_all_tests.sh ../bin/${CONFIG_DIR}/encryptcli
RESULT=$?
popd >/dev/null
exit $RESULT
;;
-t|--run-tests)
# Unit tests should run from tests directory because they need files the directory contains
pushd ../tests >/dev/null
../bin/debug/${TEST_TARGET}
RESULT=$?
popd >/dev/null
if [[ $RESULT != 0 ]]
then
popd >/dev/null
exit $RESULT
fi
# Functional tests
# pushd ../func_tests >/dev/null
# ./decryption_test.sh ../bin/${CONFIG_DIR}/encryptcli gpg_encrypted
# RESULT=$?
# popd >/dev/null
popd >/dev/null
exit $RESULT
;;
--docs)
mkdir -p ../bin
mkdir -p ../bin/docs
../contrib/markdown2web ../docs ../bin/docs
;;
--update-htm)
sed 1,/cutline/d ../README.md > /tmp/tmp_cut_readme.md
markdown /tmp/tmp_cut_readme.md > ../README.htm
cp /tmp/tmp_cut_readme.md ../docs/en/readme.md
rm /tmp/tmp_cut_readme.md
cp ../CHANGES.md ../docs/en/changes.md
markdown ../CHANGES.md > ../CHANGES.htm
;;
-h|--help)
echo -e "$USAGE"
;;
*) echo -e "$COMMAND is invalid parameter" >&2
echo -e "$USAGE"
popd >/dev/null
exit -1
;;
esac
RESULT=$?
popd >/dev/null
exit $RESULT