From 41b5017eb28f06083ee425a958a04d6f6efd6dcb Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 21 Feb 2018 10:56:24 +0000 Subject: [PATCH] Fix #534 --- CHANGES.md | 5 +++ src/build_interpret.ml | 40 ++++++++++++++++--- src/build_interpret.mli | 1 + src/build_system.ml | 3 ++ .../blackbox-tests/test-cases/github534/run.t | 4 -- test/blackbox-tests/test-cases/misc/run.t | 2 +- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f1f242a3..2864ad36 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +next +---- + +- Fix invalid warning about non-existent direcotry (#536, fixes #534) + 1.0+beta18 (21/02/2018) ----------------------- diff --git a/src/build_interpret.ml b/src/build_interpret.ml index 82c9f663..185552a3 100644 --- a/src/build_interpret.ml +++ b/src/build_interpret.ml @@ -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; diff --git a/src/build_interpret.mli b/src/build_interpret.mli index e8c439fe..e96b1794 100644 --- a/src/build_interpret.mli +++ b/src/build_interpret.mli @@ -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 diff --git a/src/build_system.ml b/src/build_system.ml index aee5299d..a3f1e1e4 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -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) diff --git a/test/blackbox-tests/test-cases/github534/run.t b/test/blackbox-tests/test-cases/github534/run.t index fe271b22..2629210f 100644 --- a/test/blackbox-tests/test-cases/github534/run.t +++ b/test/blackbox-tests/test-cases/github534/run.t @@ -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} diff --git a/test/blackbox-tests/test-cases/misc/run.t b/test/blackbox-tests/test-cases/misc/run.t index 092006e0..192b0d94 100644 --- a/test/blackbox-tests/test-cases/misc/run.t +++ b/test/blackbox-tests/test-cases/misc/run.t @@ -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