Hint for mistyped targets
This commit is contained in:
parent
41d6b3c83a
commit
83f686a821
|
@ -2,6 +2,9 @@
|
|||
|
||||
- Add support for building Reason projects (Rudi Grinberg, #58)
|
||||
|
||||
- Hint for mistyped targets. Only suggest correction on the basename
|
||||
for now, otherwise it's slow when the workspace is big
|
||||
|
||||
* 1.0+beta8 (17/04/2017)
|
||||
|
||||
- Added =${lib-available:<library-name>}= which expands to =true= or
|
||||
|
|
28
bin/main.ml
28
bin/main.ml
|
@ -287,6 +287,31 @@ type target =
|
|||
| File of Path.t
|
||||
| Alias of Path.t * Alias.t
|
||||
|
||||
let target_hint (setup : Main.setup) path =
|
||||
assert (Path.is_local path);
|
||||
let sub_dir = Path.parent path in
|
||||
let candidates = Build_system.all_targets setup.build_system in
|
||||
let candidates =
|
||||
if Path.is_in_build_dir path then
|
||||
candidates
|
||||
else
|
||||
List.map candidates ~f:(fun path ->
|
||||
match Path.extract_build_context path with
|
||||
| None -> path
|
||||
| Some (_, path) -> path)
|
||||
in
|
||||
let candidates =
|
||||
(* Only suggest hints for the basename, otherwise it's slow when there are lots of
|
||||
files *)
|
||||
List.filter_map candidates ~f:(fun path ->
|
||||
if Path.parent path = sub_dir then
|
||||
Some (Path.to_string path)
|
||||
else
|
||||
None)
|
||||
in
|
||||
let candidates = String_set.of_list candidates |> String_set.elements in
|
||||
hint (Path.to_string path) candidates
|
||||
|
||||
let resolve_targets ~log common (setup : Main.setup) user_targets =
|
||||
match user_targets with
|
||||
| [] -> []
|
||||
|
@ -305,7 +330,8 @@ let resolve_targets ~log common (setup : Main.setup) user_targets =
|
|||
else
|
||||
let path = Path.relative Path.root (prefix_target common s) in
|
||||
let can't_build path =
|
||||
die "Don't know how to build %s" (Path.to_string path)
|
||||
die "Don't know how to build %s%s" (Path.to_string path)
|
||||
(target_hint setup path)
|
||||
in
|
||||
if not (Path.is_local path) then
|
||||
[File path]
|
||||
|
|
|
@ -64,6 +64,9 @@ type t =
|
|||
; mutable local_mkdirs : Path.Local.Set.t
|
||||
}
|
||||
|
||||
|
||||
let all_targets t = Hashtbl.fold t.files ~init:[] ~f:(fun ~key ~data:_ acc -> key :: acc)
|
||||
|
||||
let timestamp t fn =
|
||||
match Hashtbl.find t.timestamps fn with
|
||||
| Some _ as x -> x
|
||||
|
|
|
@ -33,3 +33,6 @@ val all_lib_deps : t -> Path.t list -> Build.lib_deps Path.Map.t
|
|||
(** Return all the library dependencies required to build these targets, by context
|
||||
name *)
|
||||
val all_lib_deps_by_context : t -> Path.t list -> Build.lib_deps String_map.t
|
||||
|
||||
(** List of all buildable targets *)
|
||||
val all_targets : t -> Path.t list
|
||||
|
|
Loading…
Reference in New Issue