Merge pull request #1210 from rgrinberg/wrapped-virtual

Enforce wrapped true for virtual libs/implementations
This commit is contained in:
Rudi Grinberg 2018-09-04 00:49:59 +04:00 committed by GitHub
commit a61a2c8cd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 3 deletions

View File

@ -873,11 +873,15 @@ module Library = struct
string >>| fun x -> Yes_with_transition x
]
let field = field "wrapped" ~default:(Simple true) dparse
let field = field_o "wrapped" (located dparse)
let to_bool = function
| Simple b -> b
| Yes_with_transition _ -> true
let value = function
| None -> Simple true
| Some (_loc, w) -> w
end
type t =
@ -953,7 +957,8 @@ module Library = struct
let open Syntax.Version.Infix in
match name, public with
| Some n, _ ->
Lib_name.Local.validate n ~wrapped:(Wrapped.to_bool wrapped)
let wrapped = Wrapped.to_bool (Wrapped.value wrapped) in
Lib_name.Local.validate n ~wrapped
| None, Some { name = (loc, name) ; _ } ->
if dune_version >= (1, 1) then
match Lib_name.to_local name with
@ -982,6 +987,15 @@ module Library = struct
(Ordered_set_lang.loc virtual_modules
|> Option.value_exn)
"A library cannot be both virtual and implement %s" impl);
begin match virtual_modules, wrapped, implements with
| Some _, Some (loc, Wrapped.Simple false), _ ->
of_sexp_error loc "A virtual library must be wrapped"
| _, Some (loc, _), Some _ ->
of_sexp_error loc
"Wrapped cannot be set for implementations. \
It is inherited from the virtual library."
| _, _, _ -> ()
end;
{ name
; public
; synopsis
@ -997,7 +1011,7 @@ module Library = struct
; c_library_flags
; self_build_stubs_archive
; virtual_deps
; wrapped
; wrapped = Wrapped.value wrapped
; optional
; buildable
; dynlink = Dynlink_supported.of_bool (not no_dynlink)