Remove the ?extra_targets argument of Build.run
Instead, use Hidden_targets
This commit is contained in:
parent
bd7f793792
commit
13b770962d
10
src/build.ml
10
src/build.ml
|
@ -211,14 +211,8 @@ let prog_and_args ?(dir=Path.root) prog args =
|
||||||
>>>
|
>>>
|
||||||
arr fst))
|
arr fst))
|
||||||
|
|
||||||
let run ~context ?(dir=context.Context.build_dir) ?stdout_to ?(extra_targets=[])
|
let run ~context ?(dir=context.Context.build_dir) ?stdout_to prog args =
|
||||||
prog args =
|
let targets = Arg_spec.add_targets args (Option.to_list stdout_to) in
|
||||||
let extra_targets =
|
|
||||||
match stdout_to with
|
|
||||||
| None -> extra_targets
|
|
||||||
| Some fn -> fn :: extra_targets
|
|
||||||
in
|
|
||||||
let targets = Arg_spec.add_targets args extra_targets in
|
|
||||||
prog_and_args ~dir prog args
|
prog_and_args ~dir prog args
|
||||||
>>>
|
>>>
|
||||||
Targets targets
|
Targets targets
|
||||||
|
|
|
@ -133,7 +133,6 @@ val run
|
||||||
: context:Context.t
|
: context:Context.t
|
||||||
-> ?dir:Path.t (* default: [context.build_dir] *)
|
-> ?dir:Path.t (* default: [context.build_dir] *)
|
||||||
-> ?stdout_to:Path.t
|
-> ?stdout_to:Path.t
|
||||||
-> ?extra_targets:Path.t list
|
|
||||||
-> Action.Prog.t
|
-> Action.Prog.t
|
||||||
-> 'a Arg_spec.t list
|
-> 'a Arg_spec.t list
|
||||||
-> ('a, Action.t) t
|
-> ('a, Action.t) t
|
||||||
|
|
|
@ -471,10 +471,6 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
(SC.expand_and_eval_set sctx ~scope ~dir lib.library_flags ~standard:[])
|
(SC.expand_and_eval_set sctx ~scope ~dir lib.library_flags ~standard:[])
|
||||||
>>>
|
>>>
|
||||||
Build.run ~context:ctx (Ok compiler)
|
Build.run ~context:ctx (Ok compiler)
|
||||||
~extra_targets:(
|
|
||||||
match mode with
|
|
||||||
| Byte -> []
|
|
||||||
| Native -> [lib_archive lib ~dir ~ext:ctx.ext_lib])
|
|
||||||
[ Dyn (fun (_, _, flags, _) -> As flags)
|
[ Dyn (fun (_, _, flags, _) -> As flags)
|
||||||
; A "-a"; A "-o"; Target target
|
; A "-a"; A "-o"; Target target
|
||||||
; As stubs_flags
|
; As stubs_flags
|
||||||
|
@ -484,6 +480,10 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
| Normal -> []
|
| Normal -> []
|
||||||
| Ppx_deriver | Ppx_rewriter -> ["-linkall"])
|
| Ppx_deriver | Ppx_rewriter -> ["-linkall"])
|
||||||
; Dyn (fun (cm_files, _, _, _) -> Deps cm_files)
|
; Dyn (fun (cm_files, _, _, _) -> Deps cm_files)
|
||||||
|
; Hidden_targets
|
||||||
|
(match mode with
|
||||||
|
| Byte -> []
|
||||||
|
| Native -> [lib_archive lib ~dir ~ext:ctx.ext_lib])
|
||||||
]))
|
]))
|
||||||
|
|
||||||
let build_c_file (lib : Library.t) ~scope ~dir ~includes c_name =
|
let build_c_file (lib : Library.t) ~scope ~dir ~includes c_name =
|
||||||
|
@ -652,7 +652,6 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
lib.c_library_flags ~standard:[]
|
lib.c_library_flags ~standard:[]
|
||||||
>>>
|
>>>
|
||||||
Build.run ~context:ctx
|
Build.run ~context:ctx
|
||||||
~extra_targets:targets
|
|
||||||
(Ok ctx.ocamlmklib)
|
(Ok ctx.ocamlmklib)
|
||||||
[ As (Utils.g ())
|
[ As (Utils.g ())
|
||||||
; if custom then A "-custom" else As []
|
; if custom then A "-custom" else As []
|
||||||
|
@ -667,6 +666,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
else
|
else
|
||||||
As cclibs
|
As cclibs
|
||||||
)
|
)
|
||||||
|
; Hidden_targets targets
|
||||||
])
|
])
|
||||||
in
|
in
|
||||||
let static = stubs_archive lib ~dir in
|
let static = stubs_archive lib ~dir in
|
||||||
|
|
|
@ -28,12 +28,12 @@ let gen_rules sctx ~dir ~scope (t : Jbuild.Menhir.t) =
|
||||||
let menhir_binary =
|
let menhir_binary =
|
||||||
SC.resolve_program sctx "menhir" ~hint:"opam install menhir"
|
SC.resolve_program sctx "menhir" ~hint:"opam install menhir"
|
||||||
in
|
in
|
||||||
(* [extra_targets] is to tell Jbuilder about generated files that do
|
(* [hidden_targets] is to tell Jbuilder about generated files that
|
||||||
not appear in the menhir command line. *)
|
do not appear in the menhir command line. *)
|
||||||
let menhir ~extra_targets args =
|
let menhir args =
|
||||||
flags
|
flags
|
||||||
>>>
|
>>>
|
||||||
Build.run ~extra_targets
|
Build.run
|
||||||
menhir_binary
|
menhir_binary
|
||||||
~dir
|
~dir
|
||||||
~context:(SC.context sctx)
|
~context:(SC.context sctx)
|
||||||
|
@ -48,16 +48,16 @@ let gen_rules sctx ~dir ~scope (t : Jbuild.Menhir.t) =
|
||||||
List.concat_map t.modules ~f:(fun name ->
|
List.concat_map t.modules ~f:(fun name ->
|
||||||
add_rule_get_targets (
|
add_rule_get_targets (
|
||||||
menhir
|
menhir
|
||||||
~extra_targets:(targets name)
|
|
||||||
[ Dyn (fun x -> As x)
|
[ Dyn (fun x -> As x)
|
||||||
; Dep (mly name)
|
; Dep (mly name)
|
||||||
|
; Hidden_targets (targets name)
|
||||||
]))
|
]))
|
||||||
| Some merge_into ->
|
| Some merge_into ->
|
||||||
add_rule_get_targets (
|
add_rule_get_targets (
|
||||||
menhir
|
menhir
|
||||||
~extra_targets:(targets merge_into)
|
|
||||||
[ A "--base" ; A merge_into
|
[ A "--base" ; A merge_into
|
||||||
; Dyn (fun x -> As x)
|
; Dyn (fun x -> As x)
|
||||||
; Deps (List.map ~f:mly t.modules)
|
; Deps (List.map ~f:mly t.modules)
|
||||||
|
; Hidden_targets (targets merge_into)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -70,13 +70,13 @@ let build_cm sctx ?sandbox ~dynlink ~flags ~cm_kind ~dep_graphs
|
||||||
let fn = Option.value_exn (Target.cmt m ml_kind) in
|
let fn = Option.value_exn (Target.cmt m ml_kind) in
|
||||||
(fn :: other_targets, A "-bin-annot")
|
(fn :: other_targets, A "-bin-annot")
|
||||||
in
|
in
|
||||||
let extra_targets = List.map other_targets ~f:(Target.file obj_dir) in
|
let hidden_targets = List.map other_targets ~f:(Target.file obj_dir) in
|
||||||
if obj_dir <> dir then begin
|
if obj_dir <> dir then begin
|
||||||
(* Symlink the object files in the original directory for
|
(* Symlink the object files in the original directory for
|
||||||
backward compatibility *)
|
backward compatibility *)
|
||||||
let old_dst = Module.cm_file_unsafe m ~obj_dir:dir cm_kind in
|
let old_dst = Module.cm_file_unsafe m ~obj_dir:dir cm_kind in
|
||||||
SC.add_rule sctx (Build.symlink ~src:dst ~dst:old_dst) ;
|
SC.add_rule sctx (Build.symlink ~src:dst ~dst:old_dst) ;
|
||||||
List.iter2 extra_targets other_targets ~f:(fun in_obj_dir target ->
|
List.iter2 hidden_targets other_targets ~f:(fun in_obj_dir target ->
|
||||||
let in_dir = Target.file dir target in
|
let in_dir = Target.file dir target in
|
||||||
SC.add_rule sctx (Build.symlink ~src:in_obj_dir ~dst:in_dir))
|
SC.add_rule sctx (Build.symlink ~src:in_obj_dir ~dst:in_dir))
|
||||||
end;
|
end;
|
||||||
|
@ -91,7 +91,6 @@ let build_cm sctx ?sandbox ~dynlink ~flags ~cm_kind ~dep_graphs
|
||||||
other_cm_files >>>
|
other_cm_files >>>
|
||||||
Ocaml_flags.get_for_cm flags ~cm_kind >>>
|
Ocaml_flags.get_for_cm flags ~cm_kind >>>
|
||||||
Build.run ~context:ctx (Ok compiler)
|
Build.run ~context:ctx (Ok compiler)
|
||||||
~extra_targets
|
|
||||||
[ Dyn (fun ocaml_flags -> As ocaml_flags)
|
[ Dyn (fun ocaml_flags -> As ocaml_flags)
|
||||||
; cmt_args
|
; cmt_args
|
||||||
; A "-I"; Path obj_dir
|
; A "-I"; Path obj_dir
|
||||||
|
@ -105,6 +104,7 @@ let build_cm sctx ?sandbox ~dynlink ~flags ~cm_kind ~dep_graphs
|
||||||
As ["-open"; Module.Name.to_string m.name])
|
As ["-open"; Module.Name.to_string m.name])
|
||||||
; A "-o"; Target dst
|
; A "-o"; Target dst
|
||||||
; A "-c"; Ml_kind.flag ml_kind; Dep src
|
; A "-c"; Ml_kind.flag ml_kind; Dep src
|
||||||
|
; 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
|
||||||
|
|
|
@ -175,11 +175,12 @@ module Gen (S : sig val sctx : SC.t end) = struct
|
||||||
Build.remove_tree to_remove
|
Build.remove_tree to_remove
|
||||||
:: Build.mkdir odoc_file.html_dir
|
:: Build.mkdir odoc_file.html_dir
|
||||||
:: Build.run ~context ~dir:Paths.html_root
|
:: Build.run ~context ~dir:Paths.html_root
|
||||||
odoc ~extra_targets:[odoc_file.html_file]
|
odoc
|
||||||
[ A "html"
|
[ A "html"
|
||||||
; odoc_include_flags requires
|
; odoc_include_flags requires
|
||||||
; A "-o"; Path Paths.html_root
|
; A "-o"; Path Paths.html_root
|
||||||
; Dep odoc_file.odoc_input
|
; Dep odoc_file.odoc_input
|
||||||
|
; Hidden_targets [odoc_file.html_file]
|
||||||
]
|
]
|
||||||
:: jbuilder_keep
|
:: jbuilder_keep
|
||||||
)
|
)
|
||||||
|
@ -213,9 +214,10 @@ module Gen (S : sig val sctx : SC.t end) = struct
|
||||||
SC.add_rule sctx
|
SC.add_rule sctx
|
||||||
(Build.run ~context
|
(Build.run ~context
|
||||||
~dir:context.build_dir
|
~dir:context.build_dir
|
||||||
~extra_targets:[css_file]
|
|
||||||
odoc
|
odoc
|
||||||
[ A "css"; A "-o"; Path Paths.html_root ])
|
[ A "css"; A "-o"; Path Paths.html_root
|
||||||
|
; Hidden_targets [css_file]
|
||||||
|
])
|
||||||
|
|
||||||
let sp = Printf.sprintf
|
let sp = Printf.sprintf
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue