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"
|
~desc:"the experimental variants feature"
|
||||||
[ (0, 1) ]
|
[ (0, 1) ]
|
||||||
in
|
in
|
||||||
Dune_project.Extension.register syntax (Dsexp.Of_sexp.return []);
|
Dune_project.Extension.register ~experimental:true
|
||||||
|
syntax (Dsexp.Of_sexp.return []);
|
||||||
syntax
|
syntax
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -202,8 +202,9 @@ let append_to_project_file t str =
|
||||||
|
|
||||||
module Extension = struct
|
module Extension = struct
|
||||||
type t =
|
type t =
|
||||||
{ syntax : Syntax.t
|
{ syntax : Syntax.t
|
||||||
; stanzas : Stanza.Parser.t list Dsexp.Of_sexp.t
|
; stanzas : Stanza.Parser.t list Dsexp.Of_sexp.t
|
||||||
|
; experimental : bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type instance =
|
type instance =
|
||||||
|
@ -215,12 +216,12 @@ module Extension = struct
|
||||||
|
|
||||||
let extensions = Hashtbl.create 32
|
let extensions = Hashtbl.create 32
|
||||||
|
|
||||||
let register syntax stanzas =
|
let register ?(experimental=false) syntax stanzas =
|
||||||
let name = Syntax.name syntax in
|
let name = Syntax.name syntax in
|
||||||
if Hashtbl.mem extensions name then
|
if Hashtbl.mem extensions name then
|
||||||
Exn.code_error "Dune_project.Extension.register: already registered"
|
Exn.code_error "Dune_project.Extension.register: already registered"
|
||||||
[ "name", Sexp.To_sexp.string name ];
|
[ "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) =
|
let instantiate ~loc ~parse_args (name_loc, name) (ver_loc, ver) =
|
||||||
match Hashtbl.find extensions name with
|
match Hashtbl.find extensions name with
|
||||||
|
@ -241,7 +242,12 @@ module Extension = struct
|
||||||
let automatic ~project_file ~f =
|
let automatic ~project_file ~f =
|
||||||
Hashtbl.foldi extensions ~init:[] ~f:(fun name ext acc ->
|
Hashtbl.foldi extensions ~init:[] ~f:(fun name ext acc ->
|
||||||
if f name then
|
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 parse_args p =
|
||||||
let open Dsexp.Of_sexp in
|
let open Dsexp.Of_sexp in
|
||||||
let dune_project_edited = ref false 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
|
in their [dune-project] file. [parser] is used to describe
|
||||||
what [<args>] might be. *)
|
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
|
end
|
||||||
|
|
||||||
(** Load a project description from the following directory. [files]
|
(** Load a project description from the following directory. [files]
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
Variant feature is auto enabled when virtual_modules is used
|
Variant feature is auto enabled when virtual_modules is used
|
||||||
|
|
||||||
$ dune build --root variants-without-using
|
$ 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
|
$ dune build --root variants-using
|
||||||
Entering directory 'variants-using'
|
Entering directory 'variants-using'
|
||||||
|
|
Loading…
Reference in New Issue