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