Skip to content

Commit 1ba04be

Browse files
committed
Add brew checking capability during build
1 parent 85985f4 commit 1ba04be

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

_oasis

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Flag strict
3333
Description: Strict compile-time checks
3434
Default: true
3535

36+
Flag brewcheck
37+
Description: Try to check against a homebrewed sqlite3
38+
Default: false
39+
3640
Library sqlite3
3741
Path: lib
3842
FindlibName: sqlite3

myocamlbuild.ml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,20 @@ let string_trim s =
708708
else if !j >= !i then String.sub s !i (!j - !i + 1)
709709
else ""
710710

711+
let pkg_export =
712+
let env = BaseEnvLight.load () in
713+
let bcs = BaseEnvLight.var_get "brewcheck" env in
714+
let () = Printf.eprintf "bcs: %s\n" bcs in
715+
let bcs = try bool_of_string bcs with _ -> false in
716+
if not bcs then ""
717+
else
718+
let cmd = "brew ls sqlite | grep pkgconfig" in
719+
match read_lines_from_cmd ~max_lines:1 cmd with
720+
| [fullpath] when fullpath <> "" ->
721+
let path = Filename.dirname fullpath in
722+
Printf.sprintf "PKG_CONFIG_PATH=%s" path
723+
| _ -> ""
724+
711725
let () =
712726
let additional_rules = function
713727
| After_rules ->
@@ -733,13 +747,13 @@ let () =
733747
List.map cnv chunks
734748
in
735749
let osqlite3_cflags =
736-
let cmd = "pkg-config --cflags sqlite3" in
750+
let cmd = pkg_export ^ " pkg-config --cflags sqlite3" in
737751
match read_lines_from_cmd ~max_lines:1 cmd with
738752
| [cflags] -> S (ocamlify ~ocaml_flag:"-ccopt" cflags)
739753
| _ -> failwith "pkg-config failed for cflags"
740754
in
741755
let sqlite3_clibs, osqlite3_clibs =
742-
let cmd = "pkg-config --libs sqlite3" in
756+
let cmd = pkg_export ^ " pkg-config --libs sqlite3" in
743757
match read_lines_from_cmd ~max_lines:1 cmd with
744758
| [libs] ->
745759
S (split_flags libs), S (ocamlify ~ocaml_flag:"-cclib" libs)

setup.ml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(* setup.ml generated for the first time by OASIS v0.3.0 *)
22

33
(* OASIS_START *)
4-
(* DO NOT EDIT (digest: 1b6fe2a99f7d4b7e0a8fcaf32a49dc1a) *)
4+
(* DO NOT EDIT (digest: e68c0022204b3b21947672e8387508b1) *)
55
(*
66
Regenerated by OASIS v0.4.5
77
Visit http://oasis.forge.ocamlcore.org for more information and
@@ -7062,6 +7062,17 @@ let setup_t =
70627062
flag_description = Some "Strict compile-time checks";
70637063
flag_default = [(OASISExpr.EBool true, true)]
70647064
});
7065+
Flag
7066+
({
7067+
cs_name = "brewcheck";
7068+
cs_data = PropList.Data.create ();
7069+
cs_plugin_data = []
7070+
},
7071+
{
7072+
flag_description =
7073+
Some "Try to check against a homebrewed sqlite3";
7074+
flag_default = [(OASISExpr.EBool true, false)]
7075+
});
70657076
Library
70667077
({
70677078
cs_name = "sqlite3";
@@ -7512,14 +7523,14 @@ let setup_t =
75127523
};
75137524
oasis_fn = Some "_oasis";
75147525
oasis_version = "0.4.5";
7515-
oasis_digest = Some "Ý7ö\022\139Kuâeùû_¥Ó\019?";
7526+
oasis_digest = Some "\tf\154\159ÒØ ;²Õv\150\148\021.\014";
75167527
oasis_exec = None;
75177528
oasis_setup_args = [];
75187529
setup_update = false
75197530
};;
75207531

75217532
let setup () = BaseSetup.setup setup_t;;
75227533

7523-
# 7524 "setup.ml"
7534+
# 7535 "setup.ml"
75247535
(* OASIS_STOP *)
75257536
let () = setup ();;

0 commit comments

Comments
 (0)