mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
Vendor the spellfix1 extension source and compile it directly into the binary via cgo, avoiding runtime shared library dependencies across platforms. The extension is registered via sqlite3_auto_extension so every new SQLite connection has spellfix1 available. Signed-off-by: Deluan <deluan@navidrome.org>
34 lines
1005 B
Go
34 lines
1005 B
Go
//go:build sqlite_spellfix
|
|
|
|
package spellfix
|
|
|
|
/*
|
|
#cgo CFLAGS: -I${SRCDIR} -Wno-deprecated-declarations
|
|
|
|
// Avoid duplicate symbol conflicts with go-sqlite3.
|
|
// Rename the api pointer and entry point to unique names for this compilation unit.
|
|
#define sqlite3_api sqlite3_api_spellfix
|
|
#define sqlite3_spellfix_init sqlite3_spellfix_init_local
|
|
|
|
// Compile the extension into this binary.
|
|
// spellfix.c includes sqlite3ext.h and declares SQLITE_EXTENSION_INIT1.
|
|
#include "spellfix.c"
|
|
|
|
// sqlite3ext.h redefines sqlite3_auto_extension as a macro through the api
|
|
// struct. Undo that so we can call the real C function directly.
|
|
#undef sqlite3_auto_extension
|
|
|
|
// Provided by the SQLite library linked via go-sqlite3.
|
|
extern int sqlite3_auto_extension(void(*)(void));
|
|
|
|
// Register spellfix so it is available on every new sqlite3_open() connection.
|
|
static void register_spellfix(void) {
|
|
sqlite3_auto_extension((void(*)(void))sqlite3_spellfix_init_local);
|
|
}
|
|
*/
|
|
import "C"
|
|
|
|
func init() {
|
|
C.register_spellfix()
|
|
}
|