From 34a895129276ab5ad71faebd7e818d3da27c6a81 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 15 Mar 2017 11:49:31 +0000 Subject: [PATCH] Improve dependency path printing --- src/build_system.ml | 9 +-------- src/main.ml | 2 +- src/utils.ml | 7 +++++++ src/utils.mli | 3 +++ test/jbuild | 3 ++- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/build_system.ml b/src/build_system.ml index 1c04b15e..825dd4b7 100644 --- a/src/build_system.ml +++ b/src/build_system.ml @@ -142,18 +142,11 @@ module Build_error = struct raise (E { backtrace; dep_path; exn }) end -let describe_target fn = - match Path.extract_build_context fn with - | Some (".aliases", dir) -> - sprintf "alias %s" (Path.to_string dir) - | _ -> - Path.to_string fn - let wait_for_file t fn ~targeting = match Hashtbl.find t.files fn with | None -> if Path.is_in_build_dir fn then - die "no rule found for %s" (describe_target fn) + die "no rule found for %s" (Utils.describe_target fn) else if Path.exists fn then return () else diff --git a/src/main.ml b/src/main.ml index c9440e92..eb600f91 100644 --- a/src/main.ml +++ b/src/main.ml @@ -124,7 +124,7 @@ let report_error ?map_fname ppf exn = if !Clflags.debug_dep_path then Format.fprintf ppf "Dependency path:\n %s\n" (String.concat ~sep:"\n--> " - (List.map (E.dependency_path err) ~f:Path.to_string)) + (List.map (E.dependency_path err) ~f:Utils.describe_target)) | exn -> let backtrace = Printexc.get_raw_backtrace () in report_error ?map_fname ppf exn ~backtrace diff --git a/src/utils.ml b/src/utils.ml index d97c00c0..6935486f 100644 --- a/src/utils.ml +++ b/src/utils.ml @@ -66,3 +66,10 @@ let jbuild_name_in ~dir = sprintf "%s (context %s)" (Path.to_string (Path.relative dir "jbuild")) ctx_name + +let describe_target fn = + match Path.extract_build_context fn with + | Some (".aliases", dir) -> + sprintf "alias %s" (Path.to_string dir) + | _ -> + Path.to_string fn diff --git a/src/utils.mli b/src/utils.mli index 5932f272..6a1980e6 100644 --- a/src/utils.mli +++ b/src/utils.mli @@ -11,3 +11,6 @@ val signal_name : int -> string (** Return the path to the jbuild file in this directory as a string. *) val jbuild_name_in : dir:Path.t -> string + +(** Nice description of a target *) +val describe_target : Path.t -> string diff --git a/test/jbuild b/test/jbuild index 02341450..7e49ed67 100644 --- a/test/jbuild +++ b/test/jbuild @@ -23,4 +23,5 @@ (deps ((files_recursively_in workspaces/github24))) (action (chdir workspaces/github24 - (run ${exe:run.exe} ${bin:jbuilder} build @install --root .))))) + (run ${exe:run.exe} ${bin:jbuilder} + build @install --root . --debug-dependency-path)))))