Better signature for Artifacts.file_of_lib (#418)
This commit is contained in:
parent
49edf8ed65
commit
314da72d3c
|
@ -100,12 +100,3 @@ let file_of_lib t ~from ~lib ~file =
|
||||||
: Findlib.package);
|
: Findlib.package);
|
||||||
assert false
|
assert false
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_of_lib t ~loc ~from name =
|
|
||||||
let lib, file =
|
|
||||||
match String.lsplit2 name ~on:':' with
|
|
||||||
| None ->
|
|
||||||
Loc.fail loc "invalid ${lib:...} form: %s" name
|
|
||||||
| Some x -> x
|
|
||||||
in
|
|
||||||
(lib, file_of_lib t ~from ~lib ~file)
|
|
||||||
|
|
|
@ -18,14 +18,11 @@ val binary
|
||||||
-> string
|
-> string
|
||||||
-> Action.Prog.t
|
-> Action.Prog.t
|
||||||
|
|
||||||
(** [file_of_lib t ~from name] a named artifact that is looked up in the given library.
|
(** [file_of_lib t ~from ~lib ~file] returns the path to a file in the directory of the
|
||||||
|
given library. *)
|
||||||
[name] is expected to be of the form "<lib>:<file>". Raises immediately if it is not
|
|
||||||
the case. Returns "<lib>" as well as the resolved artifact.
|
|
||||||
*)
|
|
||||||
val file_of_lib
|
val file_of_lib
|
||||||
: t
|
: t
|
||||||
-> loc:Loc.t
|
|
||||||
-> from:Path.t
|
-> from:Path.t
|
||||||
-> string
|
-> lib:string
|
||||||
-> string * (Path.t, fail) result
|
-> file:string
|
||||||
|
-> (Path.t, fail) result
|
||||||
|
|
|
@ -18,11 +18,10 @@ let in_build_dir ~ctx =
|
||||||
List.fold_left ~init ~f:Path.relative
|
List.fold_left ~init ~f:Path.relative
|
||||||
|
|
||||||
let runtime_file ~sctx ~dir fname =
|
let runtime_file ~sctx ~dir fname =
|
||||||
let _lib, file =
|
match
|
||||||
Artifacts.file_of_lib (SC.artifacts sctx) ~loc:Loc.none ~from:dir
|
Artifacts.file_of_lib (SC.artifacts sctx) ~from:dir
|
||||||
(sprintf "js_of_ocaml-compiler:%s" fname)
|
~lib:"js_of_ocaml-compiler" ~file:fname
|
||||||
in
|
with
|
||||||
match file with
|
|
||||||
| Error _ ->
|
| Error _ ->
|
||||||
Arg_spec.Dyn (fun _ ->
|
Arg_spec.Dyn (fun _ ->
|
||||||
Utils.library_not_found ~context:(SC.context sctx).name ~hint:install_jsoo_hint
|
Utils.library_not_found ~context:(SC.context sctx).name ~hint:install_jsoo_hint
|
||||||
|
|
|
@ -534,6 +534,12 @@ module Action = struct
|
||||||
Path.append host.context.build_dir exe
|
Path.append host.context.build_dir exe
|
||||||
| _ -> exe
|
| _ -> exe
|
||||||
|
|
||||||
|
let parse_lib_file ~loc s =
|
||||||
|
match String.lsplit2 s ~on:':' with
|
||||||
|
| None ->
|
||||||
|
Loc.fail loc "invalid ${lib:...} form: %s" s
|
||||||
|
| Some x -> x
|
||||||
|
|
||||||
let expand_step1 sctx ~dir ~dep_kind ~scope ~targets_written_by_user ~map_exe t =
|
let expand_step1 sctx ~dir ~dep_kind ~scope ~targets_written_by_user ~map_exe t =
|
||||||
let acc =
|
let acc =
|
||||||
{ failures = []
|
{ failures = []
|
||||||
|
@ -566,19 +572,23 @@ module Action = struct
|
||||||
(* "findlib" for compatibility with Jane Street packages which are not yet updated
|
(* "findlib" for compatibility with Jane Street packages which are not yet updated
|
||||||
to convert "findlib" to "lib" *)
|
to convert "findlib" to "lib" *)
|
||||||
| Some (("lib"|"findlib"), s) -> begin
|
| Some (("lib"|"findlib"), s) -> begin
|
||||||
let lib_dep, res =
|
let lib_dep, file = parse_lib_file ~loc s in
|
||||||
Artifacts.file_of_lib (artifacts sctx) ~loc ~from:dir s in
|
|
||||||
add_lib_dep acc lib_dep dep_kind;
|
add_lib_dep acc lib_dep dep_kind;
|
||||||
match res with
|
match
|
||||||
|
Artifacts.file_of_lib (artifacts sctx) ~from:dir
|
||||||
|
~lib:lib_dep ~file
|
||||||
|
with
|
||||||
| Ok path -> static_dep_exp acc path
|
| Ok path -> static_dep_exp acc path
|
||||||
| Error fail -> add_fail acc fail
|
| Error fail -> add_fail acc fail
|
||||||
end
|
end
|
||||||
| Some ("libexec" , s) -> begin
|
| Some ("libexec" , s) -> begin
|
||||||
let sctx = host_sctx sctx in
|
let sctx = host_sctx sctx in
|
||||||
let lib_dep, res =
|
let lib_dep, file = parse_lib_file ~loc s in
|
||||||
Artifacts.file_of_lib (artifacts sctx) ~loc ~from:dir s in
|
|
||||||
add_lib_dep acc lib_dep dep_kind;
|
add_lib_dep acc lib_dep dep_kind;
|
||||||
match res with
|
match
|
||||||
|
Artifacts.file_of_lib (artifacts sctx) ~from:dir
|
||||||
|
~lib:lib_dep ~file
|
||||||
|
with
|
||||||
| Error fail -> add_fail acc fail
|
| Error fail -> add_fail acc fail
|
||||||
| Ok path ->
|
| Ok path ->
|
||||||
if not Sys.win32 || Filename.extension s = ".exe" then begin
|
if not Sys.win32 || Filename.extension s = ".exe" then begin
|
||||||
|
|
Loading…
Reference in New Issue