Skip to content

Commit 158e8b9

Browse files
Trigger amalgamation generation from ./gradlew build
1 parent d50997c commit 158e8b9

File tree

4 files changed

+179
-0
lines changed

4 files changed

+179
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.gradle
22
build
33
.DS_Store
4+
android-database-sqlcipher/src/main/external/sqlcipher
5+
android-database-sqlcipher/src/main/external/openssl
6+
android-database-sqlcipher/src/main/external/android-libs/
7+
android-database-sqlcipher/.externalNativeBuild/
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#! /usr/bin/env bash
2+
(cd src/main/external/openssl;
3+
4+
if [ ! ${ANDROID_NDK_ROOT} ]; then
5+
echo "ANDROID_NDK_ROOT environment variable not set, set and rerun"
6+
exit 1
7+
fi
8+
9+
ANDROID_LIB_ROOT=../android-libs
10+
ANDROID_TOOLCHAIN_DIR=/tmp/sqlcipher-android-toolchain
11+
OPENSSL_CONFIGURE_OPTIONS="no-krb5 no-idea no-camellia \
12+
no-seed no-bf no-cast no-rc2 no-rc4 no-rc5 no-md2 \
13+
no-md4 no-ripemd no-rsa no-ecdh no-sock no-ssl2 no-ssl3 \
14+
no-dsa no-dh no-ec no-ecdsa no-tls1 no-pbe no-pkcs \
15+
no-tlsext no-pem no-rfc3779 no-whirlpool no-ui no-srp \
16+
no-ssltrace no-tlsext no-mdc2 no-ecdh no-engine \
17+
no-tls2 no-srtp -fPIC"
18+
19+
HOST_INFO=`uname -a`
20+
case ${HOST_INFO} in
21+
Darwin*)
22+
TOOLCHAIN_SYSTEM=darwin-x86
23+
;;
24+
Linux*)
25+
if [[ "${HOST_INFO}" == *i686* ]]
26+
then
27+
TOOLCHAIN_SYSTEM=linux-x86
28+
else
29+
TOOLCHAIN_SYSTEM=linux-x86_64
30+
fi
31+
;;
32+
*)
33+
echo "Toolchain unknown for host system"
34+
exit 1
35+
;;
36+
esac
37+
38+
rm -rf ${ANDROID_LIB_ROOT}
39+
#git clean -dfx && git checkout -f
40+
./Configure dist
41+
42+
for SQLCIPHER_TARGET_PLATFORM in armeabi armeabi-v7a x86 x86_64 arm64-v8a
43+
do
44+
echo "Building for libcrypto.a for ${SQLCIPHER_TARGET_PLATFORM}"
45+
case "${SQLCIPHER_TARGET_PLATFORM}" in
46+
armeabi)
47+
TOOLCHAIN_ARCH=arm
48+
TOOLCHAIN_PREFIX=arm-linux-androideabi
49+
CONFIGURE_ARCH=android
50+
PLATFORM_OUTPUT_DIR=armeabi
51+
ANDROID_PLATFORM_VERSION=android-9
52+
;;
53+
armeabi-v7a)
54+
TOOLCHAIN_ARCH=arm
55+
TOOLCHAIN_PREFIX=arm-linux-androideabi
56+
CONFIGURE_ARCH=android -march=armv7-a
57+
PLATFORM_OUTPUT_DIR=armeabi-v7a
58+
ANDROID_PLATFORM_VERSION=android-9
59+
;;
60+
x86)
61+
TOOLCHAIN_ARCH=x86
62+
TOOLCHAIN_PREFIX=i686-linux-android
63+
CONFIGURE_ARCH=android-x86
64+
PLATFORM_OUTPUT_DIR=x86
65+
ANDROID_PLATFORM_VERSION=android-9
66+
;;
67+
x86_64)
68+
TOOLCHAIN_ARCH=x86_64
69+
TOOLCHAIN_PREFIX=x86_64-linux-android
70+
CONFIGURE_ARCH=android64
71+
PLATFORM_OUTPUT_DIR=x86_64
72+
ANDROID_PLATFORM_VERSION=android-21
73+
;;
74+
arm64-v8a)
75+
TOOLCHAIN_ARCH=arm64
76+
TOOLCHAIN_PREFIX=aarch64-linux-android
77+
CONFIGURE_ARCH=android64-aarch64
78+
PLATFORM_OUTPUT_DIR=arm64-v8a
79+
ANDROID_PLATFORM_VERSION=android-21
80+
;;
81+
*)
82+
echo "Unsupported build platform:${SQLCIPHER_TARGET_PLATFORM}"
83+
exit 1
84+
esac
85+
86+
rm -rf ${ANDROID_TOOLCHAIN_DIR}
87+
mkdir -p "${ANDROID_LIB_ROOT}/${SQLCIPHER_TARGET_PLATFORM}"
88+
${ANDROID_NDK_ROOT}/build/tools/make-standalone-toolchain.sh \
89+
--platform=${ANDROID_PLATFORM_VERSION} \
90+
--install-dir=${ANDROID_TOOLCHAIN_DIR} \
91+
--arch=${TOOLCHAIN_ARCH}
92+
93+
export PATH=${ANDROID_TOOLCHAIN_DIR}/bin:$PATH
94+
export CROSS_SYSROOT=${ANDROID_TOOLCHAIN_DIR}/sysroot
95+
96+
RANLIB=${TOOLCHAIN_PREFIX}-ranlib \
97+
AR=${TOOLCHAIN_PREFIX}-ar \
98+
CC=${TOOLCHAIN_PREFIX}-gcc \
99+
./Configure "${CONFIGURE_ARCH}" "${OPENSSL_CONFIGURE_OPTIONS}"
100+
101+
if [ $? -ne 0 ]; then
102+
echo "Error executing:./Configure ${CONFIGURE_ARCH} ${OPENSSL_CONFIGURE_OPTIONS}"
103+
exit 1
104+
fi
105+
106+
make clean
107+
make
108+
109+
if [ $? -ne 0 ]; then
110+
echo "Error executing make for platform:${SQLCIPHER_TARGET_PLATFORM}"
111+
exit 1
112+
fi
113+
114+
mv libcrypto.a ${ANDROID_LIB_ROOT}/${PLATFORM_OUTPUT_DIR}
115+
done
116+
)

