diff --git a/src/dune_file.ml b/src/dune_file.ml index 5bad3137..1bb6a9c4 100644 --- a/src/dune_file.ml +++ b/src/dune_file.ml @@ -1008,6 +1008,8 @@ module Library = struct match t.public with | None -> Lib_name.of_local t.name | Some p -> snd p.name + + let is_virtual t = Option.is_some t.virtual_modules end module Install_conf = struct diff --git a/src/dune_file.mli b/src/dune_file.mli index 6f17d593..0823c813 100644 --- a/src/dune_file.mli +++ b/src/dune_file.mli @@ -249,6 +249,7 @@ module Library : sig val dll : t -> dir:Path.t -> ext_dll:string -> Path.t val archive : t -> dir:Path.t -> ext:string -> Path.t val best_name : t -> Lib_name.t + val is_virtual : t -> bool end module Install_conf : sig diff --git a/src/install_rules.ml b/src/install_rules.ml index 28d6be20..c832d925 100644 --- a/src/install_rules.ml +++ b/src/install_rules.ml @@ -118,6 +118,7 @@ module Gen(P : Params) = struct let lib_install_files ~dir_contents ~dir ~sub_dir ~(name : Lib_name.t) ~scope ~dir_kind (lib : Library.t) = let obj_dir = Utils.library_object_directory ~dir lib.name in + let ext_obj = ctx.ext_obj in let make_entry section ?dst fn = Install.Entry.make section fn ~dst:( @@ -148,21 +149,29 @@ module Gen(P : Params) = struct in Module.Name.Map.values modules in + let virtual_library = Library.is_virtual lib in List.concat [ List.concat_map modules ~f:(fun m -> List.concat [ [ Module.cm_file_unsafe m ~obj_dir Cmi ] ; if_ (native && Module.has_impl m) [ Module.cm_file_unsafe m ~obj_dir Cmx ] + ; if_ (native && Module.has_impl m && virtual_library) + [ Module.obj_file m ~obj_dir ~ext:ext_obj ] ; List.filter_map Ml_kind.all ~f:(Module.cmt_file m ~obj_dir) ; List.filter_map [m.intf;m.impl] ~f:(function | None -> None | Some f -> Some f.path) ]) - ; if_ byte [ Library.archive ~dir lib ~ext:".cma" ] - ; if_ (Library.has_stubs lib) + ; if_ (byte && not virtual_library) [ Library.archive ~dir lib ~ext:".cma" ] + ; if virtual_library then ( + (lib.c_names @ lib.cxx_names) + |> List.map ~f:(fun (_, c) -> Path.relative dir (c ^ ext_obj)) + ) else if Library.has_stubs lib then ( [ Library.stubs_archive ~dir lib ~ext_lib:ctx.ext_lib ] - ; if_ native + ) else + [] + ; if_ (native && not virtual_library) (let files = [ Library.archive ~dir lib ~ext:".cmxa" ; Library.archive ~dir lib ~ext:ctx.ext_lib