Add rule locs to failed rules
this will add a location that will point to the rule that failed Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
b9cbdd236b
commit
66f2004f8f
|
@ -354,6 +354,7 @@ module Dir_status = struct
|
|||
; action : (unit, Action.t) Build.t
|
||||
; locks : Path.t list
|
||||
; context : Context.t
|
||||
; loc : Loc.t option
|
||||
}
|
||||
|
||||
|
||||
|
@ -684,15 +685,15 @@ let remove_old_artifacts t ~dir ~subdirs_to_keep =
|
|||
if not (Path.Table.mem t.files path) then Path.unlink path)
|
||||
|
||||
let no_rule_found =
|
||||
let fail fn =
|
||||
die "No rule found for %s" (Utils.describe_target fn)
|
||||
let fail fn ~loc =
|
||||
Loc.fail_opt loc "No rule found for %s" (Utils.describe_target fn)
|
||||
in
|
||||
fun t fn ->
|
||||
fun t ~loc fn ->
|
||||
match Utils.analyse_target fn with
|
||||
| Other _ -> fail fn
|
||||
| Other _ -> fail fn ~loc
|
||||
| Regular (ctx, _) ->
|
||||
if String.Map.mem t.contexts ctx then
|
||||
fail fn
|
||||
fail fn ~loc
|
||||
else
|
||||
die "Trying to build %s but build context %s doesn't exist.%s"
|
||||
(Path.to_string_maybe_quoted fn)
|
||||
|
@ -700,7 +701,7 @@ let no_rule_found =
|
|||
(hint ctx (String.Map.keys t.contexts))
|
||||
| Alias (ctx, fn') ->
|
||||
if String.Map.mem t.contexts ctx then
|
||||
fail fn
|
||||
fail fn ~loc
|
||||
else
|
||||
let fn = Path.append (Path.relative Path.build_dir ctx) fn' in
|
||||
die "Trying to build alias %s but build context %s doesn't exist.%s"
|
||||
|
@ -729,7 +730,7 @@ let rec compile_rule t ?(copy_source=false) pre_rule =
|
|||
|
||||
let eval_rule () =
|
||||
t.hook Rule_started;
|
||||
wait_for_deps t (Lazy.force static_deps).rule_deps
|
||||
wait_for_deps t (Lazy.force static_deps).rule_deps ~loc
|
||||
>>| fun () ->
|
||||
Build_exec.exec t build ()
|
||||
in
|
||||
|
@ -737,10 +738,10 @@ let rec compile_rule t ?(copy_source=false) pre_rule =
|
|||
let static_deps = (Lazy.force static_deps).action_deps in
|
||||
Fiber.fork_and_join_unit
|
||||
(fun () ->
|
||||
wait_for_deps t static_deps)
|
||||
wait_for_deps ~loc t static_deps)
|
||||
(fun () ->
|
||||
Fiber.Future.wait rule_evaluation >>= fun (action, dyn_deps) ->
|
||||
wait_for_deps t (Path.Set.diff dyn_deps static_deps)
|
||||
wait_for_deps ~loc t (Path.Set.diff dyn_deps static_deps)
|
||||
>>| fun () ->
|
||||
(action, dyn_deps))
|
||||
>>= fun (action, dyn_deps) ->
|
||||
|
@ -949,13 +950,13 @@ and load_dir_step2_exn t ~dir ~collector ~lazy_generators =
|
|||
let rules, deps =
|
||||
List.fold_left actions ~init:(rules, deps)
|
||||
~f:(fun (rules, deps)
|
||||
{ Dir_status. stamp; action; locks ; context } ->
|
||||
{ Dir_status. stamp; action; locks ; context ; loc } ->
|
||||
let path =
|
||||
Path.extend_basename base_path
|
||||
~suffix:("-" ^ Digest.to_hex stamp)
|
||||
in
|
||||
let rule =
|
||||
Pre_rule.make ~locks ~context:(Some context)
|
||||
Pre_rule.make ~locks ~context:(Some context) ?loc
|
||||
(Build.progn [ action; Build.create_file path ])
|
||||
in
|
||||
(rule :: rules, Path.Set.add deps path))
|
||||
|
@ -1107,7 +1108,7 @@ The following targets are not:
|
|||
|
||||
targets
|
||||
|
||||
and wait_for_file t fn =
|
||||
and wait_for_file t ~loc fn =
|
||||
match Path.Table.find t.files fn with
|
||||
| Some file -> wait_for_file_found fn file
|
||||
| None ->
|
||||
|
@ -1116,7 +1117,7 @@ and wait_for_file t fn =
|
|||
load_dir t ~dir;
|
||||
match Path.Table.find t.files fn with
|
||||
| Some file -> wait_for_file_found fn file
|
||||
| None -> no_rule_found t fn
|
||||
| None -> no_rule_found t ~loc fn
|
||||
end else if Path.exists fn then
|
||||
Fiber.return ()
|
||||
else
|
||||
|
@ -1146,8 +1147,8 @@ and wait_for_file_found fn (File_spec.T file) =
|
|||
};
|
||||
Fiber.Future.wait rule_execution)
|
||||
|
||||
and wait_for_deps t deps =
|
||||
Fiber.parallel_iter (Path.Set.to_list deps) ~f:(wait_for_file t)
|
||||
and wait_for_deps ~loc t deps =
|
||||
Fiber.parallel_iter (Path.Set.to_list deps) ~f:(wait_for_file ~loc t)
|
||||
|
||||
let stamp_file_for_files_of t ~dir ~ext =
|
||||
let files_of_dir =
|
||||
|
@ -1260,7 +1261,7 @@ let eval_request t ~request ~process_target =
|
|||
Fiber.fork_and_join_unit
|
||||
(fun () -> process_targets static_deps)
|
||||
(fun () ->
|
||||
wait_for_deps t rule_deps
|
||||
wait_for_deps t ~loc:None rule_deps
|
||||
>>= fun () ->
|
||||
let result, dyn_deps = Build_exec.exec t request () in
|
||||
process_targets (Path.Set.diff dyn_deps static_deps)
|
||||
|
@ -1285,7 +1286,7 @@ let update_universe t =
|
|||
let do_build t ~request =
|
||||
entry_point t ~f:(fun () ->
|
||||
update_universe t;
|
||||
eval_request t ~request ~process_target:(wait_for_file t))
|
||||
eval_request t ~request ~process_target:(wait_for_file ~loc:None t))
|
||||
|
||||
module Ir_set = Set.Make(Internal_rule)
|
||||
|
||||
|
@ -1616,12 +1617,13 @@ module Alias = struct
|
|||
Build.fanout def.dyn_deps build >>^ fun (a, b) ->
|
||||
Path.Set.union a b
|
||||
|
||||
let add_action build_system t ~context ?(locks=[]) ~stamp action =
|
||||
let add_action build_system t ~context ~loc ?(locks=[]) ~stamp action =
|
||||
let def = get_alias_def build_system t in
|
||||
def.actions <- { stamp = Digest.string (Sexp.to_string ~syntax:Dune stamp)
|
||||
; action
|
||||
; locks
|
||||
; context
|
||||
; loc
|
||||
} :: def.actions
|
||||
end
|
||||
|
||||
|
|
|
@ -171,6 +171,7 @@ module Alias : sig
|
|||
: build_system
|
||||
-> t
|
||||
-> context:Context.t
|
||||
-> loc:Loc.t option
|
||||
-> ?locks:Path.t list
|
||||
-> stamp:Sexp.t
|
||||
-> (unit, Action.t) Build.t
|
||||
|
|
|
@ -608,6 +608,7 @@ module Gen(P : Install_rules.Params) = struct
|
|||
; deps = t.deps
|
||||
; action = None
|
||||
; enabled_if = t.enabled_if
|
||||
; loc
|
||||
} in
|
||||
match test_kind (loc, s) with
|
||||
| `Regular ->
|
||||
|
|
|
@ -258,6 +258,7 @@ include Sub_system.Register_end_point(
|
|||
in
|
||||
|
||||
SC.add_alias_action sctx
|
||||
~loc:(Some info.loc)
|
||||
(Build_system.Alias.runtest ~dir)
|
||||
~stamp:(List [ Sexp.unsafe_atom_of_string "ppx-runner"
|
||||
; Quoted_string name
|
||||
|
|
|
@ -1558,6 +1558,7 @@ module Alias_conf = struct
|
|||
; locks : String_with_vars.t list
|
||||
; package : Package.t option
|
||||
; enabled_if : String_with_vars.t Blang.t option
|
||||
; loc : Loc.t
|
||||
}
|
||||
|
||||
let alias_name =
|
||||
|
@ -1570,6 +1571,7 @@ module Alias_conf = struct
|
|||
let t =
|
||||
record
|
||||
(let%map name = field "name" alias_name
|
||||
and loc = loc
|
||||
and package = field_o "package" Pkg.t
|
||||
and action = field_o "action" (located Action.Unexpanded.t)
|
||||
and locks = field "locks" (list String_with_vars.t) ~default:[]
|
||||
|
@ -1582,6 +1584,7 @@ module Alias_conf = struct
|
|||
; package
|
||||
; locks
|
||||
; enabled_if
|
||||
; loc
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
@ -338,6 +338,7 @@ module Alias_conf : sig
|
|||
; locks : String_with_vars.t list
|
||||
; package : Package.t option
|
||||
; enabled_if : String_with_vars.t Blang.t option
|
||||
; loc : Loc.t
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -475,7 +475,7 @@ let lint_module sctx ~dir ~dep_kind ~lint ~lib_name ~scope ~dir_kind =
|
|||
let action = Action.Unexpanded.Chdir (workspace_root_var, action) in
|
||||
Module.iter source ~f:(fun _ (src : Module.File.t) ->
|
||||
let bindings = Pform.Map.input_file src.path in
|
||||
add_alias src.path
|
||||
add_alias src.path ~loc:None
|
||||
(Build.path src.path
|
||||
>>^ (fun _ -> Jbuild.Bindings.empty)
|
||||
>>> SC.Action.run sctx
|
||||
|
@ -516,6 +516,7 @@ let lint_module sctx ~dir ~dep_kind ~lint ~lib_name ~scope ~dir_kind =
|
|||
(fun ~source ~ast ->
|
||||
Module.iter ast ~f:(fun kind src ->
|
||||
add_alias src.path
|
||||
~loc:None
|
||||
(promote_correction ~suffix:corrected_suffix
|
||||
(Option.value_exn (Module.file source kind))
|
||||
(Build.of_result_map driver_and_flags ~f:(fun (exe, flags) ->
|
||||
|
|
|
@ -65,9 +65,9 @@ let copy_files sctx ~dir ~scope ~src_dir (def: Copy_files.t) =
|
|||
~dst:file_dst);
|
||||
file_dst)
|
||||
|
||||
let add_alias sctx ~dir ~name ~stamp ?(locks=[]) build =
|
||||
let add_alias sctx ~dir ~name ~stamp ~loc ?(locks=[]) build =
|
||||
let alias = Build_system.Alias.make name ~dir in
|
||||
SC.add_alias_action sctx alias ~locks ~stamp build
|
||||
SC.add_alias_action sctx alias ~loc ~locks ~stamp build
|
||||
|
||||
let alias sctx ~dir ~scope (alias_conf : Alias_conf.t) =
|
||||
let enabled =
|
||||
|
@ -91,9 +91,11 @@ let alias sctx ~dir ~scope (alias_conf : Alias_conf.t) =
|
|||
(Option.map alias_conf.action ~f:snd)
|
||||
]
|
||||
in
|
||||
let loc = Some alias_conf.loc in
|
||||
if enabled then
|
||||
add_alias sctx
|
||||
~dir
|
||||
~loc
|
||||
~name:alias_conf.name
|
||||
~stamp
|
||||
~locks:(interpret_locks sctx ~dir ~scope alias_conf.locks)
|
||||
|
@ -114,6 +116,7 @@ let alias sctx ~dir ~scope (alias_conf : Alias_conf.t) =
|
|||
~scope)
|
||||
else
|
||||
add_alias sctx
|
||||
~loc
|
||||
~dir
|
||||
~name:alias_conf.name
|
||||
~stamp
|
||||
|
|
|
@ -112,8 +112,9 @@ let add_rules t ?sandbox builds =
|
|||
let add_alias_deps t alias ?dyn_deps deps =
|
||||
Alias.add_deps t.build_system alias ?dyn_deps deps
|
||||
|
||||
let add_alias_action t alias ?locks ~stamp action =
|
||||
Alias.add_action t.build_system ~context:t.context alias ?locks ~stamp action
|
||||
let add_alias_action t alias ~loc ?locks ~stamp action =
|
||||
Alias.add_action t.build_system ~context:t.context alias ~loc ?locks
|
||||
~stamp action
|
||||
|
||||
let eval_glob t ~dir re = Build_system.eval_glob t.build_system ~dir re
|
||||
let load_dir t ~dir = Build_system.load_dir t.build_system ~dir
|
||||
|
|
|
@ -148,6 +148,7 @@ val add_alias_deps
|
|||
val add_alias_action
|
||||
: t
|
||||
-> Build_system.Alias.t
|
||||
-> loc:Loc.t option
|
||||
-> ?locks:Path.t list
|
||||
-> stamp:Sexp.t
|
||||
-> (unit, Action.t) Build.t
|
||||
|
|
|
@ -2,7 +2,8 @@ Exact path provided by the user:
|
|||
|
||||
$ dune runtest --root precise-path
|
||||
Entering directory 'precise-path'
|
||||
No rule found for foo.exe
|
||||
File "dune", line 1, characters 0-49:
|
||||
Error: No rule found for foo.exe
|
||||
[1]
|
||||
|
||||
Path that needs to be searched:
|
||||
|
|
Loading…
Reference in New Issue