Skip to content

Commit

Permalink
fix(x-compilation): take the default findlib path context into account
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Nuno Monteiro <[email protected]>
  • Loading branch information
anmonteiro committed Mar 28, 2023
1 parent 494e900 commit 8d7c0b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
10 changes: 7 additions & 3 deletions src/dune_rules/findlib/findlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module Vars = struct

let empty = String.Map.empty

let superpose = String.Map.superpose
let union = String.Map.union
end

module Config = struct
Expand All @@ -116,7 +116,6 @@ module Config = struct
; ("preds", Ps.to_dyn preds)
]


let load config_file =
let load p =
let+ meta = Meta.load ~name:None p in
Expand All @@ -141,7 +140,12 @@ module Config = struct
let p = Path.Outside_build_dir.relative config_dir p in
load p)
in
List.fold_left all_vars ~init:vars ~f:Vars.superpose
List.fold_left all_vars ~init:vars ~f:(fun acc vars ->
Vars.union acc vars ~f:(fun _ (x : Rules.t) y ->
Some
{ Rules.set_rules = x.set_rules @ y.set_rules
; add_rules = x.add_rules @ y.add_rules
}))
| Error _ -> Memo.return vars)
| Ok false | Error _ -> Memo.return vars
in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,24 @@ Dune should be able to find it too

$ dune build --root=app @install -x foo
Entering directory 'app'
File "dune", line 6, characters 12-18:
6 | (libraries libdep))
^^^^^^
Error: Library "libdep" not found.
-> required by _build/default/.gen.eobjs/byte/dune__exe__Gen.cmi
-> required by _build/default/.gen.eobjs/native/dune__exe__Gen.cmx
-> required by _build/default/gen.exe
-> required by _build/default.foo/foo.ml
-> required by _build/install/default.foo/lib/repro/foo.ml
-> required by _build/default.foo/repro-foo.install
-> required by alias install (context default.foo)
Leaving directory 'app'
[1]

Library is built in the target context

$ ls app/_build/default.foo
META.repro
foo.ml
repro-foo.install
repro.a
repro.cma
repro.cmxa
repro.cmxs
repro.dune-package
repro.ml-gen

Executable was built in the host context

$ ls app/_build/default
gen.exe
gen.ml
gen.mli

0 comments on commit 8d7c0b0

Please sign in to comment.