Rename Alias.of_path to Alias.of_user_written_path
And add a loc argument for correct error messages
This commit is contained in:
parent
76c1a32da4
commit
8eba040b92
|
@ -238,9 +238,10 @@ module Alias0 = struct
|
||||||
|
|
||||||
let suffix = "-" ^ String.make 32 '0'
|
let suffix = "-" ^ String.make 32 '0'
|
||||||
|
|
||||||
let of_path path =
|
let of_user_written_path ~loc path =
|
||||||
if not (Path.is_in_build_dir path) then
|
if not (Path.is_in_build_dir path) then
|
||||||
die "Invalid alias!\nTried to reference alias %S"
|
Loc.fail loc "Invalid alias!\n\
|
||||||
|
Tried to reference path outside build dir: %S"
|
||||||
(Path.to_string_maybe_quoted path);
|
(Path.to_string_maybe_quoted path);
|
||||||
make ~dir:(Path.parent path) (Path.basename path)
|
make ~dir:(Path.parent path) (Path.basename path)
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ module Alias : sig
|
||||||
|
|
||||||
val make : string -> dir:Path.t -> t
|
val make : string -> dir:Path.t -> t
|
||||||
|
|
||||||
val of_path : Path.t -> t
|
val of_user_written_path : loc:Loc.t -> Path.t -> t
|
||||||
|
|
||||||
(** The following always holds:
|
(** The following always holds:
|
||||||
|
|
||||||
|
|
|
@ -457,7 +457,9 @@ module Deps = struct
|
||||||
open Dep_conf
|
open Dep_conf
|
||||||
|
|
||||||
let make_alias t ~scope ~dir s =
|
let make_alias t ~scope ~dir s =
|
||||||
Alias.of_path (Path.relative dir (expand_vars t ~scope ~dir s))
|
let loc = String_with_vars.loc s in
|
||||||
|
Alias.of_user_written_path ~loc
|
||||||
|
(Path.relative ~error_loc:loc dir (expand_vars t ~scope ~dir s))
|
||||||
|
|
||||||
let dep t ~scope ~dir = function
|
let dep t ~scope ~dir = function
|
||||||
| File s ->
|
| File s ->
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
$ dune runtest --root absolute-path 2>&1 | grep -v Entering
|
$ dune runtest --root absolute-path 2>&1 | grep -v Entering
|
||||||
Invalid alias!
|
File "jbuild", line 3, characters 16-24:
|
||||||
Tried to reference alias "/foo/bar"
|
Error: Invalid alias!
|
||||||
|
Tried to reference path outside build dir: "/foo/bar"
|
||||||
$ dune runtest --root outside-workspace 2>&1 | grep -v Entering
|
$ dune runtest --root outside-workspace 2>&1 | grep -v Entering
|
||||||
Path outside the workspace: ./../../../foobar from _build/default
|
File "jbuild", line 4, characters 16-39:
|
||||||
|
Error: path outside the workspace: ./../../../foobar from _build/default
|
||||||
|
|
Loading…
Reference in New Issue