Skip to content

Commit

Permalink
fix(pkg): index rules (#11035)
Browse files Browse the repository at this point in the history
do not assume indices are built for libraries from the lock directory

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Oct 22, 2024
1 parent dbd8448 commit 3f9630f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
15 changes: 8 additions & 7 deletions src/dune_rules/merlin/ocaml_index.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ let cctx_rules cctx =
- If these libs are rebuilt a re-indexation is needed *)
let other_indexes_deps =
let open Resolve.Memo.O in
let+ requires_compile = Compilation_context.requires_compile cctx in
let deps =
List.filter_map requires_compile ~f:(fun l ->
match Lib.info l |> Lib_info.obj_dir |> Obj_dir.obj_dir with
| In_build_dir dir -> Some (Path.relative (Path.build dir) index_file_name)
| _ -> None)
let+ deps =
Compilation_context.requires_compile cctx
>>| List.filter_map ~f:(fun lib ->
Lib.Local.of_lib lib
|> Option.map ~f:(fun lib ->
Lib.Local.obj_dir lib |> index_path_in_obj_dir |> Path.build))
>>| Dep.Set.of_files
in
Command.Args.Hidden_deps (Dep.Set.of_files deps)
Command.Args.Hidden_deps deps
in
let context_dir =
Compilation_context.context cctx
Expand Down
17 changes: 11 additions & 6 deletions test/blackbox-tests/test-cases/pkg/gh10985.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ Now we set up a lock file with this package and then attempt to use it:
> let () = Test_lib.x
> EOF

$ mkdir .bin
$ cat > .bin/ocaml-index <<EOF
> #!/usr/bin/env sh
> exit 1
> EOF

$ chmod +x .bin/ocaml-index
$ export PATH="$PWD/.bin:$PATH"

$ dune build @ocaml-index
Error: This rule defines a directory target "default/.pkg/mypkg/target" that
matches the requested path
"default/.pkg/mypkg/target/lib/mypkg/lib/cctx.ocaml-index" but the rule's
action didn't produce it
-> required by _build/default/.foo.objs/cctx.ocaml-index
-> required by alias ocaml-index
File ".foo.objs/_unknown_", line 1, characters 0-0:
Command exited with code 1.
[1]

0 comments on commit 3f9630f

Please sign in to comment.