Skip to content

Commit

Permalink
sqlcipher support
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Apr 2, 2021
1 parent 4dc52f1 commit 5acdaf9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.lzz linguist-language=C++
deps/sqlite3.tar.gz filter=lfs diff=lfs merge=lfs -text
11 changes: 5 additions & 6 deletions deps/defines.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

{
'defines': [
'SQLITE_DQS=0',
'SQLITE_LIKE_DOESNT_MATCH_BLOBS',
'SQLITE_THREADSAFE=2',
'SQLITE_USE_URI=0',
Expand All @@ -19,14 +18,14 @@
'SQLITE_ENABLE_COLUMN_METADATA',
'SQLITE_ENABLE_UPDATE_DELETE_LIMIT',
'SQLITE_ENABLE_STAT4',
'SQLITE_ENABLE_FTS3_PARENTHESIS',
'SQLITE_ENABLE_FTS3',
'SQLITE_ENABLE_FTS4',
'SQLITE_ENABLE_FTS5',
'SQLITE_ENABLE_JSON1',
'SQLITE_ENABLE_RTREE',
'SQLITE_ENABLE_GEOPOLY',
'SQLITE_INTROSPECTION_PRAGMAS',
'SQLITE_SOUNDEX',

# SQLCipher-specific options
'SQLITE_HAS_CODEC',
'SQLITE_TEMP_STORE=2',
'SQLITE_SECURE_DELETE',
],
}
106 changes: 80 additions & 26 deletions deps/sqlite3.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,108 @@
'target_name': 'locate_sqlite3',
'type': 'none',
'hard_dependency': 1,
'conditions': [
['sqlite3 == ""', {
'actions': [{
'action_name': 'extract_sqlite3',
'inputs': ['sqlite3.tar.gz'],
'actions': [{
'action_name': 'extract_sqlite3',
'inputs': ['sqlite3.tar.gz'],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3ext.h',
],
'conditions': [
['OS == "win"', {
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3ext.h',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/>(openssl_root)/libssl.lib',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/>(openssl_root)/libcrypto.lib',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/>(openssl_root)/ossl_static.pdb',
],
'action': ['node', 'extract.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3'],
}],
}, {
'actions': [{
'action_name': 'symlink_sqlite3',
'inputs': [],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
],
'action': ['node', 'extract.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3'],
}],
},
{
'target_name': 'copy_dll',
'type': 'none',
'dependencies': ['locate_sqlite3'],
'conditions': [
['OS == "win"', {
'copies': [{
'files': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/>(openssl_root)/libssl.lib',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/>(openssl_root)/libcrypto.lib',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/>(openssl_root)/ossl_static.pdb',
],
'action': ['node', 'symlink.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '<(sqlite3)'],
'destination': '<(PRODUCT_DIR)',
}],
}],
],
},
{
'target_name': 'sqlite3',
'type': 'static_library',
'dependencies': ['locate_sqlite3'],
'dependencies': ['locate_sqlite3', 'copy_dll'],
'sources': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c'],
'include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/'],
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/openssl-include',
],
'direct_dependent_settings': {
'include_dirs': ['<(SHARED_INTERMEDIATE_DIR)/sqlite3/'],
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/',
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/openssl-include',
],
},
'cflags': ['-std=c99', '-w'],
'xcode_settings': {
'OTHER_CFLAGS': ['-std=c99'],
'WARNING_CFLAGS': ['-w'],
},
'includes': ['defines.gypi'],
'conditions': [
['sqlite3 == ""', {
'includes': ['defines.gypi'],
}, {
['OS == "win"', {
'defines': [
# This is currently required by better-sqlite3.
'SQLITE_ENABLE_COLUMN_METADATA',
'WIN32'
],
}]
'conditions': [
['target_arch == "ia32"', {
'variables': {
'openssl_root%': 'OpenSSL-Win32',
}
}, {
'variables': {
'openssl_root%': 'OpenSSL-Win64',
}
}]
],
'link_settings': {
'libraries': [
'-llibcrypto.lib',
'-llibssl.lib',
'-lws2_32.lib',
'-lcrypt32.lib'
],
'library_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/<(openssl_root)'
]
}
},
'OS == "mac"', {
'link_settings': {
'libraries': [
# This statically links libcrypto, whereas -lcrypto would dynamically link it
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/OpenSSL-macOS/libcrypto.a'
]
}
},
{ # Linux
'link_settings': {
'libraries': [
# This statically links libcrypto, whereas -lcrypto would dynamically link it
'<(SHARED_INTERMEDIATE_DIR)/sqlite3/OpenSSL-Linux/libcrypto.a'
]
}
}],
],
'configurations': {
'Debug': {
Expand Down
Binary file modified deps/sqlite3.tar.gz
Binary file not shown.

0 comments on commit 5acdaf9

Please sign in to comment.