Add support for experimental extensions
These extension provide the minimum version by default Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
f7b31f121b
commit
bc69c43433
|
@ -861,7 +861,8 @@ module Library = struct
|
|||
~desc:"the experimental variants feature"
|
||||
[ (0, 1) ]
|
||||
in
|
||||
Dune_project.Extension.register syntax (Dsexp.Of_sexp.return []);
|
||||
Dune_project.Extension.register ~experimental:true
|
||||
syntax (Dsexp.Of_sexp.return []);
|
||||
syntax
|
||||
end
|
||||
|
||||
|
|
|
@ -202,8 +202,9 @@ let append_to_project_file t str =
|
|||
|
||||
module Extension = struct
|
||||
type t =
|
||||
{ syntax : Syntax.t
|
||||
; stanzas : Stanza.Parser.t list Dsexp.Of_sexp.t
|
||||
{ syntax : Syntax.t
|
||||
; stanzas : Stanza.Parser.t list Dsexp.Of_sexp.t
|
||||
; experimental : bool
|
||||
}
|
||||
|
||||
type instance =
|
||||
|
@ -215,12 +216,12 @@ module Extension = struct
|
|||
|
||||
let extensions = Hashtbl.create 32
|
||||
|
||||
let register syntax stanzas =
|
||||
let register ?(experimental=false) syntax stanzas =
|
||||
let name = Syntax.name syntax in
|
||||
if Hashtbl.mem extensions name then
|
||||
Exn.code_error "Dune_project.Extension.register: already registered"
|
||||
[ "name", Sexp.To_sexp.string name ];
|
||||
Hashtbl.add extensions name { syntax; stanzas }
|
||||
Hashtbl.add extensions name { syntax; stanzas ; experimental }
|
||||
|
||||
let instantiate ~loc ~parse_args (name_loc, name) (ver_loc, ver) =
|
||||
match Hashtbl.find extensions name with
|
||||
|
@ -241,7 +242,12 @@ module Extension = struct
|
|||
let automatic ~project_file ~f =
|
||||
Hashtbl.foldi extensions ~init:[] ~f:(fun name ext acc ->
|
||||
if f name then
|
||||
let version = Syntax.greatest_supported_version ext.syntax in
|
||||
let version =
|
||||
if ext.experimental then
|
||||
(0, 0)
|
||||
else
|
||||
Syntax.greatest_supported_version ext.syntax
|
||||
in
|
||||
let parse_args p =
|
||||
let open Dsexp.Of_sexp in
|
||||
let dune_project_edited = ref false in
|
||||
|
|
|
@ -63,7 +63,11 @@ module Extension : sig
|
|||
|
||||
in their [dune-project] file. [parser] is used to describe
|
||||
what [<args>] might be. *)
|
||||
val register : Syntax.t -> Stanza.Parser.t list Dsexp.Of_sexp.t -> unit
|
||||
val register
|
||||
: ?experimental:bool
|
||||
-> Syntax.t
|
||||
-> Stanza.Parser.t list Dsexp.Of_sexp.t
|
||||
-> unit
|
||||
end
|
||||
|
||||
(** Load a project description from the following directory. [files]
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
Variant feature is auto enabled when virtual_modules is used
|
||||
|
||||
$ dune build --root variants-without-using
|
||||
Entering directory 'variants-without-using'
|
||||
File "dune", line 3, characters 1-25:
|
||||
3 | (virtual_modules foobar))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: 'virtual_modules' is only available since version 0.1 of the experimental variants feature
|
||||
[1]
|
||||
|
||||
$ dune build --root variants-using
|
||||
Entering directory 'variants-using'
|
||||
|
|
Loading…
Reference in New Issue