From dea2ac77cab3f35ac6d8cca9d3ba0ca82793a5aa Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 15 Mar 2018 18:17:00 +0800 Subject: [PATCH] No optional args for context --- src/action.ml | 2 +- src/action.mli | 2 +- src/build_interpret.ml | 2 +- src/build_interpret.mli | 2 +- src/build_system.ml | 8 +++++--- src/super_context.ml | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/action.ml b/src/action.ml index 2e5bd7e7..f91ac157 100644 --- a/src/action.ml +++ b/src/action.ml @@ -888,7 +888,7 @@ and exec_list l ~ectx ~dir ~env ~stdout_to ~stderr_to = exec t ~ectx ~dir ~env ~stdout_to ~stderr_to >>= fun () -> exec_list rest ~ectx ~dir ~env ~stdout_to ~stderr_to -let exec ~targets ?context t = +let exec ~targets ~context t = let env = match (context : Context.t option) with | None -> Env.initial () diff --git a/src/action.mli b/src/action.mli index b85f7254..87df693b 100644 --- a/src/action.mli +++ b/src/action.mli @@ -112,7 +112,7 @@ module Unexpanded : sig -> Partial.t end -val exec : targets:Path.Set.t -> ?context:Context.t -> t -> unit Fiber.t +val exec : targets:Path.Set.t -> context:Context.t option -> t -> unit Fiber.t (* Return a sandboxed version of an action *) val sandbox diff --git a/src/build_interpret.ml b/src/build_interpret.ml index 42c4a902..37c55471 100644 --- a/src/build_interpret.ml +++ b/src/build_interpret.ml @@ -191,7 +191,7 @@ module Rule = struct } let make ?(sandbox=false) ?(mode=Jbuild.Rule.Mode.Not_a_rule_stanza) - ?context ?(locks=[]) ?loc build = + ~context ?(locks=[]) ?loc build = let targets = targets build in let dir = match targets with diff --git a/src/build_interpret.mli b/src/build_interpret.mli index e96b1794..5d2f08c7 100644 --- a/src/build_interpret.mli +++ b/src/build_interpret.mli @@ -25,7 +25,7 @@ module Rule : sig val make : ?sandbox:bool -> ?mode:Jbuild.Rule.Mode.t - -> ?context:Context.t + -> context:Context.t option -> ?locks:Path.t list -> ?loc:Loc.t -> (unit, Action.t) Build.t diff --git a/src/build_system.ml b/src/build_system.ml index ac56495a..05997a31 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -736,7 +736,7 @@ let rec compile_rule t ?(copy_source=false) pre_rule = in make_local_dirs t (Action.chdirs action); with_locks locks ~f:(fun () -> - Action.exec ?context ~targets action) >>| fun () -> + Action.exec ~context ~targets action) >>| fun () -> Option.iter sandbox_dir ~f:Path.rm_rf; (* All went well, these targets are no longer pending *) pending_targets := Pset.diff !pending_targets targets; @@ -783,7 +783,7 @@ and setup_copy_rules t ~ctx_dir ~non_target_source_files = This allows to keep generated files in tarballs. Maybe we should allow it on a case-by-case basis though. *) - compile_rule t (Pre_rule.make build) ~copy_source:true) + compile_rule t (Pre_rule.make build ~context:None) ~copy_source:true) and load_dir t ~dir = ignore (load_dir_and_get_targets t ~dir : Pset.t) and targets_of t ~dir = load_dir_and_get_targets t ~dir @@ -860,13 +860,14 @@ and load_dir_step2_exn t ~dir ~collector ~lazy_generators = ~suffix:("-" ^ Digest.to_hex stamp) in let rule = - Pre_rule.make ~locks + Pre_rule.make ~locks ~context:None (Build.progn [ action; Build.create_file path ]) in (rule :: rules, Pset.add deps path)) in let path = Path.extend_basename base_path ~suffix:Alias0.suffix in (Pre_rule.make + ~context:None (Build.path_set deps >>> Build.action ~targets:[path] (Redirect (Stdout, @@ -1074,6 +1075,7 @@ let stamp_file_for_files_of t ~dir ~ext = compile_rule t (let open Build.O in Pre_rule.make + ~context:None (Build.paths files >>> Build.action ~targets:[stamp_file] (Action.with_stdout_to stamp_file diff --git a/src/super_context.ml b/src/super_context.ml index ca13e310..6865261d 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -209,13 +209,13 @@ let add_rule t ?sandbox ?mode ?locks ?loc build = let build = Build.O.(>>>) build t.chdir in Build_system.add_rule t.build_system (Build_interpret.Rule.make ?sandbox ?mode ?locks ?loc - ~context:t.context build) + ~context:(Some t.context) build) let add_rule_get_targets t ?sandbox ?mode ?locks ?loc build = let build = Build.O.(>>>) build t.chdir in let rule = Build_interpret.Rule.make ?sandbox ?mode ?locks ?loc - ~context:t.context build + ~context:(Some t.context) build in Build_system.add_rule t.build_system rule; List.map rule.targets ~f:Build_interpret.Target.path