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
|
||||
~js_of_ocaml
|
||||
~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 } ->
|
||||
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
|
||||
Module_compilation.build_modules sctx
|
||||
~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 ->
|
||||
let flags = Ocaml_flags.default ~profile:(SC.profile sctx) in
|
||||
Module_compilation.build_module sctx m
|
||||
|
@ -618,7 +619,7 @@ module Gen(P : Install_rules.Params) = struct
|
|||
~dir
|
||||
~obj_dir
|
||||
~dep_graphs:(Ocamldep.Dep_graphs.dummy m)
|
||||
~includes:(Cm_kind.Dict.make_all (Arg_spec.As []))
|
||||
~includes:Module_compilation.Includes.empty
|
||||
~alias_module:None);
|
||||
|
||||
if Library.has_stubs lib then begin
|
||||
|
|
|
@ -4,6 +4,37 @@ open! No_io
|
|||
|
||||
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
|
||||
type 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
|
||||
])))
|
||||
|
||||
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 =
|
||||
List.iter Cm_kind.all ~f:(fun cm_kind ->
|
||||
let includes = Cm_kind.Dict.get includes cm_kind in
|
||||
build_cm sctx ?sandbox ~dynlink ~flags ~dir ~obj_dir ~dep_graphs m ~cm_kind
|
||||
~includes ~alias_module);
|
||||
(* Build *.cmo.js *)
|
||||
let src = Module.cm_file_unsafe m ~obj_dir Cm_kind.Cmo in
|
||||
let target =
|
||||
Path.extend_basename (Module.cm_file_unsafe m ~obj_dir:dir Cm_kind.Cmo)
|
||||
~suffix:".js"
|
||||
in
|
||||
SC.add_rules sctx
|
||||
(Js_of_ocaml_rules.build_cm sctx ~scope ~dir ~js_of_ocaml ~src ~target)
|
||||
Option.iter js_of_ocaml ~f:(fun js_of_ocaml ->
|
||||
(* Build *.cmo.js *)
|
||||
let src = Module.cm_file_unsafe m ~obj_dir Cm_kind.Cmo in
|
||||
let target =
|
||||
Path.extend_basename (Module.cm_file_unsafe m ~obj_dir:dir Cm_kind.Cmo)
|
||||
~suffix:".js"
|
||||
in
|
||||
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
|
||||
~dep_graphs ~modules ~requires ~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
|
||||
~dep_graphs ~modules ~includes ~alias_module =
|
||||
Module.Name.Map.iter
|
||||
(match alias_module with
|
||||
| None -> modules
|
||||
|
|
|
@ -2,19 +2,28 @@
|
|||
|
||||
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. *)
|
||||
val build_module
|
||||
: Super_context.t
|
||||
-> ?sandbox:bool
|
||||
-> dynlink:bool
|
||||
-> js_of_ocaml:Jbuild.Js_of_ocaml.t
|
||||
-> ?js_of_ocaml:Jbuild.Js_of_ocaml.t
|
||||
-> flags:Ocaml_flags.t
|
||||
-> Module.t
|
||||
-> scope:Scope.t
|
||||
-> dir:Path.t
|
||||
-> obj_dir:Path.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
|
||||
-> unit
|
||||
|
||||
|
@ -29,6 +38,6 @@ val build_modules
|
|||
-> obj_dir:Path.t
|
||||
-> dep_graphs:Ocamldep.Dep_graphs.t
|
||||
-> modules:Module.t Module.Name.Map.t
|
||||
-> requires:Lib.t list Or_exn.t
|
||||
-> includes:Includes.t
|
||||
-> alias_module:Module.t option
|
||||
-> unit
|
||||
|
|
Loading…
Reference in New Issue