Add fields for variants (#1148)
Add variants fields but guard them behind an extension
This commit is contained in:
parent
4518c79f42
commit
265adc8eae
|
@ -848,6 +848,17 @@ module Library = struct
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module Variants = struct
|
||||||
|
let syntax =
|
||||||
|
let syntax =
|
||||||
|
Syntax.create ~name:"in_development_do_not_use_variants"
|
||||||
|
~desc:"the experimental variants feature"
|
||||||
|
[ (0, 0) ]
|
||||||
|
in
|
||||||
|
Dune_project.Extension.register syntax (Dsexp.Of_sexp.return []);
|
||||||
|
syntax
|
||||||
|
end
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{ name : Lib_name.Local.t
|
{ name : Lib_name.Local.t
|
||||||
; public : Public_lib.t option
|
; public : Public_lib.t option
|
||||||
|
@ -872,6 +883,8 @@ module Library = struct
|
||||||
; sub_systems : Sub_system_info.t Sub_system_name.Map.t
|
; sub_systems : Sub_system_info.t Sub_system_name.Map.t
|
||||||
; no_keep_locs : bool
|
; no_keep_locs : bool
|
||||||
; dune_version : Syntax.Version.t
|
; dune_version : Syntax.Version.t
|
||||||
|
; virtual_modules : Ordered_set_lang.t option
|
||||||
|
; implements : (Loc.t * string) option
|
||||||
}
|
}
|
||||||
|
|
||||||
let dparse =
|
let dparse =
|
||||||
|
@ -906,6 +919,14 @@ module Library = struct
|
||||||
Sub_system_info.record_parser ()
|
Sub_system_info.record_parser ()
|
||||||
and project = Dune_project.get_exn ()
|
and project = Dune_project.get_exn ()
|
||||||
and dune_version = Syntax.get_exn Stanza.syntax
|
and dune_version = Syntax.get_exn Stanza.syntax
|
||||||
|
and virtual_modules =
|
||||||
|
field_o "virtual_modules" (
|
||||||
|
Syntax.since Variants.syntax (0, 1)
|
||||||
|
>>= fun () -> Ordered_set_lang.dparse)
|
||||||
|
and implements =
|
||||||
|
field_o "implements" (
|
||||||
|
Syntax.since Variants.syntax (0, 1)
|
||||||
|
>>= fun () -> (located string))
|
||||||
in
|
in
|
||||||
let name =
|
let name =
|
||||||
let open Syntax.Version.Infix in
|
let open Syntax.Version.Infix in
|
||||||
|
@ -934,6 +955,12 @@ module Library = struct
|
||||||
"name field is missing"
|
"name field is missing"
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
|
Option.both virtual_modules implements
|
||||||
|
|> Option.iter ~f:(fun (virtual_modules, (_, impl)) ->
|
||||||
|
of_sexp_errorf
|
||||||
|
(Ordered_set_lang.loc virtual_modules
|
||||||
|
|> Option.value_exn)
|
||||||
|
"A library cannot be both virtual and implement %s" impl);
|
||||||
{ name
|
{ name
|
||||||
; public
|
; public
|
||||||
; synopsis
|
; synopsis
|
||||||
|
@ -957,6 +984,8 @@ module Library = struct
|
||||||
; sub_systems
|
; sub_systems
|
||||||
; no_keep_locs
|
; no_keep_locs
|
||||||
; dune_version
|
; dune_version
|
||||||
|
; virtual_modules
|
||||||
|
; implements
|
||||||
})
|
})
|
||||||
|
|
||||||
let has_stubs t =
|
let has_stubs t =
|
||||||
|
|
|
@ -240,6 +240,8 @@ module Library : sig
|
||||||
; sub_systems : Sub_system_info.t Sub_system_name.Map.t
|
; sub_systems : Sub_system_info.t Sub_system_name.Map.t
|
||||||
; no_keep_locs : bool
|
; no_keep_locs : bool
|
||||||
; dune_version : Syntax.Version.t
|
; dune_version : Syntax.Version.t
|
||||||
|
; virtual_modules : Ordered_set_lang.t option
|
||||||
|
; implements : (Loc.t * string) option
|
||||||
}
|
}
|
||||||
|
|
||||||
val has_stubs : t -> bool
|
val has_stubs : t -> bool
|
||||||
|
|
|
@ -812,6 +812,14 @@
|
||||||
test-cases/utop-default
|
test-cases/utop-default
|
||||||
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
|
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
(name variants)
|
||||||
|
(deps (package dune) (source_tree test-cases/variants))
|
||||||
|
(action
|
||||||
|
(chdir
|
||||||
|
test-cases/variants
|
||||||
|
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name windows-diff)
|
(name windows-diff)
|
||||||
(deps (package dune) (source_tree test-cases/windows-diff))
|
(deps (package dune) (source_tree test-cases/windows-diff))
|
||||||
|
@ -928,6 +936,7 @@
|
||||||
(alias use-meta)
|
(alias use-meta)
|
||||||
(alias utop)
|
(alias utop)
|
||||||
(alias utop-default)
|
(alias utop-default)
|
||||||
|
(alias variants)
|
||||||
(alias windows-diff)
|
(alias windows-diff)
|
||||||
(alias workspaces)))
|
(alias workspaces)))
|
||||||
|
|
||||||
|
@ -1018,6 +1027,7 @@
|
||||||
(alias too-many-parens)
|
(alias too-many-parens)
|
||||||
(alias use-meta)
|
(alias use-meta)
|
||||||
(alias utop-default)
|
(alias utop-default)
|
||||||
|
(alias variants)
|
||||||
(alias windows-diff)
|
(alias windows-diff)
|
||||||
(alias workspaces)))
|
(alias workspaces)))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
Variant feature is auto enabled when virtual_modules is used
|
||||||
|
|
||||||
|
$ dune build --root variants-without-using
|
||||||
|
File "dune", line 3, characters 1-25:
|
||||||
|
(virtual_modules foobar))
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
Error: 'virtual_modules' is only available since version 0.1 of the experimental variants feature
|
||||||
|
[1]
|
||||||
|
|
||||||
|
$ dune build --root variants-using
|
||||||
|
File "dune-project", line 2, characters 42-45:
|
||||||
|
2:
|
||||||
|
Error: Version 0.1 of in_development_do_not_use_variants is not supported.
|
||||||
|
Supported versions:
|
||||||
|
- 0.0
|
||||||
|
[1]
|
|
@ -0,0 +1,3 @@
|
||||||
|
(library
|
||||||
|
(public_name foo)
|
||||||
|
(virtual_modules bar))
|
|
@ -0,0 +1,3 @@
|
||||||
|
(lang dune 1.1)
|
||||||
|
|
||||||
|
(using in_development_do_not_use_variants 0.1)
|
|
@ -0,0 +1,3 @@
|
||||||
|
(library
|
||||||
|
(public_name foo)
|
||||||
|
(virtual_modules foobar))
|
|
@ -0,0 +1 @@
|
||||||
|
(lang dune 1.1)
|
Loading…
Reference in New Issue