android-database-sqlcipher/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,38 @@ android {
2525
}
2626
}
2727

28+
task buildOpenSSL (type:Exec) {
29+
workingDir "${projectDir}"
30+
commandLine "./build-openssl-libraries.sh"
31+
}
32+
33+
task buildAmalgamation () {
34+
doLast {
35+
exec {
36+
workingDir "${projectDir}/src/main/external/sqlcipher"
37+
environment("CFLAGS", "${rootProject.ext.sqlcipherCFlags}")
38+
commandLine "./configure", "--enable-tempstore=yes", "--with-crypto-lib=none"
39+
}
40+
exec {
41+
workingDir "${projectDir}/src/main/external/sqlcipher"
42+
environment("CFLAGS", "${rootProject.ext.sqlcipherCFlags}")
43+
commandLine "make", "sqlite3.c"
44+
}
45+
}
46+
}
47+
48+
preBuild.dependsOn buildAmalgamation
49+
50+
// task cleanOpenSSL() {
51+
// println "OpenSSL dir:${rootProject.ext.opensslDir}"
52+
// println "Cleaning OpenSSL"
53+
// }
54+
55+
// task cleanSQLCipher() {
56+
// println "SQLCipher dir:${rootProject.ext.sqlcipherDir}"
57+
// println "Cleaning SQLCipher"
58+
// }
59+
2860
}
2961

3062
dependencies {

build.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,33 @@ allprojects {
1818
}
1919
}
2020

21+
ext {
22+
sqlcipherDir = "${projectDir}/${name}/src/main/external/sqlcipher"
23+
opensslDir = "${projectDir}/${name}/src/main/external/openssl"
24+
sqlcipherCFlags = "-DSQLITE_HAS_CODEC " +
25+
"-DSQLITE_SOUNDEX " +
26+
"-DHAVE_USLEEP=1 " +
27+
"-DSQLITE_TEMP_STORE=3 " +
28+
"-DSQLITE_THREADSAFE=1 " +
29+
"-DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 " +
30+
"-DNDEBUG=1 " +
31+
"-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 " +
32+
"-DSQLITE_ENABLE_LOAD_EXTENSION " +
33+
"-DSQLITE_ENABLE_COLUMN_METADATA " +
34+
"-DSQLITE_ENABLE_UNLOCK_NOTIFY " +
35+
"-DSQLITE_ENABLE_RTREE " +
36+
"-DSQLITE_ENABLE_STAT3 " +
37+
"-DSQLITE_ENABLE_STAT4 " +
38+
"-DSQLITE_ENABLE_JSON1 " +
39+
"-DSQLITE_ENABLE_FTS3_PARENTHESIS " +
40+
"-DSQLITE_ENABLE_FTS4 " +
41+
"-DSQLITE_ENABLE_FTS5 " +
42+
"-DSQLCIPHER_CRYPTO_OPENSSL"
43+
}
44+
45+
// task clean(type: Delete, dependsOn: [cleanOpenSSL, cleanSQLCipher]) {
46+
// delete rootProject.buildDir
47+
// }
2148
task clean(type: Delete) {
2249
delete rootProject.buildDir
2350
}

0 commit comments

Comments
 (0)