Disable archives for virtual libraries
And refactor the archive building to allow for external o files to be provided Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
6da1f199f7
commit
918ae9ab0a
|
@ -241,7 +241,7 @@ module Gen (P : Install_rules.Params) = struct
|
||||||
ocamlmklib ~sandbox:true ~custom:false ~targets:[dynamic]
|
ocamlmklib ~sandbox:true ~custom:false ~targets:[dynamic]
|
||||||
end
|
end
|
||||||
|
|
||||||
let build_stubs lib ~dir ~scope ~requires ~dir_contents =
|
let build_o_files lib ~dir ~scope ~requires ~dir_contents =
|
||||||
let all_dirs = Dir_contents.dirs dir_contents in
|
let all_dirs = Dir_contents.dirs dir_contents in
|
||||||
let h_files =
|
let h_files =
|
||||||
List.fold_left all_dirs ~init:[] ~f:(fun acc dc ->
|
List.fold_left all_dirs ~init:[] ~f:(fun acc dc ->
|
||||||
|
@ -265,25 +265,32 @@ module Gen (P : Install_rules.Params) = struct
|
||||||
;
|
;
|
||||||
(p, Path.relative dir (fn ^ ctx.ext_obj))
|
(p, Path.relative dir (fn ^ ctx.ext_obj))
|
||||||
in
|
in
|
||||||
let o_files =
|
let includes =
|
||||||
let includes =
|
Arg_spec.S
|
||||||
Arg_spec.S
|
[ Hidden_deps h_files
|
||||||
[ Hidden_deps h_files
|
; Arg_spec.of_result_map requires ~f:(fun libs ->
|
||||||
; Arg_spec.of_result_map requires ~f:(fun libs ->
|
S [ Lib.L.c_include_flags libs ~stdlib_dir:ctx.stdlib_dir
|
||||||
S [ Lib.L.c_include_flags libs ~stdlib_dir:ctx.stdlib_dir
|
; Hidden_deps (SC.Libs.file_deps sctx libs ~ext:".h")
|
||||||
; Hidden_deps (SC.Libs.file_deps sctx libs ~ext:".h")
|
])
|
||||||
])
|
]
|
||||||
]
|
|
||||||
in
|
|
||||||
List.map lib.c_names ~f:(fun name ->
|
|
||||||
build_c_file lib ~scope ~dir ~includes (resolve_name name ~ext:".c")
|
|
||||||
) @ List.map lib.cxx_names ~f:(fun name ->
|
|
||||||
build_cxx_file lib ~scope ~dir ~includes (resolve_name name ~ext:".cpp")
|
|
||||||
)
|
|
||||||
in
|
in
|
||||||
match lib.self_build_stubs_archive with
|
List.map lib.c_names ~f:(fun name ->
|
||||||
| Some _ -> ()
|
build_c_file lib ~scope ~dir ~includes (resolve_name name ~ext:".c")
|
||||||
| None -> build_self_stubs lib ~dir ~scope ~o_files
|
) @ List.map lib.cxx_names ~f:(fun name ->
|
||||||
|
build_cxx_file lib ~scope ~dir ~includes (resolve_name name ~ext:".cpp")
|
||||||
|
)
|
||||||
|
|
||||||
|
let build_stubs lib ~dir ~scope ~requires ~dir_contents =
|
||||||
|
let vlib_stubs_o_files = [] in (* TODO *)
|
||||||
|
let lib_o_files =
|
||||||
|
if Library.has_stubs lib then
|
||||||
|
build_o_files lib ~dir ~scope ~requires ~dir_contents
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
in
|
||||||
|
match vlib_stubs_o_files @ lib_o_files with
|
||||||
|
| [] -> ()
|
||||||
|
| o_files -> build_self_stubs lib ~dir ~scope ~o_files
|
||||||
|
|
||||||
let build_shared lib ~dir ~flags ~(ctx : Context.t) =
|
let build_shared lib ~dir ~flags ~(ctx : Context.t) =
|
||||||
Option.iter ctx.ocamlopt ~f:(fun ocamlopt ->
|
Option.iter ctx.ocamlopt ~f:(fun ocamlopt ->
|
||||||
|
@ -406,33 +413,35 @@ module Gen (P : Install_rules.Params) = struct
|
||||||
Path.relative dir (header ^ ".h"))
|
Path.relative dir (header ^ ".h"))
|
||||||
|> Path.Set.of_list);
|
|> Path.Set.of_list);
|
||||||
|
|
||||||
(let modules =
|
if not (Library.is_virtual lib) then begin
|
||||||
Module.Name.Map.fold modules ~init:[] ~f:(fun m acc ->
|
(let modules =
|
||||||
if Module.has_impl m then
|
Module.Name.Map.fold modules ~init:[] ~f:(fun m acc ->
|
||||||
m :: acc
|
if Module.has_impl m then
|
||||||
else
|
m :: acc
|
||||||
acc)
|
else
|
||||||
in
|
acc)
|
||||||
let wrapped_compat = Module.Name.Map.values wrapped_compat in
|
in
|
||||||
(* Compatibility modules have implementations so we can just append them.
|
let wrapped_compat = Module.Name.Map.values wrapped_compat in
|
||||||
We append the modules at the end as no library modules depend on
|
(* Compatibility modules have implementations so we can just append them.
|
||||||
them. *)
|
We append the modules at the end as no library modules depend on
|
||||||
let top_sorted_modules =
|
them. *)
|
||||||
Ocamldep.Dep_graph.top_closed_implementations dep_graphs.impl modules
|
let top_sorted_modules =
|
||||||
>>^ fun modules -> modules @ wrapped_compat
|
Ocamldep.Dep_graph.top_closed_implementations dep_graphs.impl modules
|
||||||
in
|
>>^ fun modules -> modules @ wrapped_compat
|
||||||
(let modules = modules @ wrapped_compat in
|
in
|
||||||
|
(let modules = modules @ wrapped_compat in
|
||||||
List.iter Mode.all ~f:(fun mode ->
|
List.iter Mode.all ~f:(fun mode ->
|
||||||
build_lib lib ~scope ~flags ~dir ~obj_dir ~mode ~top_sorted_modules
|
build_lib lib ~scope ~flags ~dir ~obj_dir ~mode ~top_sorted_modules
|
||||||
~modules)));
|
~modules)));
|
||||||
(* Build *.cma.js *)
|
(* Build *.cma.js *)
|
||||||
SC.add_rules sctx (
|
SC.add_rules sctx (
|
||||||
let src = Library.archive lib ~dir ~ext:(Mode.compiled_lib_ext Mode.Byte) in
|
let src = Library.archive lib ~dir ~ext:(Mode.compiled_lib_ext Mode.Byte) in
|
||||||
let target = Path.extend_basename src ~suffix:".js" in
|
let target = Path.extend_basename src ~suffix:".js" in
|
||||||
Js_of_ocaml_rules.build_cm cctx ~js_of_ocaml ~src ~target);
|
Js_of_ocaml_rules.build_cm cctx ~js_of_ocaml ~src ~target);
|
||||||
|
|
||||||
if Dynlink_supported.By_the_os.get ctx.natdynlink_supported then
|
if Dynlink_supported.By_the_os.get ctx.natdynlink_supported then
|
||||||
build_shared lib ~dir ~flags ~ctx;
|
build_shared lib ~dir ~flags ~ctx;
|
||||||
|
end;
|
||||||
|
|
||||||
Odoc.setup_library_odoc_rules lib ~requires ~modules ~dep_graphs ~scope;
|
Odoc.setup_library_odoc_rules lib ~requires ~modules ~dep_graphs ~scope;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue