aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-wasm.c
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-03-08 10:05:42 +0000
committerstephan <stephan@noemail.net>2023-03-08 10:05:42 +0000
commit248c1abdf4c61bf0761994db40c214272a092c7c (patch)
treecdd199ae1f5b4b42c2d82a603ed88c9be3e76ce9 /ext/wasm/api/sqlite3-wasm.c
parent217e860053262181d175c5e209bec7d0da194c9f (diff)
downloadsqlite-248c1abdf4c61bf0761994db40c214272a092c7c.tar.gz
sqlite-248c1abdf4c61bf0761994db40c214272a092c7c.zip
Extend wasm build to support a custom sqlite3.c to support building against sqlite3-see.c. The JS code now binds the SEE-specific functions if it detects an SEE build.
FossilOrigin-Name: dd8612c8adbaf9d06bf0d7319b9afc9bd8ca3d0fcfa1cb591a7a2fcb86480048
Diffstat (limited to 'ext/wasm/api/sqlite3-wasm.c')
-rw-r--r--ext/wasm/api/sqlite3-wasm.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c
index bcabe922b..fd074541a 100644
--- a/ext/wasm/api/sqlite3-wasm.c
+++ b/ext/wasm/api/sqlite3-wasm.c
@@ -168,11 +168,6 @@
#endif
#include <assert.h>
-#include "sqlite3.c" /* yes, .c instead of .h. */
-
-#if defined(__EMSCRIPTEN__)
-# include <emscripten/console.h>
-#endif
/*
** SQLITE_WASM_EXPORT is functionally identical to EMSCRIPTEN_KEEPALIVE
@@ -201,6 +196,30 @@
// See also:
//__attribute__((export_name("theExportedName"), used, visibility("default")))
+/*
+** Which sqlite3.c we're using needs to be configurable to enable
+** building against a custom copy, e.g. the SEE variant. Note that we
+** #include the .c file, rather than the header, so that the WASM
+** extensions have access to private API internals.
+**
+** The caveat here is that custom variants need to account for
+** exporting any necessary symbols (e.g. sqlite3_activate_see()). We
+** cannot export them from here using SQLITE_WASM_EXPORT because that
+** attribute (apparently) has to be part of the function definition.
+*/
+#ifndef SQLITE_C
+# define SQLITE_C sqlite3.c /* yes, .c instead of .h. */
+#endif
+#define INC__STRINGIFY_(f) #f
+#define INC__STRINGIFY(f) INC__STRINGIFY_(f)
+#include INC__STRINGIFY(SQLITE_C)
+#undef INC__STRINGIFY_
+#undef INC__STRINGIFY
+#undef SQLITE_C
+
+#if defined(__EMSCRIPTEN__)
+# include <emscripten/console.h>
+#endif
#if 0
/*