diff --git a/src/compilation_context.ml b/src/compilation_context.ml index 550289cf..ddb3de07 100644 --- a/src/compilation_context.ml +++ b/src/compilation_context.ml @@ -37,6 +37,7 @@ type t = { super_context : Super_context.t ; scope : Scope.t ; dir : Path.t + ; dir_kind : File_tree.Dune_file.Kind.t ; obj_dir : Path.t ; modules : Module.t Module.Name.Map.t ; alias_module : Module.t option @@ -50,6 +51,7 @@ type t = let super_context t = t.super_context let scope t = t.scope let dir t = t.dir +let dir_kind t = t.dir_kind let obj_dir t = t.obj_dir let modules t = t.modules let alias_module t = t.alias_module @@ -59,12 +61,13 @@ let requires t = t.requires let includes t = t.includes let preprocessing t = t.preprocessing -let create ~super_context ~scope ~dir ?(obj_dir=dir) ~modules ?alias_module - ?lib_interface_module ~flags ~requires - ?(preprocessing=Preprocessing.dummy) () = +let create ~super_context ~scope ~dir ?(dir_kind=File_tree.Dune_file.Kind.Dune) + ?(obj_dir=dir) ~modules ?alias_module ?lib_interface_module ~flags + ~requires ?(preprocessing=Preprocessing.dummy) () = { super_context ; scope ; dir + ; dir_kind ; obj_dir ; modules ; alias_module diff --git a/src/compilation_context.mli b/src/compilation_context.mli index 1f3b1dbd..d5eaeea5 100644 --- a/src/compilation_context.mli +++ b/src/compilation_context.mli @@ -16,6 +16,7 @@ val create : super_context : Super_context.t -> scope : Scope.t -> dir : Path.t + -> ?dir_kind : File_tree.Dune_file.Kind.t -> ?obj_dir : Path.t -> modules : Module.t Module.Name.Map.t -> ?alias_module : Module.t @@ -32,6 +33,7 @@ val for_alias_module : t -> t val super_context : t -> Super_context.t val scope : t -> Scope.t val dir : t -> Path.t +val dir_kind : t -> File_tree.Dune_file.Kind.t val obj_dir : t -> Path.t val modules : t -> Module.t Module.Name.Map.t val alias_module : t -> Module.t option diff --git a/src/gen_rules.ml b/src/gen_rules.ml index 8f7cf26c..56b7fcff 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -569,6 +569,7 @@ module Gen(P : Install_rules.Params) = struct ~super_context:sctx ~scope ~dir + ~dir_kind ~obj_dir ~modules ?alias_module @@ -874,6 +875,7 @@ module Gen(P : Install_rules.Params) = struct ~super_context:sctx ~scope ~dir + ~dir_kind ~obj_dir ~modules ~flags diff --git a/src/module_compilation.ml b/src/module_compilation.ml index 7736e5bd..8d496fa9 100644 --- a/src/module_compilation.ml +++ b/src/module_compilation.ml @@ -74,7 +74,7 @@ let build_cm cctx ?sandbox ?(dynlink=true) ~dep_graphs ~cm_kind (m : Module.t) = (fn :: other_targets, A "-bin-annot") in let hidden_targets = List.map other_targets ~f:(Target.file obj_dir) in - if obj_dir <> dir then begin + if CC.dir_kind cctx = Jbuild && obj_dir <> dir then begin (* Symlink the object files in the original directory for backward compatibility *) let old_dst = Module.cm_file_unsafe m ~obj_dir:dir cm_kind in diff --git a/test/blackbox-tests/test-cases/ocamldep-multi-stanzas/run.t b/test/blackbox-tests/test-cases/ocamldep-multi-stanzas/run.t index 6af65376..7e59b5e9 100644 --- a/test/blackbox-tests/test-cases/ocamldep-multi-stanzas/run.t +++ b/test/blackbox-tests/test-cases/ocamldep-multi-stanzas/run.t @@ -8,10 +8,17 @@ each module cannot appear in more than one "modules" field - it must belong to a single library or executable. This warning will become an error in the future. - Multiple rules generated for _build/default/lib$ext_obj: - - - - - [1] + ocamldep lib.ml.d + ocamlc .lib.objs/lib.{cmi,cmo,cmt} + ocamlopt .lib.objs/lib.{cmx,o} + ocamlopt lib.{a,cmxa} + ocamldep test.ml.d + ocamlc .test.eobjs/lib.{cmi,cmo,cmt} + ocamlopt .test.eobjs/lib.{cmx,o} + ocamlc .test.eobjs/test.{cmi,cmo,cmt} + ocamlopt .test.eobjs/test.{cmx,o} + ocamlopt test.exe + foo bar $ dune build src/a.cma --debug-dep --display short File "src/dune", line 1, characters 0-0: