Compute includes outside of build_modules
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
parent
634cd25b1b
commit
69af40dced
|
@ -191,7 +191,8 @@ let build_and_link_many
|
||||||
Module_compilation.build_modules sctx
|
Module_compilation.build_modules sctx
|
||||||
~js_of_ocaml
|
~js_of_ocaml
|
||||||
~dynlink:true ~flags ~scope ~dir ~obj_dir ~dep_graphs ~modules
|
~dynlink:true ~flags ~scope ~dir ~obj_dir ~dep_graphs ~modules
|
||||||
~requires ~alias_module:None;
|
~alias_module:None
|
||||||
|
~includes:(Module_compilation.Includes.make sctx ~requires);
|
||||||
|
|
||||||
List.iter programs ~f:(fun { Program.name; main_module_name } ->
|
List.iter programs ~f:(fun { Program.name; main_module_name } ->
|
||||||
let top_sorted_modules =
|
let top_sorted_modules =
|
||||||
|
|
|
@ -606,7 +606,8 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
let js_of_ocaml = lib.buildable.js_of_ocaml in
|
let js_of_ocaml = lib.buildable.js_of_ocaml in
|
||||||
Module_compilation.build_modules sctx
|
Module_compilation.build_modules sctx
|
||||||
~js_of_ocaml ~dynlink ~flags ~scope ~dir ~obj_dir ~dep_graphs
|
~js_of_ocaml ~dynlink ~flags ~scope ~dir ~obj_dir ~dep_graphs
|
||||||
~modules ~requires ~alias_module;
|
~modules ~alias_module
|
||||||
|
~includes:(Module_compilation.Includes.make sctx ~requires);
|
||||||
Option.iter alias_module ~f:(fun m ->
|
Option.iter alias_module ~f:(fun m ->
|
||||||
let flags = Ocaml_flags.default ~profile:(SC.profile sctx) in
|
let flags = Ocaml_flags.default ~profile:(SC.profile sctx) in
|
||||||
Module_compilation.build_module sctx m
|
Module_compilation.build_module sctx m
|
||||||
|
@ -618,7 +619,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
~dir
|
~dir
|
||||||
~obj_dir
|
~obj_dir
|
||||||
~dep_graphs:(Ocamldep.Dep_graphs.dummy m)
|
~dep_graphs:(Ocamldep.Dep_graphs.dummy m)
|
||||||
~includes:(Cm_kind.Dict.make_all (Arg_spec.As []))
|
~includes:Module_compilation.Includes.empty
|
||||||
~alias_module:None);
|
~alias_module:None);
|
||||||
|
|
||||||
if Library.has_stubs lib then begin
|
if Library.has_stubs lib then begin
|
||||||
|
|
|
@ -4,6 +4,37 @@ open! No_io
|
||||||
|
|
||||||
module SC = Super_context
|
module SC = Super_context
|
||||||
|
|
||||||
|
module Includes = struct
|
||||||
|
type t = string list Arg_spec.t Cm_kind.Dict.t
|
||||||
|
|
||||||
|
let make sctx ~requires : _ Cm_kind.Dict.t =
|
||||||
|
match requires with
|
||||||
|
| Error exn -> Cm_kind.Dict.make_all (Arg_spec.Dyn (fun _ -> raise exn))
|
||||||
|
| Ok libs ->
|
||||||
|
let iflags =
|
||||||
|
Lib.L.include_flags libs ~stdlib_dir:(SC.context sctx).stdlib_dir
|
||||||
|
in
|
||||||
|
let cmi_includes =
|
||||||
|
Arg_spec.S [ iflags
|
||||||
|
; Hidden_deps
|
||||||
|
(SC.Libs.file_deps sctx libs ~ext:".cmi")
|
||||||
|
]
|
||||||
|
in
|
||||||
|
let cmi_and_cmx_includes =
|
||||||
|
Arg_spec.S [ iflags
|
||||||
|
; Hidden_deps
|
||||||
|
(SC.Libs.file_deps sctx libs ~ext:".cmi-and-.cmx")
|
||||||
|
]
|
||||||
|
in
|
||||||
|
{ cmi = cmi_includes
|
||||||
|
; cmo = cmi_includes
|
||||||
|
; cmx = cmi_and_cmx_includes
|
||||||
|
}
|
||||||
|
|
||||||
|
let empty =
|
||||||
|
Cm_kind.Dict.make_all (Arg_spec.As [])
|
||||||
|
end
|
||||||
|
|
||||||
module Target : sig
|
module Target : sig
|
||||||
type t
|
type t
|
||||||
val cm : Module.t -> Cm_kind.t -> t
|
val cm : Module.t -> Cm_kind.t -> t
|
||||||
|
@ -107,47 +138,24 @@ let build_cm sctx ?sandbox ~dynlink ~flags ~cm_kind ~dep_graphs
|
||||||
; Hidden_targets hidden_targets
|
; Hidden_targets hidden_targets
|
||||||
])))
|
])))
|
||||||
|
|
||||||
let build_module sctx ?sandbox ~dynlink ~js_of_ocaml ~flags m ~scope ~dir
|
let build_module sctx ?sandbox ~dynlink ?js_of_ocaml ~flags m ~scope ~dir
|
||||||
~obj_dir ~dep_graphs ~includes ~alias_module =
|
~obj_dir ~dep_graphs ~includes ~alias_module =
|
||||||
List.iter Cm_kind.all ~f:(fun cm_kind ->
|
List.iter Cm_kind.all ~f:(fun cm_kind ->
|
||||||
let includes = Cm_kind.Dict.get includes cm_kind in
|
let includes = Cm_kind.Dict.get includes cm_kind in
|
||||||
build_cm sctx ?sandbox ~dynlink ~flags ~dir ~obj_dir ~dep_graphs m ~cm_kind
|
build_cm sctx ?sandbox ~dynlink ~flags ~dir ~obj_dir ~dep_graphs m ~cm_kind
|
||||||
~includes ~alias_module);
|
~includes ~alias_module);
|
||||||
(* Build *.cmo.js *)
|
Option.iter js_of_ocaml ~f:(fun js_of_ocaml ->
|
||||||
let src = Module.cm_file_unsafe m ~obj_dir Cm_kind.Cmo in
|
(* Build *.cmo.js *)
|
||||||
let target =
|
let src = Module.cm_file_unsafe m ~obj_dir Cm_kind.Cmo in
|
||||||
Path.extend_basename (Module.cm_file_unsafe m ~obj_dir:dir Cm_kind.Cmo)
|
let target =
|
||||||
~suffix:".js"
|
Path.extend_basename (Module.cm_file_unsafe m ~obj_dir:dir Cm_kind.Cmo)
|
||||||
in
|
~suffix:".js"
|
||||||
SC.add_rules sctx
|
in
|
||||||
(Js_of_ocaml_rules.build_cm sctx ~scope ~dir ~js_of_ocaml ~src ~target)
|
SC.add_rules sctx
|
||||||
|
(Js_of_ocaml_rules.build_cm sctx ~scope ~dir ~js_of_ocaml ~src ~target))
|
||||||
|
|
||||||
let build_modules sctx ~dynlink ~js_of_ocaml ~flags ~scope ~dir ~obj_dir
|
let build_modules sctx ~dynlink ~js_of_ocaml ~flags ~scope ~dir ~obj_dir
|
||||||
~dep_graphs ~modules ~requires ~alias_module =
|
~dep_graphs ~modules ~includes ~alias_module =
|
||||||
let includes : _ Cm_kind.Dict.t =
|
|
||||||
match requires with
|
|
||||||
| Error exn -> Cm_kind.Dict.make_all (Arg_spec.Dyn (fun _ -> raise exn))
|
|
||||||
| Ok libs ->
|
|
||||||
let iflags =
|
|
||||||
Lib.L.include_flags libs ~stdlib_dir:(SC.context sctx).stdlib_dir
|
|
||||||
in
|
|
||||||
let cmi_includes =
|
|
||||||
Arg_spec.S [ iflags
|
|
||||||
; Hidden_deps
|
|
||||||
(SC.Libs.file_deps sctx libs ~ext:".cmi")
|
|
||||||
]
|
|
||||||
in
|
|
||||||
let cmi_and_cmx_includes =
|
|
||||||
Arg_spec.S [ iflags
|
|
||||||
; Hidden_deps
|
|
||||||
(SC.Libs.file_deps sctx libs ~ext:".cmi-and-.cmx")
|
|
||||||
]
|
|
||||||
in
|
|
||||||
{ cmi = cmi_includes
|
|
||||||
; cmo = cmi_includes
|
|
||||||
; cmx = cmi_and_cmx_includes
|
|
||||||
}
|
|
||||||
in
|
|
||||||
Module.Name.Map.iter
|
Module.Name.Map.iter
|
||||||
(match alias_module with
|
(match alias_module with
|
||||||
| None -> modules
|
| None -> modules
|
||||||
|
|
|
@ -2,19 +2,28 @@
|
||||||
|
|
||||||
open Import
|
open Import
|
||||||
|
|
||||||
|
module Includes : sig
|
||||||
|
type t
|
||||||
|
|
||||||
|
val make : Super_context.t -> requires:Lib.t list Or_exn.t -> t
|
||||||
|
|
||||||
|
(** Empty set of include directories *)
|
||||||
|
val empty : t
|
||||||
|
end
|
||||||
|
|
||||||
(** Setup rules to build a single module. *)
|
(** Setup rules to build a single module. *)
|
||||||
val build_module
|
val build_module
|
||||||
: Super_context.t
|
: Super_context.t
|
||||||
-> ?sandbox:bool
|
-> ?sandbox:bool
|
||||||
-> dynlink:bool
|
-> dynlink:bool
|
||||||
-> js_of_ocaml:Jbuild.Js_of_ocaml.t
|
-> ?js_of_ocaml:Jbuild.Js_of_ocaml.t
|
||||||
-> flags:Ocaml_flags.t
|
-> flags:Ocaml_flags.t
|
||||||
-> Module.t
|
-> Module.t
|
||||||
-> scope:Scope.t
|
-> scope:Scope.t
|
||||||
-> dir:Path.t
|
-> dir:Path.t
|
||||||
-> obj_dir:Path.t
|
-> obj_dir:Path.t
|
||||||
-> dep_graphs:Ocamldep.Dep_graphs.t
|
-> dep_graphs:Ocamldep.Dep_graphs.t
|
||||||
-> includes:string list Arg_spec.t Cm_kind.Dict.t
|
-> includes:Includes.t
|
||||||
-> alias_module:Module.t option
|
-> alias_module:Module.t option
|
||||||
-> unit
|
-> unit
|
||||||
|
|
||||||
|
@ -29,6 +38,6 @@ val build_modules
|
||||||
-> obj_dir:Path.t
|
-> obj_dir:Path.t
|
||||||
-> dep_graphs:Ocamldep.Dep_graphs.t
|
-> dep_graphs:Ocamldep.Dep_graphs.t
|
||||||
-> modules:Module.t Module.Name.Map.t
|
-> modules:Module.t Module.Name.Map.t
|
||||||
-> requires:Lib.t list Or_exn.t
|
-> includes:Includes.t
|
||||||
-> alias_module:Module.t option
|
-> alias_module:Module.t option
|
||||||
-> unit
|
-> unit
|
||||||
|
|
Loading…
Reference in New Issue