File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,18 @@ let major_minor_from_pgconfig () =
55
55
in
56
56
Fun. protect ~finally: (fun () -> close_in ic) (fun () -> pg_major_minor ic)
57
57
58
+ let major_minor_from_pkg_config () =
59
+ let ic = Unix. open_process_in " pkg-config --modversion libpq" in
60
+ Fun. protect ~finally: (fun () -> close_in ic) @@ fun () ->
61
+ let version_line = input_line ic in
62
+ (* Typically something like "14.1" *)
63
+ match String. split_on_char '.' version_line with
64
+ | major :: minor :: _ ->
65
+ (" -DPG_OCAML_MAJOR_VERSION=" ^ major, " -DPG_OCAML_MINOR_VERSION=" ^ minor)
66
+ | _ ->
67
+ eprintf " Unable to parse libpq version: %s" version_line;
68
+ exit 1
69
+
58
70
let from_pgconfig () =
59
71
let cmd = " pg_config --includedir --libdir --version" in
60
72
let ic =
@@ -81,7 +93,7 @@ let () =
81
93
| Some pc -> (
82
94
match C.Pkg_config. query pc ~package: " libpq" with
83
95
| Some conf ->
84
- let major, minor = major_minor_from_pgconfig () in
96
+ let major, minor = major_minor_from_pkg_config () in
85
97
{
86
98
conf with
87
99
C.Pkg_config. cflags = major :: minor :: conf .cflags;
You can’t perform that action at this time.
0 commit comments