Last active
December 31, 2019 13:46
-
-
Save matths/a5f315bc3d2332ec3429aaf930183d6e to your computer and use it in GitHub Desktop.
Install better-sqlite3 node package with custom sqlcipher amalgamation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# build the SQLCipher .c/.h files | |
git clone https://github.com/sqlcipher/sqlcipher.git | |
cd sqlcipher | |
./configure --enable-tempstore=yes --enable-fts5 CFLAGS="-DSQLITE_HAS_CODEC" | |
make sqlite3.c | |
# prepend better-sqlite3 configuration | |
# https://github.com/JoshuaWise/better-sqlite3/blob/v5.0.1/docs/compilation.md | |
echo "#define SQLITE_THREADSAFE 0" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_DEFAULT_MEMSTATUS 0" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_OMIT_DEPRECATED 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_OMIT_GET_TABLE 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_OMIT_TRACE 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_OMIT_TCL_VARIABLE 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_OMIT_PROGRESS_CALLBACK 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_DEFAULT_CACHE_SIZE -16000" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_DEFAULT_FOREIGN_KEYS 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_DEFAULT_WAL_SYNCHRONOUS 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_USE_URI 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_COLUMN_METADATA 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_UPDATE_DELETE_LIMIT 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_STAT4 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_FTS3_PARENTHESIS 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_FTS3 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_FTS4 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_FTS5 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_JSON1 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_ENABLE_RTREE 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_INTROSPECTION_PRAGMAS 1" | tee -a sqlite3.c_temp | |
echo "#define SQLITE_SOUNDEX 1" | tee -a sqlite3.c_temp | |
# prepend custom configuration | |
echo "#define SQLITE_HAS_CODEC 1" | tee -a sqlite3.c_temp sqlite3.h_temp | |
echo "#define SQLITE_TEMP_STORE 2" | tee -a sqlite3.c_temp sqlite3.h_temp | |
cat sqlite3.c >> sqlite3.c_temp | |
cat sqlite3.h >> sqlite3.h_temp | |
mv -f sqlite3.c_temp sqlite3.c | |
mv -f sqlite3.h_temp sqlite3.h | |
# install better-sqlite3 with custom amalgamation | |
cd .. | |
npm install --save better-sqlite3 --sqlite3=./sqlcipher/ | |
rm -Rf sqlcipher |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment