Add a workaround for broken META file for builtin packages

Fixes #563
This commit is contained in:
Jeremie Dimino 2018-03-03 10:48:55 +00:00
parent cf2f6c03ba
commit d1feb062b6
2 changed files with 27 additions and 6 deletions

View File

@ -3,6 +3,10 @@ next
- Ignore errors during the generation of the .merlin (#569, fixes #568 and #51)
- Add a workaround for when a library normally installed by the
compiler is not installed but still has a META file (#574, fixes
#563)
1.0+beta18 (25/02/2018)
-----------------------

View File

@ -189,15 +189,10 @@ let parse_package t ~meta_file ~name ~parent_dir ~vars =
Path.relative t.stdlib_dir
(String.sub pkg_dir ~pos:1 ~len:(String.length pkg_dir - 1))
else if Filename.is_relative pkg_dir then
Path.relative parent_dir pkg_dir
Path.relative parent_dir pkg_dir
else
Path.absolute pkg_dir
in
let exists_if = Vars.get_words vars "exists_if" Ps.empty in
let exists =
List.for_all exists_if ~f:(fun fn ->
Path.exists (Path.relative dir fn))
in
let pkg =
{ Package.
meta_file
@ -206,6 +201,28 @@ let parse_package t ~meta_file ~name ~parent_dir ~vars =
; vars
}
in
let exists_if = Vars.get_words vars "exists_if" Ps.empty in
let exists =
match exists_if with
| _ :: _ ->
List.for_all exists_if ~f:(fun fn ->
Path.exists (Path.relative dir fn))
| [] ->
if not (String_map.mem t.builtins (root_package_name name)) then
true
else
(* The META files for installed packages are sometimes broken,
i.e. META files for libraries that were not installed by
the compiler are still present:
https://github.com/ocaml/dune/issues/563
To workaround this problem, for builtin packages we check
that at least one of the archive is present. *)
match Package.archives pkg with
| { byte = []; native = [] } -> true
| { byte; native } -> List.exists (byte @ native) ~f:Path.exists
in
let res =
if exists then
Ok pkg