This commit is contained in:
Jeremie Dimino 2018-02-21 10:56:24 +00:00 committed by Jérémie Dimino
parent 4993c6b89a
commit 41b5017eb2
6 changed files with 44 additions and 11 deletions

View File

@ -1,3 +1,8 @@
next
----
- Fix invalid warning about non-existent direcotry (#536, fixes #534)
1.0+beta18 (21/02/2018)
-----------------------

View File

@ -26,7 +26,32 @@ module Static_deps = struct
}
end
let static_deps t ~all_targets =
type file_kind = Reg | Dir
let inspect_path file_tree path =
match Path.drop_build_context path with
| None ->
if not (Path.exists path) then
None
else if Path.is_directory path then
Some Dir
else
Some Reg
| Some path ->
match File_tree.find_dir file_tree path with
| Some _ ->
Some Dir
| None ->
if Path.is_root path then
Some Dir
else if File_tree.file_exists file_tree
(Path.parent path)
(Path.basename path) then
Some Reg
else
None
let static_deps t ~all_targets ~file_tree =
let rec loop : type a b. (a, b) t -> Static_deps.t -> Static_deps.t = fun t acc ->
match t with
| Arr _ -> acc
@ -49,13 +74,16 @@ let static_deps t ~all_targets =
Re.execp re (Path.basename path))
in
if Pset.is_empty result then begin
if not (Path.exists dir) then
match inspect_path file_tree dir with
| None ->
Loc.warn loc "Directory %s doesn't exist."
(Path.to_string_maybe_quoted dir)
else if not (Path.is_directory dir) then
(Path.to_string_maybe_quoted
(Path.drop_optional_build_context dir))
| Some Reg ->
Loc.warn loc "%s is not a directory."
(Path.to_string_maybe_quoted dir)
else
(Path.to_string_maybe_quoted
(Path.drop_optional_build_context dir))
| Some Dir ->
(* diml: we should probably warn in this case as well *)
()
end;

View File

@ -43,6 +43,7 @@ end
val static_deps
: (_, _) Build.t
-> all_targets:(dir:Path.t -> Path.Set.t)
-> file_tree:File_tree.t
-> Static_deps.t
val lib_deps

View File

@ -646,6 +646,7 @@ let rec compile_rule t ?(copy_source=false) pre_rule =
rule_deps
; action_deps = static_deps
} = Build_interpret.static_deps build ~all_targets:(targets_of t)
~file_tree:t.file_tree
in
let eval_rule () =
@ -1148,6 +1149,7 @@ let eval_request t ~request ~process_target =
rule_deps
; action_deps = static_deps
} = Build_interpret.static_deps request ~all_targets:(targets_of t)
~file_tree:t.file_tree
in
let process_targets ts =
@ -1205,6 +1207,7 @@ let static_deps_of_request t request =
rule_deps
; action_deps
} = Build_interpret.static_deps request ~all_targets:(targets_of t)
~file_tree:t.file_tree
in
Pset.elements (Pset.union rule_deps action_deps)

View File

@ -1,8 +1,4 @@
$ $JBUILDER exec ./main.exe --root . -j1 --display short
File "jbuild", line 1, characters 0-124:
Warning: Directory _build/default doesn't exist.
File "jbuild", line 1, characters 0-89:
Warning: Directory _build/default doesn't exist.
echo main.ml
ocamldep main.ml.d
ocamlc .main.eobjs/main.{cmi,cmo,cmt}

View File

@ -1,6 +1,6 @@
$ $JBUILDER runtest -j1 --display short --root .
File "jbuild", line 54, characters 10-209:
Warning: Directory _build/default/dir-that-doesnt-exist doesn't exist.
Warning: Directory dir-that-doesnt-exist doesn't exist.
diff alias runtest
diff alias runtest
diff alias runtest