Merge pull request #1197 from rgrinberg/install-rules-virtual-libs

Adjust install files for virtual libraries
This commit is contained in:
Rudi Grinberg 2018-08-31 13:51:26 +03:00 committed by GitHub
commit 6dedc68186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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