From 44ca7f0bbf95279bdc8013f06fe0186719e8df23 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 30 Aug 2018 14:24:04 +0300 Subject: [PATCH 1/2] Adjust installed artifacts for virtual libraries * Virtual libraries do not install archive files * Virtual libraries should install .o files Signed-off-by: Rudi Grinberg --- src/dune_file.ml | 2 ++ src/dune_file.mli | 1 + src/install_rules.ml | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) 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..12448aaa 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,24 @@ 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_ (Library.has_stubs lib && not virtual_library) [ Library.stubs_archive ~dir lib ~ext_lib:ctx.ext_lib ] - ; if_ native + ; if_ (native && not virtual_library) (let files = [ Library.archive ~dir lib ~ext:".cmxa" ; Library.archive ~dir lib ~ext:ctx.ext_lib From 1ded621dc710a46be78b662f0ae33a5db8d687da Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 30 Aug 2018 14:36:03 +0300 Subject: [PATCH 2/2] Install c/cxx stubs for virtual libraries Signed-off-by: Rudi Grinberg --- src/install_rules.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/install_rules.ml b/src/install_rules.ml index 12448aaa..c832d925 100644 --- a/src/install_rules.ml +++ b/src/install_rules.ml @@ -164,8 +164,13 @@ module Gen(P : Params) = struct | Some f -> Some f.path) ]) ; if_ (byte && not virtual_library) [ Library.archive ~dir lib ~ext:".cma" ] - ; if_ (Library.has_stubs lib && not virtual_library) + ; 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 ] + ) else + [] ; if_ (native && not virtual_library) (let files = [ Library.archive ~dir lib ~ext:".cmxa"