Make invalid public name warn when (wrapped false)

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-08-08 11:06:14 +03:00
parent c08cec1f4b
commit 5706e4ee56
2 changed files with 17 additions and 8 deletions

View File

@ -925,12 +925,20 @@ module Library = struct
in
let name =
match name, public with
| Some n, _ -> n
| Some n, _ -> Lib_name.to_string n
| None, Some { name = (loc, name) ; _ } ->
if dune_version >= (1, 1) then
match Lib_name.of_string name with
| Some n -> n
| None ->
match Lib_name.of_string name, wrapped with
| Some n, _ -> Lib_name.to_string n
| None, false ->
Loc.warn loc
"%s.\n\
This is temporary allowed for libraries with (wrapped false).\
\nIt will not be supported in the future. \
Please choose a valid name field."
Lib_name.error_message;
name
| None, true ->
of_sexp_errorf loc
"%s.\n\
Public library names don't have this restriction. \
@ -948,7 +956,7 @@ module Library = struct
"name field is missing"
)
in
{ name = Lib_name.to_string name
{ name
; public
; synopsis
; install_c_headers

View File

@ -33,7 +33,8 @@ it's just a warning
$ dune build --root public-name-invalid-wrapped-false
Info: creating file dune-project with this contents: (lang dune 1.1)
File "dune", line 3, characters 14-21:
Error: invalid library name.
Warning: invalid library name.
Hint: library names must be non-empty and composed only of the following characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
Public library names don't have this restriction. You can either change this public name to be a valid library name or add a "name" field with a valid library name.
[1]
This is temporary allowed for libraries with (wrapped false).
It will not be supported in the future. Please choose a valid name field.
Entering directory 'public-name-invalid-wrapped-false'