diff --git a/doc/migration.rst b/doc/migration.rst index a50fd0cb..d85670d6 100644 --- a/doc/migration.rst +++ b/doc/migration.rst @@ -169,7 +169,6 @@ Jbuild Dune ======================== ============ ``${@}`` ``%{targets}`` ``${^}`` ``%{deps}`` -``${<}`` ``%{first-dep}`` ``${path:file}`` ``%{dep:file}`` ``${SCOPE_ROOT}`` ``%{project_root}`` ``${findlib:..}`` ``%{lib:..}`` @@ -186,8 +185,26 @@ Jbuild Dune Removed Variables ----------------- -``${path-no-dep:file}`` has been removed. +``${path-no-dep:file}`` and ``${<}`` have been removed. +A named dependency should be used instead of ``${<}``. For instance +the following jbuild file: + +.. code:: scheme + + (alias + ((name runtest) + (deps (input)) + (action (run ./test.exe %{<})))) + +should be rewritten to the following dune file: + +.. code:: scheme + + (alias + (name runtest) + (deps (:x input)) + (action (run ./test.exe %{x}))) ``# JBUILDER_GEN`` renamed -------------------------- diff --git a/src/jbuild.ml b/src/jbuild.ml index 04fb383c..2be16d07 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -1307,7 +1307,7 @@ module Rule = struct [ S.virt_text __POS__ "-q" ; S.virt_text __POS__ "-o" ; S.virt_var __POS__ "targets" - ; S.virt_var __POS__"first-dep-tmp" + ; S.virt_var __POS__"deps" ]))) ; mode ; locks = [] @@ -1328,7 +1328,7 @@ module Rule = struct Chdir (S.virt_var __POS__ "root", Run (S.virt_text __POS__ "ocamlyacc", - [S.virt_var __POS__ "first-dep-tmp"]))) + [S.virt_var __POS__ "deps"]))) ; mode ; locks = [] ; loc diff --git a/src/pform.ml b/src/pform.ml index 58e1858b..587cff57 100644 --- a/src/pform.ml +++ b/src/pform.ml @@ -36,24 +36,24 @@ end type 'a t = | No_info of 'a | Since of 'a * Syntax.Version.t - | Deleted_in of 'a * Syntax.Version.t + | Deleted_in of 'a * Syntax.Version.t * string option | Renamed_in of Syntax.Version.t * string module Map = struct type nonrec 'a t = 'a t String.Map.t - let values v = No_info (Var.Values v) - let renamed_in ~new_name ~version = Renamed_in (version, new_name) - let deleted_in ~version kind = Deleted_in (kind, version) - let since ~version v = Since (v, version) + let values v = No_info (Var.Values v) + let renamed_in ~new_name ~version = Renamed_in (version, new_name) + let deleted_in ~version ?repl kind = Deleted_in (kind, version, repl) + let since ~version v = Since (v, version) let static_vars = - [ "first-dep", since ~version:(1, 0) Var.First_dep - ; "targets", since ~version:(1, 0) Var.Targets + [ "targets", since ~version:(1, 0) Var.Targets ; "deps", since ~version:(1, 0) Var.Deps ; "project_root", since ~version:(1, 0) Var.Project_root - ; "<", renamed_in ~version:(1, 0) ~new_name:"first-dep" + ; "<", deleted_in Var.Deps ~version:(1, 0) + ~repl:"Use a named dependency instead: (: )" ; "@", renamed_in ~version:(1, 0) ~new_name:"targets" ; "^", renamed_in ~version:(1, 0) ~new_name:"deps" ; "SCOPE_ROOT", renamed_in ~version:(1, 0) ~new_name:"project_root" @@ -167,10 +167,10 @@ module Map = struct expand t ~syntax_version:in_version ~var:(String_with_vars.Var.with_name var ~name:new_name) end - | Deleted_in (v, in_version) -> + | Deleted_in (v, in_version, repl) -> if syntax_version < in_version then Some v else Syntax.Error.deleted_in (String_with_vars.Var.loc var) - Stanza.syntax syntax_version ~what:(what var)) + Stanza.syntax syntax_version ~what:(what var) ?repl) end diff --git a/src/pform.mli b/src/pform.mli index 357a3a16..71ab99ae 100644 --- a/src/pform.mli +++ b/src/pform.mli @@ -28,7 +28,7 @@ end type 'a t = | No_info of 'a | Since of 'a * Syntax.Version.t - | Deleted_in of 'a * Syntax.Version.t + | Deleted_in of 'a * Syntax.Version.t * string option | Renamed_in of Syntax.Version.t * string module Map : sig diff --git a/src/syntax.ml b/src/syntax.ml index 3e778dc2..8ea07e32 100644 --- a/src/syntax.ml +++ b/src/syntax.ml @@ -65,9 +65,12 @@ module Error = struct Loc.fail loc "%s was renamed to '%s' in the %s version of %s" what to_ (Version.to_string ver) t.desc - let deleted_in loc t ver ~what = - Loc.fail loc "%s was deleted in version %s of %s" + let deleted_in loc t ?repl ver ~what = + Loc.fail loc "%s was deleted in version %s of %s%s" what (Version.to_string ver) t.desc + (match repl with + | None -> "" + | Some s -> ".\n" ^ s) end diff --git a/src/syntax.mli b/src/syntax.mli index dd9c8e0b..1baca844 100644 --- a/src/syntax.mli +++ b/src/syntax.mli @@ -25,7 +25,13 @@ module Error : sig val renamed_in : Loc.t -> t -> Version.t -> what:string -> to_:string -> _ - val deleted_in : Loc.t -> t -> Version.t -> what:string -> _ + val deleted_in + : Loc.t + -> t + -> ?repl:string + -> Version.t + -> what:string + -> _ end (** [create ~name ~desc supported_versions] defines a new diff --git a/test/blackbox-tests/test-cases/syntax-versioning/run.t b/test/blackbox-tests/test-cases/syntax-versioning/run.t index 100b0add..40fba033 100644 --- a/test/blackbox-tests/test-cases/syntax-versioning/run.t +++ b/test/blackbox-tests/test-cases/syntax-versioning/run.t @@ -16,3 +16,11 @@ Error: 'link_executables' was deleted in version 1.0 of the dune language [1] $ rm -f dune + + $ echo '(alias (name x) (deps x) (action (run %{<})))' > dune + $ dune build + File "dune", line 1, characters 40-42: + Error: %{<} was deleted in version 1.0 of the dune language. + Use a named dependency instead: (: ) + [1] + $ rm -f dune