From 6453a86022deaafd2baf62a7554bc1d417326aa2 Mon Sep 17 00:00:00 2001 From: Daniel Cohen Gindi Date: Mon, 15 Apr 2019 09:10:53 +0300 Subject: [PATCH] Allow custom magic to be specified through --sqlite_magic --- README.md | 11 +++++++++++ deps/sqlite3.gyp | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f7097d8e..699f9234d 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,17 @@ This uses the npm_config_python config, so values in .npmrc will be honoured: python=/usr/bin/python2 +## Custom file header (magic) + +The default sqlite file header is "SQLite format 3". +You can specify a different magic, though this will make standard tools and libraries unable to work with your files. + + + npm install --build-from-source --sqlite_magic="MyCustomMagic15" + + +Note that the magic *must* be exactly 15 characters long (16 bytes including null terminator). + ## Building for node-webkit Because of ABI differences, `sqlite3` must be built in a custom to be used with [node-webkit](https://github.com/rogerwang/node-webkit). diff --git a/deps/sqlite3.gyp b/deps/sqlite3.gyp index 3e7ea75b6..54440690f 100755 --- a/deps/sqlite3.gyp +++ b/deps/sqlite3.gyp @@ -1,5 +1,10 @@ { 'includes': [ 'common-sqlite.gypi' ], + + 'variables': { + 'sqlite_magic%': '', + }, + 'target_defaults': { 'default_configuration': 'Release', 'cflags':[ @@ -101,7 +106,14 @@ ], 'export_dependent_settings': [ 'action_before_build', - ] + ], + 'conditions': [ + ["sqlite_magic != ''", { + 'defines': [ + 'SQLITE_FILE_HEADER="<(sqlite_magic)"' + ] + }] + ], } ] }