Skip to content

Commit

Permalink
Configurator: add by default --personality=@target@ to pkgconf calls
Browse files Browse the repository at this point in the history
Specifying a personality is only useful when cross-compiling (which you do when you use mingw on Windows) but
(nearly) never harmful as pkgconf installs a default.personality which it uses for all triplets (that parses
therefore the nearly) it hasn't a explicit personality for.

Signed-off-by: Pierre Boutillier <pierre.boutillier@laposte.net>
  • Loading branch information
pirbo committed Oct 18, 2024
1 parent 0077e6e commit 1fbeaaf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
15 changes: 12 additions & 3 deletions otherlibs/configurator/src/v1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -658,21 +658,30 @@ module Pkg_config = struct
}

let get c =
let pkg_config_args =
let get_pkg_config_args default =
match Sys.getenv "PKG_CONFIG_ARGN" with
| s -> String.split ~on:' ' s
| exception Not_found -> []
| exception Not_found -> default
in
match Sys.getenv "PKG_CONFIG" with
| s ->
Option.map (which c s) ~f:(fun pkg_config ->
let pkg_config_args = get_pkg_config_args [] in
{ pkg_config; pkg_config_args; configurator = c })
| exception Not_found ->
(match which c "pkgconf" with
| None ->
Option.map (which c "pkg-config") ~f:(fun pkg_config ->
let pkg_config_args = get_pkg_config_args [] in
{ pkg_config; pkg_config_args; configurator = c })
| Some pkg_config -> Some { pkg_config; pkg_config_args; configurator = c })
| Some pkg_config ->
let pkg_config_args =
get_pkg_config_args
(match ocaml_config_var c "target" with
| None -> []
| Some target -> [ "--personality"; target ])
in
Some { pkg_config; pkg_config_args; configurator = c })
;;

type package_conf =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
These tests show that setting `PKG_CONFIG_ARGN` passes extra args to `pkg-config`

$ dune build 2>&1 | awk '/run:.*bin\/pkgconf/{a=1}/stderr/{a=0}a'
$ dune build 2>&1 | awk '/run:.*bin\/pkgconf/{a=1}/stderr/{a=0}a' | sed s/$(ocamlc -config | sed -n "/^target:/ {s/target: //; p; }")/\$TARGET/g
run: $TESTCASE_ROOT/_build/default/.bin/pkgconf --print-errors dummy-pkg
-> process exited with code 0
-> stdout:
| dummy-pkg
run: $TESTCASE_ROOT/_build/default/.bin/pkgconf --cflags dummy-pkg
run: $TESTCASE_ROOT/_build/default/.bin/pkgconf --personality $TARGET --cflags dummy-pkg
-> process exited with code 0
-> stdout:
| --personality
| $TARGET
| --cflags
| dummy-pkg
run: $TESTCASE_ROOT/_build/default/.bin/pkgconf --libs dummy-pkg
run: $TESTCASE_ROOT/_build/default/.bin/pkgconf --personality $TARGET --libs dummy-pkg
-> process exited with code 0
-> stdout:
| --personality
| $TARGET
| --libs
| dummy-pkg
Expand Down

0 comments on commit 1fbeaaf

Please sign in to comment.