forked from evpo/EncryptPad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·162 lines (148 loc) · 3.97 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
#!/usr/bin/env bash
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\
-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
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
case $COMMAND in
-a|--all)
if [[ ! "$USE_SYSTEM_LIBS" == "on" ]]
then
$MAKE -f Makefile.botan
fi
$MAKE -f Makefile RELEASE=$RELEASE USE_SYSTEM_LIBS=$USE_SYSTEM_LIBS
if [[ $SUBDIR == *MACOS* ]]
then
cd ../macos_deployment && ./prepare_bundle.sh ../bin/${CONFIG_DIR}/${TARGET}.app
fi
;;
-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}/${TARGET}.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}/${TARGET}.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
;;
-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