Skip to content

lib/config: Handle version strings like "18beta1" #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lib/config/discover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ let major_minor_from_pkg_config () =
let ic = Unix.open_process_in cmd in
Fun.protect ~finally:(fun () -> close_in ic) @@ fun () ->
let version_line = input_line ic in
match String.split_on_char '.' version_line with
| major :: minor :: _ ->
("-DPG_OCAML_MAJOR_VERSION=" ^ major, "-DPG_OCAML_MINOR_VERSION=" ^ minor)
| _ ->
eprintf "Unable to parse libpq version: %s" version_line;
exit 1
let major, minor =
try Scanf.sscanf version_line "%d.%d" (fun a b -> a, b)
with Scanf.Scan_failure _ ->
try
(* Treat "NbetaM" as a pre-release of N.0 *)
Scanf.sscanf version_line "%dbeta%d" (fun a _ -> a, 0)
with Scanf.Scan_failure _ ->
eprintf "Unable to parse libpq version: %s" version_line;
exit 1 in
("-DPG_OCAML_MAJOR_VERSION=" ^ string_of_int major,
"-DPG_OCAML_MINOR_VERSION=" ^ string_of_int minor)

let from_pgconfig () =
let cmd = "pg_config --includedir --libdir --version" in
Expand Down