Skip to content

Commit

Permalink
Allow turning off loadable extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmottl committed Jan 5, 2016
1 parent ed27c9e commit ca2d053
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 19 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ for testing various features of this library.
SQLite3-OCaml depends on `pkg-config` to locate and compile against an
[SQLite3](http://www.sqlite.org) library.

If the SQLite3 version is larger than or equal to 3.3.7, it is assumed that it
If the SQLite3 version is greater than or equal to 3.3.7, it is assumed that it
supports [Run-Time Loadable Extensions](http://www.sqlite.org/loadext.html).
If this feature has been explicitly disabled in the library, the build will
fail with:
If this feature has been explicitly disabled in the library, building
applications will fail with:

```
Undefined symbols for architecture ...:
Expand All @@ -54,6 +54,11 @@ Undefined symbols for architecture ...:
environment variable; this will instruct the build to see if a _brewed_
version of SQLite is installed and route `pkg-config` appropriately.

* You can explicitly disable run-time loadable extensions by calling
`configure` with the flag `--disable-loadable-extensions` or by setting
the environment variable `SQLITE3_DISABLE_LOADABLE_EXTENSIONS` if linking
problems persist.

Credits
-------

Expand All @@ -80,4 +85,4 @@ page](https://github.com/mmottl/sqlite3-ocaml).

Enjoy!

Markus Mottl on December 15, 2015
Markus Mottl on January 5, 2015
12 changes: 9 additions & 3 deletions _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.4
Name: sqlite3
Version: 4.0.2
Version: 4.0.3
Synopsis: sqlite3-ocaml - SQLite3 bindings
Description: sqlite3-ocaml is an OCaml library with bindings to the
SQLite3 client API. Sqlite3 is a self-contained, serverless,
Expand All @@ -12,7 +12,7 @@ Description: sqlite3-ocaml is an OCaml library with bindings to the
Authors: Markus Mottl <[email protected]>,
Christian Szegedy <[email protected]>
Copyrights: (C) 2007-2010 Jane Street Holding LLC <[email protected]>,
(C) 2010-2015 Markus Mottl <[email protected]>,
(C) 2010-2016 Markus Mottl <[email protected]>,
(C) 2005-2012 Christian Szegedy <[email protected]>
Maintainers: Markus Mottl <[email protected]>,
Christian Szegedy <[email protected]>
Expand All @@ -37,14 +37,20 @@ Flag brewcheck
Description: Try to check against a homebrewed sqlite3
Default: false

Flag loadable_extensions
Description: Enable loadable extensions
Default: true

Library sqlite3
Path: lib
FindlibName: sqlite3
Modules: Sqlite3
CSources: sqlite3_stubs.c
CCOpt: -g -O2 -fPIC -DPIC
if flag(strict) && ccomp_type(cc)
CCOpt+: -Wall -pedantic -Wextra -Wunused -Wno-long-long
CCOpt+: -Wall -pedantic -Wextra -Wunused -Wno-long-long -Wno-keyword-macro
if !flag(loadable_extensions)
CCOpt+: -DSQLITE3_DISABLE_LOADABLE_EXTENSIONS
CCLib: -lsqlite3 -lpthread


Expand Down
4 changes: 2 additions & 2 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OASIS_START
# DO NOT EDIT (digest: 5524efdf2a9ea85569fd9184ad5804ae)
version = "4.0.2"
# DO NOT EDIT (digest: fa8ee36501416c86cd1e145c553d9aae)
version = "4.0.3"
description = "sqlite3-ocaml - SQLite3 bindings"
archive(byte) = "sqlite3.cma"
archive(byte, plugin) = "sqlite3.cma"
Expand Down
2 changes: 1 addition & 1 deletion lib/sqlite3_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# define inline
#endif

#if SQLITE_VERSION_NUMBER >= 3003007
#if SQLITE_VERSION_NUMBER >= 3003007 && !SQLITE3_DISABLE_LOADABLE_EXTENSIONS
# define SQLITE_HAS_ENABLE_LOAD_EXTENSION
#endif

Expand Down
61 changes: 58 additions & 3 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: 1308fb3d48472c2edc4cc51c862b6705) *)
(* DO NOT EDIT (digest: ef3f6bb7de5d2441c8248057cdf28ea3) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)

Expand Down Expand Up @@ -625,6 +625,20 @@ let package_default =
A "-ccopt";
A "-DPIC"
]);
(OASISExpr.ENot (OASISExpr.EFlag "loadable_extensions"),
S
[
A "-ccopt";
A "-g";
A "-ccopt";
A "-O2";
A "-ccopt";
A "-fPIC";
A "-ccopt";
A "-DPIC";
A "-ccopt";
A "-DSQLITE3_DISABLE_LOADABLE_EXTENSIONS"
]);
(OASISExpr.EAnd
(OASISExpr.EFlag "strict",
OASISExpr.ETest ("ccomp_type", "cc")),
Expand All @@ -647,7 +661,39 @@ let package_default =
A "-ccopt";
A "-Wunused";
A "-ccopt";
A "-Wno-long-long"
A "-Wno-long-long";
A "-ccopt";
A "-Wno-keyword-macro"
]);
(OASISExpr.EAnd
(OASISExpr.EAnd
(OASISExpr.EFlag "strict",
OASISExpr.ETest ("ccomp_type", "cc")),
OASISExpr.ENot (OASISExpr.EFlag "loadable_extensions")),
S
[
A "-ccopt";
A "-g";
A "-ccopt";
A "-O2";
A "-ccopt";
A "-fPIC";
A "-ccopt";
A "-DPIC";
A "-ccopt";
A "-Wall";
A "-ccopt";
A "-pedantic";
A "-ccopt";
A "-Wextra";
A "-ccopt";
A "-Wunused";
A "-ccopt";
A "-Wno-long-long";
A "-ccopt";
A "-Wno-keyword-macro";
A "-ccopt";
A "-DSQLITE3_DISABLE_LOADABLE_EXTENSIONS"
])
]);
(["oasis_library_sqlite3_cclib"; "link"],
Expand All @@ -666,7 +712,7 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}

let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;

# 670 "myocamlbuild.ml"
# 716 "myocamlbuild.ml"
(* OASIS_STOP *)

let read_lines_from_cmd ~max_lines cmd =
Expand Down Expand Up @@ -755,6 +801,15 @@ let () =
| [cflags] -> S (ocamlify ~ocaml_flag:"-ccopt" cflags)
| _ -> failwith "pkg-config failed for cflags"
in
let osqlite3_cflags =
try
ignore (Sys.getenv "SQLITE3_DISABLE_LOADABLE_EXTENSIONS");
S [
A "-ccopt"; A "-DSQLITE3_DISABLE_LOADABLE_EXTENSIONS";
osqlite3_cflags
]
with _ -> osqlite3_cflags
in
let sqlite3_clibs, osqlite3_clibs =
let cmd = pkg_export ^ " pkg-config --libs sqlite3" in
match read_lines_from_cmd ~max_lines:1 cmd with
Expand Down
51 changes: 45 additions & 6 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.3.0 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: 4f2751487ce181081e99de1028e4c41a) *)
(* DO NOT EDIT (digest: 34b827fa7f40294929d50e745345a17a) *)
(*
Regenerated by OASIS v0.4.5
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -6981,7 +6981,7 @@ let setup_t =
alpha_features = [];
beta_features = [];
name = "sqlite3";
version = "4.0.2";
version = "4.0.3";
license =
OASISLicense.DEP5License
(OASISLicense.DEP5Unit
Expand All @@ -6994,7 +6994,7 @@ let setup_t =
copyrights =
[
"(C) 2007-2010 Jane Street Holding LLC <[email protected]>";
"(C) 2010-2015 Markus Mottl <[email protected]>";
"(C) 2010-2016 Markus Mottl <[email protected]>";
"(C) 2005-2012 Christian Szegedy <[email protected]>"
];
maintainers =
Expand Down Expand Up @@ -7073,6 +7073,16 @@ let setup_t =
Some "Try to check against a homebrewed sqlite3";
flag_default = [(OASISExpr.EBool true, false)]
});
Flag
({
cs_name = "loadable_extensions";
cs_data = PropList.Data.create ();
cs_plugin_data = []
},
{
flag_description = Some "Enable loadable extensions";
flag_default = [(OASISExpr.EBool true, true)]
});
Library
({
cs_name = "sqlite3";
Expand All @@ -7093,6 +7103,15 @@ let setup_t =
[
(OASISExpr.EBool true,
["-g"; "-O2"; "-fPIC"; "-DPIC"]);
(OASISExpr.ENot
(OASISExpr.EFlag "loadable_extensions"),
[
"-g";
"-O2";
"-fPIC";
"-DPIC";
"-DSQLITE3_DISABLE_LOADABLE_EXTENSIONS"
]);
(OASISExpr.EAnd
(OASISExpr.EFlag "strict",
OASISExpr.ETest ("ccomp_type", "cc")),
Expand All @@ -7105,7 +7124,27 @@ let setup_t =
"-pedantic";
"-Wextra";
"-Wunused";
"-Wno-long-long"
"-Wno-long-long";
"-Wno-keyword-macro"
]);
(OASISExpr.EAnd
(OASISExpr.EAnd
(OASISExpr.EFlag "strict",
OASISExpr.ETest ("ccomp_type", "cc")),
OASISExpr.ENot
(OASISExpr.EFlag "loadable_extensions")),
[
"-g";
"-O2";
"-fPIC";
"-DPIC";
"-Wall";
"-pedantic";
"-Wextra";
"-Wunused";
"-Wno-long-long";
"-Wno-keyword-macro";
"-DSQLITE3_DISABLE_LOADABLE_EXTENSIONS"
])
];
bs_cclib =
Expand Down Expand Up @@ -7523,14 +7562,14 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.5";
oasis_digest = Some "\tÿ¾%³~;¹×\t=ïÿ\\¶";
oasis_digest = Some "\026Á2=èì-\007\130\026ù\151Ù ";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
};;

let setup () = BaseSetup.setup setup_t;;

# 7535 "setup.ml"
# 7574 "setup.ml"
(* OASIS_STOP *)
let () = setup ();;

0 comments on commit ca2d053

Please sign in to comment.