Print "Entering directory '...'" when necessary
When the root of the workspace is not the current directory, print: Entering directory '<absolute path to root>' This way editors such as emacs or vim knows how to interpret filenames reported by the compiler. Fixes #138
This commit is contained in:
parent
b2e7720b41
commit
157e4d6548
|
@ -17,6 +17,15 @@ jbuild-workspace
|
|||
The root of the current workspace is determined by looking up a
|
||||
``jbuild-workspace`` file in the current directory and parent directories.
|
||||
|
||||
``jbuilder`` prints out the root when starting if it is not the
|
||||
current directory:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
$ jbuilder runtest
|
||||
Entering directory '/home/jdimino/code/jbuilder'
|
||||
...
|
||||
|
||||
More precisely, it will choose the outermost ancestor directory containing a
|
||||
``jbuild-workspace`` file as root. For instance if you are in
|
||||
``/home/me/code/myproject/src``, then jbuilder will look for all these files in
|
||||
|
|
|
@ -661,5 +661,7 @@ module Scheduler = struct
|
|||
Lazy.force Ansi_color.setup_env_for_colors;
|
||||
Log.info log ("Workspace root: " ^ !Clflags.workspace_root);
|
||||
let cwd = Sys.getcwd () in
|
||||
if cwd <> initial_cwd then
|
||||
Printf.eprintf "Entering directory '%s'\n%!" cwd;
|
||||
go_rec cwd log t
|
||||
end
|
||||
|
|
|
@ -12,6 +12,8 @@ let () = Printexc.record_backtrace true
|
|||
let sprintf = Printf.sprintf
|
||||
let ksprintf = Printf.ksprintf
|
||||
|
||||
let initial_cwd = Sys.getcwd ()
|
||||
|
||||
(* An error in the code of jbuild, that should be reported upstream *)
|
||||
exception Code_error of string
|
||||
let code_errorf fmt = ksprintf (fun msg -> raise (Code_error msg)) fmt
|
||||
|
|
12
src/path.ml
12
src/path.ml
|
@ -266,13 +266,11 @@ let of_string ?error_loc s =
|
|||
let t sexp = of_string (Sexp.Of_sexp.string sexp) ~error_loc:(Sexp.Ast.loc sexp)
|
||||
let sexp_of_t t = Sexp.Atom (to_string t)
|
||||
|
||||
let absolute =
|
||||
let initial_dir = Sys.getcwd () in
|
||||
fun fn ->
|
||||
if is_local fn then
|
||||
Filename.concat initial_dir fn
|
||||
else
|
||||
fn
|
||||
let absolute fn =
|
||||
if is_local fn then
|
||||
Filename.concat initial_cwd fn
|
||||
else
|
||||
fn
|
||||
|
||||
let reach t ~from =
|
||||
match is_local t, is_local from with
|
||||
|
|
|
@ -57,6 +57,8 @@ val is_local : t -> bool
|
|||
|
||||
val relative : ?error_loc:Loc.t -> t -> string -> t
|
||||
|
||||
(** Create an external path. If the argument is relative, assume it is
|
||||
relative to the initial directory jbuilder was launched in. *)
|
||||
val absolute : string -> t
|
||||
|
||||
val reach : t -> from:t -> string
|
||||
|
|
Loading…
Reference in New Issue