Use the absolute path when evaluating a jbuild file in OCaml syntax.
This commit is contained in:
Jeremie Dimino 2017-09-22 11:15:15 +01:00
parent c636331148
commit 3fb1915033
4 changed files with 14 additions and 5 deletions

View File

@ -124,7 +124,7 @@ end
[ [ "-I"; "+compiler-libs" ]
; includes
; List.map cmas ~f:(Path.reach ~from:dir)
; [ Path.reach ~from:dir wrapper ]
; [ Path.to_absolute_filename wrapper ]
]
in
(* CR-someday jdimino: if we want to allow plugins to use findlib:

View File

@ -12,15 +12,12 @@ type t =
; source_dirs: Path.Set.t
}
(* This must be forced after we change the cwd to the workspace root *)
let root_absolute_name = lazy (Sys.getcwd ())
let ppx_flags sctx ~dir ~src_dir:_ { preprocess; libname; _ } =
match preprocess with
| Pps { pps; flags } ->
let exe = SC.PP.get_ppx_driver sctx pps ~dir ~dep_kind:Optional in
let command =
List.map (Filename.concat (Lazy.force root_absolute_name) (Path.to_string exe)
List.map (Path.to_absolute_filename exe
:: "--as-ppx"
:: SC.PP.cookie_library_name libname
@ flags)

View File

@ -272,6 +272,14 @@ let absolute fn =
else
fn
let to_absolute_filename t =
if is_local t then begin
let root = !Clflags.workspace_root in
assert (not (Filename.is_relative root));
Filename.concat root (to_string t)
end else
t
let reach t ~from =
match is_local t, is_local from with
| false, _ -> t

View File

@ -61,6 +61,10 @@ val relative : ?error_loc:Loc.t -> t -> string -> t
relative to the initial directory jbuilder was launched in. *)
val absolute : string -> t
(** Convert a path to an absolute filename. Must be called after the
workspace root has been set. *)
val to_absolute_filename : t -> string
val reach : t -> from:t -> string
val reach_for_running : t -> from:t -> string