From 9498cb70131ec561f01f526fbdff61a824560c8c Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 26 Apr 2017 15:10:59 +0100 Subject: [PATCH] Improve the error message for the last commit --- src/main.ml | 2 +- src/path.ml | 5 +++++ src/path.mli | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.ml b/src/main.ml index 67b23a73..8199e83a 100644 --- a/src/main.ml +++ b/src/main.ml @@ -111,7 +111,7 @@ let report_error ?(map_fname=fun x->x) ppf exn ~backtrace = - external library %S is required in %s\n\ This cannot work.\n" package - (Path.to_string defined_locally_in) + (Utils.jbuild_name_in ~dir:(Path.drop_build_context defined_locally_in)) required_by required_by (Utils.jbuild_name_in ~dir:required_locally_in) diff --git a/src/path.ml b/src/path.ml index dc574b0b..12107d7a 100644 --- a/src/path.ml +++ b/src/path.ml @@ -346,6 +346,11 @@ let extract_build_context_dir t = else None +let drop_build_context t = + match extract_build_context t with + | None -> t + | Some (_, t) -> t + let exists t = Sys.file_exists (to_string t) let readdir t = Sys.readdir (to_string t) |> Array.to_list let is_directory t = Sys.is_directory (to_string t) diff --git a/src/path.mli b/src/path.mli index d0c71cc2..f16b182e 100644 --- a/src/path.mli +++ b/src/path.mli @@ -83,6 +83,9 @@ val extract_build_context : t -> (string * t) option *) val extract_build_context_dir : t -> (t * t) option +(** Drop the "_build/blah" prefix *) +val drop_build_context : t -> t + val is_in_build_dir : t -> bool val insert_after_build_dir_exn : t -> t -> t