2018-08-20 20:17:35 +03:00
#!/usr/bin/env bash
2018-05-25 23:39:00 +03:00
2018-08-04 02:25:10 +03:00
set -euvx
2018-05-25 23:39:00 +03:00
2019-07-09 21:00:48 +03:00
# SQLCIPHER_VERSION="4.1.0"
# SQLCIPHER_SHA256="65144ca3ba4c0f9cd4bae8c20bb42f2b84424bf29d1ebcf04c44a728903b1faa"
2018-05-25 23:39:00 +03:00
2019-08-30 20:48:57 +03:00
NSS = "nss-3.46"
NSS_ARCHIVE = "nss-3.46-with-nspr-4.22.tar.gz"
NSS_URL = " http://ftp.mozilla.org/pub/security/nss/releases/NSS_3_46_RTM/src/ ${ NSS_ARCHIVE } "
NSS_SHA256 = "3d4197196e870ab2dccc6ee497e0ec83f45ea070fee929dd931491c024d69f31"
2019-03-27 00:35:50 +03:00
2018-05-25 23:39:00 +03:00
# End of configuration.
2019-07-24 22:51:06 +03:00
if [ [ ! -f " $( pwd ) /build-all.sh " ] ]
2019-05-29 23:12:28 +03:00
then
echo "build-all.sh must be executed from within the libs/ directory."
exit 1
fi
2019-07-24 22:51:06 +03:00
if [ [ " ${# } " -ne 1 ] ]
2018-05-25 23:39:00 +03:00
then
echo "Usage:"
2018-05-28 21:44:34 +03:00
echo "./build-all.sh [ios|android|desktop]"
2018-05-25 23:39:00 +03:00
exit 1
fi
2019-04-11 18:04:58 +03:00
PLATFORM = " ${ 1 } "
2018-05-25 23:39:00 +03:00
2019-04-11 18:04:58 +03:00
abspath ( ) { case " ${ 1 } " in /*) printf "%s\\n" " ${ 1 } " ; ; *) printf "%s\\n" " ${ PWD } / ${ 1 } " ; ; esac ; }
2018-05-25 23:39:00 +03:00
export -f abspath
2019-07-24 22:51:06 +03:00
if ! [ [ -x " $( command -v gyp) " ] ] ; then
2019-07-10 01:27:40 +03:00
echo 'Error: gyp needs to be installed and executable. See https://github.com/mogemimi/pomdog/wiki/How-to-Install-GYP for install instructions.' >& 2
exit 1
fi
2019-07-24 22:51:06 +03:00
if ! [ [ -x " $( command -v ninja) " ] ] ; then
2019-07-10 01:27:40 +03:00
echo 'Error: ninja needs to be installed and executable. See https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages for install instructions.' >& 2
exit 1
fi
2019-07-17 21:21:18 +03:00
# SQLCipher needs TCL.
2019-07-24 22:51:06 +03:00
if ! [ [ -x " $( command -v tclsh) " ] ] ; then
2019-07-17 21:21:18 +03:00
echo 'Error: tclsh needs to be installed and executable. See https://www.tcl.tk/software/tcltk/.' >& 2
exit 1
fi
2019-07-09 21:00:48 +03:00
# Delete the following...
rm -rf sqlcipher
git clone --single-branch --branch nss-crypto-impl --depth 1 "https://github.com/eoger/sqlcipher.git"
SQLCIPHER_SRC_PATH = $( abspath "sqlcipher" )
# ... and uncomment the following once SQLCipher has an NSS crypto backend.
# SQLCIPHER="v${SQLCIPHER_VERSION}"
# rm -rf "${SQLCIPHER}"
2019-07-24 22:51:06 +03:00
# if [[ ! -e "${SQLCIPHER}.tar.gz" ]]; then
2019-07-09 21:00:48 +03:00
# echo "Downloading ${SQLCIPHER}.tar.gz"
# curl -L -O "https://github.com/sqlcipher/sqlcipher/archive/${SQLCIPHER}.tar.gz"
# else
# echo "Using ${SQLCIPHER}.tar.gz"
# fi
# echo "${SQLCIPHER_SHA256} ${SQLCIPHER}.tar.gz" | shasum -a 256 -c - || exit 2
# tar xfz "${SQLCIPHER}.tar.gz"
# SQLCIPHER_SRC_PATH=$(abspath "sqlcipher-${SQLCIPHER_VERSION}")
2019-03-27 00:35:50 +03:00
2019-04-11 18:04:58 +03:00
rm -rf " ${ NSS } "
2019-08-30 20:48:57 +03:00
if [ [ ! -e " ${ NSS_ARCHIVE } " ] ] ; then
echo " Downloading ${ NSS_ARCHIVE } "
curl -L -O " ${ NSS_URL } "
else
echo " Using ${ NSS_ARCHIVE } "
fi
echo " ${ NSS_SHA256 } ${ NSS_ARCHIVE } " | shasum -a 256 -c - || exit 2
tar xfz " ${ NSS_ARCHIVE } "
2019-04-11 18:04:58 +03:00
NSS_SRC_PATH = $( abspath " ${ NSS } " )
2019-07-09 21:00:48 +03:00
# Some NSS symbols clash with OpenSSL symbols, rename them using
# C preprocessor define macros.
echo $' \
diff -r 65efa74ef84a coreconf/config.gypi
--- a/coreconf/config.gypi Thu May 16 09:43:04 2019 +0000
+++ b/coreconf/config.gypi Thu May 23 19:46:44 2019 -0400
@@ -138,6 +138,21 @@
\' <( nspr_include_dir) \' ,
\' <( nss_dist_dir) /private/<( module) \' ,
] ,
+ \' defines\' : [
+ \' HMAC_Update = NSS_HMAC_Update\' ,
+ \' HMAC_Init = NSS_HMAC_Init\' ,
+ \' MD5_Update = NSS_MD5_Update\' ,
+ \' SHA1_Update = NSS_SHA1_Update\' ,
+ \' SHA256_Update = NSS_SHA256_Update\' ,
+ \' SHA224_Update = NSS_SHA224_Update\' ,
+ \' SHA512_Update = NSS_SHA512_Update\' ,
+ \' SHA384_Update = NSS_SHA384_Update\' ,
+ \' SEED_set_key = NSS_SEED_set_key\' ,
+ \' SEED_encrypt = NSS_SEED_encrypt\' ,
+ \' SEED_decrypt = NSS_SEED_decrypt\' ,
+ \' SEED_ecb_encrypt = NSS_SEED_ecb_encrypt\' ,
+ \' SEED_cbc_encrypt = NSS_SEED_cbc_encrypt\' ,
+ ] ,
\' conditions\' : [
[ \' mozpkix_only = = 1 and OS = = "linux" \' , {
\' include_dirs\' : [
' | patch " ${ NSS_SRC_PATH } /nss/coreconf/config.gypi "
2018-08-04 02:26:45 +03:00
2019-07-24 22:51:06 +03:00
if [ [ " ${ PLATFORM } " = = "ios" ] ]
2018-05-25 23:39:00 +03:00
then
2019-08-14 20:57:50 +03:00
./build-all-ios.sh " ${ SQLCIPHER_SRC_PATH } " " ${ NSS_SRC_PATH } "
2019-07-24 22:51:06 +03:00
elif [ [ " ${ PLATFORM } " = = "android" ] ]
2018-05-25 23:39:00 +03:00
then
2019-08-14 20:57:50 +03:00
./build-all-android.sh " ${ SQLCIPHER_SRC_PATH } " " ${ NSS_SRC_PATH } "
2019-07-24 22:51:06 +03:00
elif [ [ " ${ PLATFORM } " = = "desktop" ] ]
2018-05-28 21:44:34 +03:00
then
2019-04-11 18:04:58 +03:00
./build-nss-desktop.sh " ${ NSS_SRC_PATH } "
./build-sqlcipher-desktop.sh " ${ SQLCIPHER_SRC_PATH } "
2019-07-24 22:51:06 +03:00
elif [ [ " ${ PLATFORM } " = = "darwin" ] ] || [ [ " ${ PLATFORM } " = = "win32-x86-64" ] ]
2018-11-02 06:40:29 +03:00
then
2019-04-11 18:04:58 +03:00
./build-nss-desktop.sh " ${ NSS_SRC_PATH } " " ${ PLATFORM } "
./build-sqlcipher-desktop.sh " ${ SQLCIPHER_SRC_PATH } " " ${ PLATFORM } "
2018-05-25 23:39:00 +03:00
else
echo "Unrecognized platform"
exit 1
fi
echo "Cleaning up"
2019-04-11 18:04:58 +03:00
rm -rf " ${ SQLCIPHER_SRC_PATH } "
rm -rf " ${ NSS_SRC_PATH } "
2018-05-25 23:39:00 +03:00
echo "Done"