Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate no_keep_locs #1822

Merged
2 commits merged into from Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ unreleased
- Add `DUNE_PROFILE` environment variable to easily set the profile. (#1806,
@rgrinberg)

- Deprecate the undocumented `(no_keep_locs)` field. It was only
necessary until virtual libraries were supported (#1822, fix #1816,
@diml)

1.6.2 (05/12/2018)
------------------

Expand Down
5 changes: 3 additions & 2 deletions doc/dune-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ to use the :ref:`include_subdirs` stanza.
- ``(allow_overlapping_dependencies)`` allows external dependencies to
overlap with libraries that are present in the workspace

- ``(no_keep_locs)`` undocumented, it is a necessary hack until this
is implemented: https://github.com/ocaml/dune/issues/921
- ``(no_keep_locs)`` does nothing. It used to be a necessary hack when
we were waiting for proper support for virtual libraries. Do not use
in new code, it will be deleted in dune 2.0

Note that when binding C libraries, dune doesn't provide special support for
tools such as ``pkg-config``, however it integrates easily with configurator_ by
Expand Down
1 change: 1 addition & 0 deletions src/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ module Library = struct
located (field "self_build_stubs_archive" (option string) ~default:None)
and no_dynlink = field_b "no_dynlink"
and no_keep_locs = field_b "no_keep_locs"
~check:(Syntax.deprecated_in Stanza.syntax (1, 7))
and sub_systems =
return () >>= fun () ->
Sub_system_info.record_parser ()
Expand Down
19 changes: 19 additions & 0 deletions src/syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ module Error = struct
| Some s -> ".\n" ^ s)
end

module Warning = struct
let deprecated_in loc t ?repl ver ~what =
Errors.warn loc "%s was deprecated in version %s of %s%s"
what (Version.to_string ver) t.desc
(match repl with
| None -> ""
| Some s -> ".\n" ^ s)
end


let create ~name ~desc supported_versions =
{ name
Expand Down Expand Up @@ -167,6 +176,16 @@ let deleted_in t ver =
Error.deleted_in loc t ver ~what
end

let deprecated_in t ver =
let open Version.Infix in
get_exn t >>= fun current_ver ->
if current_ver < ver then
return ()
else begin
desc () >>| fun (loc, what) ->
Warning.deprecated_in loc t ver ~what;
end

let renamed_in t ver ~to_ =
let open Version.Infix in
get_exn t >>= fun current_ver ->
Expand Down
14 changes: 14 additions & 0 deletions src/syntax.mli
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ module Error : sig
-> _
end

module Warning : sig
val deprecated_in
: Loc.t
-> t
-> ?repl:string
-> Version.t
-> what:string
-> unit
end

(** [create ~name ~desc supported_versions] defines a new
syntax. [supported_version] is the list of the last minor version
of each supported major version. [desc] is used to describe what
Expand All @@ -63,6 +73,10 @@ val greatest_supported_version : t -> Version.t
given version *)
val deleted_in : t -> Version.t -> (unit, _) Dune_lang.Decoder.parser

(** Indicate the field/constructor being parsed was deprecated in the
given version *)
val deprecated_in : t -> Version.t -> (unit, _) Dune_lang.Decoder.parser

(** Indicate the field/constructor being parsed was renamed in the
given version *)
val renamed_in : t -> Version.t -> to_:string -> (unit, _) Dune_lang.Decoder.parser
Expand Down

This file was deleted.

15 changes: 15 additions & 0 deletions test/blackbox-tests/test-cases/syntax-versioning/run.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ echo '(lang dune 1.0)' > dune-project

$ echo '(jbuild_version 1)' > dune
$ dune build
File "dune", line 1, characters 0-18:
Expand Down Expand Up @@ -35,3 +37,16 @@
... %{x} ...
[1]
$ rm -f dune

$ echo '(lang dune 1.7)' > dune-project
$ cat > dune <<EOF
> (library
> (name foo)
> (no_keep_locs))
> EOF
$ dune build
File "dune", line 3, characters 1-15:
3 | (no_keep_locs))
^^^^^^^^^^^^^^
Warning: 'no_keep_locs' was deprecated in version 1.7 of the dune language
$ rm -f dune