Add ESQLITE_USE_SYSTEM
This allows the nif to link against the system's SQLite database. Useful when you need to share the database with other applications
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,4 +7,4 @@ priv
|
||||
*.o
|
||||
*~
|
||||
_build
|
||||
c_src/*.d
|
||||
c_src/**/*.d
|
||||
|
||||
24
rebar.config
24
rebar.config
@@ -1,24 +0,0 @@
|
||||
{require_min_otp_vsn, "R15"}.
|
||||
{port_env, [
|
||||
%% Default darwin ldflags causes loading of system sqlite. Removed -bundle flag.
|
||||
{"darwin", "DRV_LDFLAGS",
|
||||
"-flat_namespace -undefined suppress $ERL_LDFLAGS"},
|
||||
|
||||
{"solaris", "CFLAGS",
|
||||
"-std=c99"},
|
||||
|
||||
{"linux", "CFLAGS",
|
||||
"-std=c11"},
|
||||
|
||||
{"CFLAGS", "$CFLAGS -DSQLITE_THREADSAFE=1 -DSQLITE_USE_URI -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS"}
|
||||
]}.
|
||||
{port_specs, [
|
||||
{"priv/esqlite3_nif.so", ["c_src/esqlite3_nif.c", "c_src/queue.c", "c_src/sqlite3.c"]}
|
||||
]}.
|
||||
|
||||
{plugins, [pc]}.
|
||||
|
||||
{provider_hooks,
|
||||
[{post,
|
||||
[{compile, {pc, compile}},
|
||||
{clean, {pc, clean}}]}]}.
|
||||
50
rebar.config.script
Normal file
50
rebar.config.script
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
NifSharedSources = ["c_src/esqlite3_nif.c", "c_src/queue.c"].
|
||||
NifStaticSources = NifSharedSources ++ ["c_src/sqlite3/sqlite3.c"].
|
||||
CFlagsDefault = "$CFLAGS -DSQLITE_THREADSAFE=1 -DSQLITE_USE_URI -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS".
|
||||
DrvLdFlagsDefault = "-shared -lsqlite3".
|
||||
|
||||
DrvLdFlags =
|
||||
case os:getenv("ESQLITE_CFLAGS") of
|
||||
NotDefined when NotDefined == false; NotDefined == [] -> DrvLdFlagsDefault;
|
||||
DrvLdFlagsOverride -> DrvLdFlagsOverride
|
||||
end.
|
||||
|
||||
{NifSources, LdEnv, CFlagsExt} =
|
||||
case os:getenv("ESQLITE_USE_SYSTEM") of
|
||||
NotDefined when NotDefined == false; NotDefined == [] -> {NifStaticSources, [], []};
|
||||
_Defined -> {NifSharedSources, [{"DRV_LDFLAGS", DrvLdFlags}], " -Ic_src/sqlite3"}
|
||||
end.
|
||||
|
||||
CFlags =
|
||||
case os:getenv("ESQLITE_CFLAGS") of
|
||||
NotDefined when NotDefined == false; NotDefined == [] -> CFlagsDefault ++ CFlagsExt;
|
||||
CFlagsOverride -> CFlagsOverride
|
||||
end.
|
||||
|
||||
[
|
||||
{require_min_otp_vsn, "R15"},
|
||||
{port_env, [
|
||||
%% Default darwin ldflags causes loading of system sqlite. Removed -bundle flag.
|
||||
{"darwin", "DRV_LDFLAGS",
|
||||
"-flat_namespace -undefined suppress $ERL_LDFLAGS"},
|
||||
|
||||
{"solaris", "CFLAGS",
|
||||
"-std=c99"},
|
||||
|
||||
{"linux", "CFLAGS",
|
||||
"-std=c11"},
|
||||
|
||||
{"CFLAGS", CFlags}
|
||||
] ++ LdEnv},
|
||||
{port_specs, [
|
||||
{"priv/esqlite3_nif.so", NifSources}
|
||||
]},
|
||||
|
||||
{plugins, [pc]},
|
||||
|
||||
{provider_hooks,
|
||||
[{post,
|
||||
[{compile, {pc, compile}},
|
||||
{clean, {pc, clean}}]}]}
|
||||
].
|
||||
Reference in New Issue
Block a user