Skip to content

Commit

Permalink
Variants - simplified (ocaml#1859)
Browse files Browse the repository at this point in the history
The new algorithm takes place in closure computation. It builds a map
from virtual libraries to implementations, and resolves default
implementation selection. New tests have been added.

Signed-off-by: Lucas Pluvinage <[email protected]>
  • Loading branch information
TheLortex committed Mar 4, 2019
1 parent 8655417 commit 8c78099
Show file tree
Hide file tree
Showing 51 changed files with 371 additions and 134 deletions.
5 changes: 2 additions & 3 deletions src/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ module Library = struct
; virtual_modules : Ordered_set_lang.t option
; implements : (Loc.t * Lib_name.t) option
; variant : Variant.t option
; default_implementation : Lib_name.t option
; default_implementation : (Loc.t * Lib_name.t) option
; private_modules : Ordered_set_lang.t option
; stdlib : Stdlib.t option
}
Expand Down Expand Up @@ -940,8 +940,7 @@ module Library = struct
match implements, variant with
| None, Some (loc, _) -> of_sexp_error loc "Only implementations can specify a variant."
| _ -> ();
let default_implementation = Option.map default_implementation ~f:(fun (_, v) -> v)
and variant = Option.map variant ~f:(fun (_, v) -> v) in
let variant = Option.map variant ~f:(fun (_, v) -> v) in
let self_build_stubs_archive =
let loc, self_build_stubs_archive = self_build_stubs_archive in
let err =
Expand Down
2 changes: 1 addition & 1 deletion src/dune_file.mli
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ module Library : sig
; virtual_modules : Ordered_set_lang.t option
; implements : (Loc.t * Lib_name.t) option
; variant : Variant.t option
; default_implementation : Lib_name.t option
; default_implementation : (Loc.t * Lib_name.t) option
; private_modules : Ordered_set_lang.t option
; stdlib : Stdlib.t option
}
Expand Down
6 changes: 3 additions & 3 deletions src/dune_package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Lib = struct
; virtual_ : bool
; implements : (Loc.t * Lib_name.t) option
; variant : Variant.t option
; default_implementation : Lib_name.t option
; default_implementation : (Loc.t * Lib_name.t) option
; modules : Lib_modules.t option
; main_module_name : Module.Name.t option
; requires : (Loc.t * Lib_name.t) list
Expand Down Expand Up @@ -99,7 +99,7 @@ module Lib = struct
; libs "ppx_runtime_deps" ppx_runtime_deps
; field_o "implements" (no_loc Lib_name.encode) implements
; field_o "variant" Variant.encode variant
; field_o "default_implementation" Lib_name.encode default_implementation
; field_o "default_implementation" (no_loc Lib_name.encode) default_implementation
; field_o "main_module_name" Module.Name.encode main_module_name
; field_l "modes" sexp (Mode.Dict.Set.encode modes)
; field_l "modules" sexp
Expand All @@ -123,7 +123,7 @@ module Lib = struct
field_o "main_module_name" Module.Name.decode >>= fun main_module_name ->
field_o "implements" (located Lib_name.decode) >>= fun implements ->
field_o "variant" Variant.decode >>= fun variant ->
field_o "default_implementation" Lib_name.decode >>= fun default_implementation ->
field_o "default_implementation" (located Lib_name.decode) >>= fun default_implementation ->
field "name" Lib_name.decode >>= fun name ->
let dir = Path.append_local base (dir_of_name name) in
let%map synopsis = field_o "synopsis" string
Expand Down
4 changes: 2 additions & 2 deletions src/dune_package.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Lib : sig
val jsoo_runtime : _ t -> Path.t list
val implements : _ t -> (Loc.t * Lib_name.t) option
val variant : _ t -> Variant.t option
val default_implementation : _ t -> Lib_name.t option
val default_implementation : _ t -> (Loc.t * Lib_name.t) option

val dir_of_name : Lib_name.t -> Path.Local.t

Expand All @@ -49,7 +49,7 @@ module Lib : sig
-> ppx_runtime_deps:(Loc.t * Lib_name.t) list
-> implements:(Loc.t * Lib_name.t) option
-> variant: (Variant.t) option
-> default_implementation: (Lib_name.t) option
-> default_implementation: (Loc.t * Lib_name.t) option
-> virtual_:bool
-> modules:Lib_modules.t option
-> modes:Mode.Dict.Set.t
Expand Down
Loading

0 comments on commit 8c78099

Please sign in to comment.