summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/embed
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-05-27 15:46:15 +0000
committerLibravatar GitHub <noreply@github.com>2024-05-27 17:46:15 +0200
commit1e7b32490dfdccddd04f46d4b0416b48d749d51b (patch)
tree62a11365933a5a11e0800af64cbdf9172e5e6e7a /vendor/github.com/ncruces/go-sqlite3/embed
parent[chore] Small styling + link issues (#2933) (diff)
downloadgotosocial-1e7b32490dfdccddd04f46d4b0416b48d749d51b.tar.xz
[experiment] add alternative wasm sqlite3 implementation available via build-tag (#2863)
This allows for building GoToSocial with [SQLite transpiled to WASM](https://github.com/ncruces/go-sqlite3) and accessed through [Wazero](https://wazero.io/).
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/embed')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/embed/README.md27
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/embed/build.sh32
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/embed/exports.txt130
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/embed/init.go20
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasmbin0 -> 1365178 bytes
5 files changed, 209 insertions, 0 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/embed/README.md b/vendor/github.com/ncruces/go-sqlite3/embed/README.md
new file mode 100644
index 000000000..400fe870a
--- /dev/null
+++ b/vendor/github.com/ncruces/go-sqlite3/embed/README.md
@@ -0,0 +1,27 @@
+# Embeddable Wasm build of SQLite
+
+This folder includes an embeddable Wasm build of SQLite 3.46.0 for use with
+[`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3).
+
+The following optional features are compiled in:
+- [math functions](https://sqlite.org/lang_mathfunc.html)
+- [FTS5](https://sqlite.org/fts5.html)
+- [JSON](https://sqlite.org/json1.html)
+- [R*Tree](https://sqlite.org/rtree.html)
+- [GeoPoly](https://sqlite.org/geopoly.html)
+- [soundex](https://sqlite.org/lang_corefunc.html#soundex)
+- [stat4](https://sqlite.org/compile.html#enable_stat4)
+- [base64](https://github.com/sqlite/sqlite/blob/master/ext/misc/base64.c)
+- [decimal](https://github.com/sqlite/sqlite/blob/master/ext/misc/decimal.c)
+- [ieee754](https://github.com/sqlite/sqlite/blob/master/ext/misc/ieee754.c)
+- [regexp](https://github.com/sqlite/sqlite/blob/master/ext/misc/regexp.c)
+- [series](https://github.com/sqlite/sqlite/blob/master/ext/misc/series.c)
+- [uint](https://github.com/sqlite/sqlite/blob/master/ext/misc/uint.c)
+- [uuid](https://github.com/sqlite/sqlite/blob/master/ext/misc/uuid.c)
+- [time](../sqlite3/time.c)
+
+See the [configuration options](../sqlite3/sqlite_cfg.h),
+and [patches](../sqlite3) applied.
+
+Built using [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk),
+and [`binaryen`](https://github.com/WebAssembly/binaryen). \ No newline at end of file
diff --git a/vendor/github.com/ncruces/go-sqlite3/embed/build.sh b/vendor/github.com/ncruces/go-sqlite3/embed/build.sh
new file mode 100644
index 000000000..abe5e60c4
--- /dev/null
+++ b/vendor/github.com/ncruces/go-sqlite3/embed/build.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+cd -P -- "$(dirname -- "$0")"
+
+ROOT=../
+BINARYEN="$ROOT/tools/binaryen-version_117/bin"
+WASI_SDK="$ROOT/tools/wasi-sdk-22.0/bin"
+
+"$WASI_SDK/clang" --target=wasm32-wasi -std=c17 -flto -g0 -O2 \
+ -Wall -Wextra -Wno-unused-parameter -Wno-unused-function \
+ -o sqlite3.wasm "$ROOT/sqlite3/main.c" \
+ -I"$ROOT/sqlite3" \
+ -mexec-model=reactor \
+ -msimd128 -mmutable-globals \
+ -mbulk-memory -mreference-types \
+ -mnontrapping-fptoint -msign-ext \
+ -fno-stack-protector -fno-stack-clash-protection \
+ -Wl,--initial-memory=327680 \
+ -Wl,--stack-first \
+ -Wl,--import-undefined \
+ -D_HAVE_SQLITE_CONFIG_H \
+ -DSQLITE_CUSTOM_INCLUDE=sqlite_opt.h \
+ $(awk '{print "-Wl,--export="$0}' exports.txt)
+
+trap 'rm -f sqlite3.tmp' EXIT
+"$BINARYEN/wasm-ctor-eval" -g -c _initialize sqlite3.wasm -o sqlite3.tmp
+"$BINARYEN/wasm-opt" -g --strip --strip-producers -c -O3 \
+ sqlite3.tmp -o sqlite3.wasm \
+ --enable-simd --enable-mutable-globals --enable-multivalue \
+ --enable-bulk-memory --enable-reference-types \
+ --enable-nontrapping-float-to-int --enable-sign-ext \ No newline at end of file
diff --git a/vendor/github.com/ncruces/go-sqlite3/embed/exports.txt b/vendor/github.com/ncruces/go-sqlite3/embed/exports.txt
new file mode 100644
index 000000000..b3cb1581c
--- /dev/null
+++ b/vendor/github.com/ncruces/go-sqlite3/embed/exports.txt
@@ -0,0 +1,130 @@
+aligned_alloc
+free
+malloc
+malloc_destructor
+sqlite3_anycollseq_init
+sqlite3_autovacuum_pages_go
+sqlite3_backup_finish
+sqlite3_backup_init
+sqlite3_backup_pagecount
+sqlite3_backup_remaining
+sqlite3_backup_step
+sqlite3_bind_blob64
+sqlite3_bind_double
+sqlite3_bind_int64
+sqlite3_bind_null
+sqlite3_bind_parameter_count
+sqlite3_bind_parameter_index
+sqlite3_bind_parameter_name
+sqlite3_bind_pointer_go
+sqlite3_bind_text64
+sqlite3_bind_value
+sqlite3_bind_zeroblob64
+sqlite3_blob_bytes
+sqlite3_blob_close
+sqlite3_blob_open
+sqlite3_blob_read
+sqlite3_blob_reopen
+sqlite3_blob_write
+sqlite3_busy_handler_go
+sqlite3_busy_timeout
+sqlite3_changes64
+sqlite3_clear_bindings
+sqlite3_close
+sqlite3_close_v2
+sqlite3_collation_needed_go
+sqlite3_column_blob
+sqlite3_column_bytes
+sqlite3_column_count
+sqlite3_column_database_name
+sqlite3_column_decltype
+sqlite3_column_double
+sqlite3_column_int64
+sqlite3_column_name
+sqlite3_column_origin_name
+sqlite3_column_table_name
+sqlite3_column_text
+sqlite3_column_type
+sqlite3_column_value
+sqlite3_columns_go
+sqlite3_commit_hook_go
+sqlite3_config_log_go
+sqlite3_create_aggregate_function_go
+sqlite3_create_collation_go
+sqlite3_create_function_go
+sqlite3_create_module_go
+sqlite3_create_window_function_go
+sqlite3_database_file_object
+sqlite3_db_config
+sqlite3_db_filename
+sqlite3_db_name
+sqlite3_db_readonly
+sqlite3_db_release_memory
+sqlite3_declare_vtab
+sqlite3_errcode
+sqlite3_errmsg
+sqlite3_error_offset
+sqlite3_errstr
+sqlite3_exec
+sqlite3_filename_database
+sqlite3_filename_journal
+sqlite3_filename_wal
+sqlite3_finalize
+sqlite3_get_autocommit
+sqlite3_get_auxdata
+sqlite3_interrupt
+sqlite3_last_insert_rowid
+sqlite3_limit
+sqlite3_open_v2
+sqlite3_overload_function
+sqlite3_prepare_v3
+sqlite3_progress_handler_go
+sqlite3_reset
+sqlite3_result_blob64
+sqlite3_result_double
+sqlite3_result_error
+sqlite3_result_error_code
+sqlite3_result_error_nomem
+sqlite3_result_error_toobig
+sqlite3_result_int64
+sqlite3_result_null
+sqlite3_result_pointer_go
+sqlite3_result_text64
+sqlite3_result_value
+sqlite3_result_zeroblob64
+sqlite3_rollback_hook_go
+sqlite3_set_authorizer_go
+sqlite3_set_auxdata_go
+sqlite3_set_last_insert_rowid
+sqlite3_step
+sqlite3_stmt_busy
+sqlite3_stmt_readonly
+sqlite3_stmt_status
+sqlite3_total_changes64
+sqlite3_txn_state
+sqlite3_update_hook_go
+sqlite3_uri_key
+sqlite3_uri_parameter
+sqlite3_value_blob
+sqlite3_value_bytes
+sqlite3_value_double
+sqlite3_value_dup
+sqlite3_value_free
+sqlite3_value_int64
+sqlite3_value_nochange
+sqlite3_value_numeric_type
+sqlite3_value_pointer_go
+sqlite3_value_text
+sqlite3_value_type
+sqlite3_vtab_collation
+sqlite3_vtab_config_go
+sqlite3_vtab_distinct
+sqlite3_vtab_in
+sqlite3_vtab_in_first
+sqlite3_vtab_in_next
+sqlite3_vtab_nochange
+sqlite3_vtab_on_conflict
+sqlite3_vtab_rhs_value
+sqlite3_wal_autocheckpoint
+sqlite3_wal_checkpoint_v2
+sqlite3_wal_hook_go \ No newline at end of file
diff --git a/vendor/github.com/ncruces/go-sqlite3/embed/init.go b/vendor/github.com/ncruces/go-sqlite3/embed/init.go
new file mode 100644
index 000000000..da527abd0
--- /dev/null
+++ b/vendor/github.com/ncruces/go-sqlite3/embed/init.go
@@ -0,0 +1,20 @@
+// Package embed embeds SQLite into your application.
+//
+// Importing package embed initializes the [sqlite3.Binary] variable
+// with an appropriate build of SQLite:
+//
+// import _ "github.com/ncruces/go-sqlite3/embed"
+package embed
+
+import (
+ _ "embed"
+
+ "github.com/ncruces/go-sqlite3"
+)
+
+//go:embed sqlite3.wasm
+var binary []byte
+
+func init() {
+ sqlite3.Binary = binary
+}
diff --git a/vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm b/vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm
new file mode 100644
index 000000000..2689f773a
--- /dev/null
+++ b/vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm
Binary files differ