Change Path.insert_after_build_dir_exn not to hard code _build
Use the build_dir variable rather than the "_build" string and treat the case Path.build_dir argument differently. Previously this would error: Path.insert_after_build_dir_exn Path.build_dir "foo" Now, it will return _build/foo
This commit is contained in:
parent
6ee133b4dd
commit
0f8dcc5848
|
@ -468,12 +468,16 @@ let insert_after_build_dir_exn =
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
fun a b ->
|
fun a b ->
|
||||||
if not (is_local a) || String.contains b '/' then error a b;
|
if not (is_local a) then
|
||||||
match String.lsplit2 a ~on:'/' with
|
|
||||||
| Some ("_build", rest) ->
|
|
||||||
Printf.sprintf "_build/%s/%s" b rest
|
|
||||||
| _ ->
|
|
||||||
error a b
|
error a b
|
||||||
|
else if a = build_dir then
|
||||||
|
relative build_dir b
|
||||||
|
else
|
||||||
|
match String.lsplit2 a ~on:'/' with
|
||||||
|
| Some (build_dir', rest) when build_dir = build_dir' ->
|
||||||
|
Local.append (relative build_dir b) rest
|
||||||
|
| _ ->
|
||||||
|
error a b
|
||||||
|
|
||||||
let rm_rf =
|
let rm_rf =
|
||||||
let rec loop dir =
|
let rec loop dir =
|
||||||
|
|
|
@ -121,9 +121,7 @@ Called from file "toplevel/toploop.ml", line 180, characters 17-56
|
||||||
|
|
||||||
Path.insert_after_build_dir_exn Path.build_dir "foobar"
|
Path.insert_after_build_dir_exn Path.build_dir "foobar"
|
||||||
[%%expect{|
|
[%%expect{|
|
||||||
Exception: Stdune__Exn.Code_error <abstr>.
|
- : Stdune.Path.t = _build/foobar
|
||||||
Raised at file "src/stdune/exn.ml", line 30, characters 37-131
|
|
||||||
Called from file "toplevel/toploop.ml", line 180, characters 17-56
|
|
||||||
|}]
|
|}]
|
||||||
|
|
||||||
Path.insert_after_build_dir_exn (Path.relative Path.build_dir "qux") "foobar"
|
Path.insert_after_build_dir_exn (Path.relative Path.build_dir "qux") "foobar"
|
||||||
|
|
Loading…
Reference in New Issue