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

Fix #985 #1188

Merged
merged 17 commits into from
Aug 31, 2018
Merged

Fix #985 #1188

merged 17 commits into from
Aug 31, 2018

Conversation

rgrinberg
Copy link
Member

Add a transition mode to wrapped modules. This will add aliases to the unprefixed names with a deprecation message as in #985.

For some reason, I can't see the deprecation message in the test. @diml any idea why?

@rgrinberg rgrinberg requested review from hhugo and a user August 29, 2018 07:50
@rgrinberg rgrinberg requested a review from emillon as a code owner August 29, 2018 07:50
@emillon
Copy link
Collaborator

emillon commented Aug 29, 2018

I'm not sure that it's a good idea to use dates here. Some library authors might want to use a version number, or just a generic "some day".

What do you think about making this a generic deprecation message, like (transition "message")?

@ghost
Copy link

ghost commented Aug 29, 2018

The idea of the date was to remind the developer of the library using the transition mode to get rid of it after the given date. Though maybe that's not really the job of dune to do that. Taking the deprecation message as argument seems good.

@ghost
Copy link

ghost commented Aug 29, 2018

For some reason, I can't see the deprecation message in the test. @diml any idea why?

Ah, that's annoying. Misplaced attributes are silently ignored by the compiler so I don't know if it's supported at all in this position. Need to look in the compiler code to see what we can do.

@rgrinberg
Copy link
Member Author

The [@@@deprecated ...] works

src/dune_file.ml Outdated
| Yes_with_transition of string

let dparse =
if_list
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use sum directly here:

sum ["true", return (Simple true)
...

src/lib_rules.ml Outdated
);
let dep_graphs =
Ocamldep.Dep_graphs.deprecated ~modules ~deprecated in
let cctx = Compilation_context.set_modules cctx deprecated in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a dedicated compilation context here, i.e. with preprocessing, special flags, libraries, etc... Since these modules are under our control, we know exactly how they should be compiled. It should be similar to the one for the alias module

src/module.ml Outdated
intf = None
; impl =
Some (
let impl = Option.value_exn t.impl in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we use (wrapped (transition "")) with (modules_without_implementation x)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I fixed this and added a test case.

@@ -176,25 +177,32 @@ end = struct
{ modules : Module.t Module.Name.Map.t
; alias_module : Module.t option
; main_module_name : Module.Name.t
; deprecated : Module.t Module.Name.Map.t
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure deprecated is the right name. What about unwrapped_compat?

@hhugo
Copy link
Collaborator

hhugo commented Aug 29, 2018

I've tried this PR with https://github.com/ocsigen/js_of_ocaml/tree/transition and got the following error message:

Multiple rules generated for _build/default/lib/js_of_ocaml.cmo.js:
- <internal location>
- <internal location>

note that lib/js_of_ocaml.ml exists and js_of_ocaml is the name of the library.

@rgrinberg
Copy link
Member Author

@hhugo could you try the latest commit?

@hhugo
Copy link
Collaborator

hhugo commented Aug 30, 2018

This doesn't work. I think it fail trying to build cmis for deprecated module.

src/module.mli Outdated

val to_sexp : t Sexp.To_sexp.t

val deprecate : t -> t
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed to wrapped_compat as well

@rgrinberg
Copy link
Member Author

@hhugo I tried your branch and it works now

@rgrinberg
Copy link
Member Author

@diml addressed your comment and added docs/change log entry.

@rgrinberg
Copy link
Member Author

Fixed the tests. I think this is ready.

src/lib_rules.ml Outdated
@@ -377,12 +413,16 @@ module Gen (P : Install_rules.Params) = struct
else
acc)
in
let deprecated_modules = Module.Name.Map.values wrapped_compat in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be consistent, let's use the wrapped_compat terminology here as well. This will make it easier to understand this code in the future

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was just an omission. I fixed this.

src/lib_rules.ml Outdated
@@ -377,12 +413,16 @@ module Gen (P : Install_rules.Params) = struct
else
acc)
in
let deprecated_modules = Module.Name.Map.values wrapped_compat in
(* deprecated modules have implementations so we can just append them *)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comments is not clear to me. The reason is: nothing depends on compatibility modules and compatibility modules depends only on real modules

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, my comment referred to the earlier line where we filter only the modules which have implementations. You're right that I should comment about the order as well.

@rgrinberg rgrinberg force-pushed the wrapped-transition branch 2 times, most recently from c82cbaf to 74264e7 Compare August 31, 2018 14:48
src/module.ml Outdated
let (base, _) = Path.split_extension path in
{ syntax = OCaml
; path = Path.extend_basename base ~suffix:".ml-gen"
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code does the same thing:

{ syntax = OCaml
; path = Path.L.relative (dir t) [ ".wrapped_compat"; Name.to_string t.name ^ ".ml-gen" ]
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is. Fixed.

@ghost
Copy link

ghost commented Aug 31, 2018

BTW, I'm not sure Path.L.relative is the right name. We have Lib.L that operates on lists of Lib.t, while here Path.L.relative takes a single Path.t. Although I don't have a better suggestion

@rgrinberg
Copy link
Member Author

Yeah, Path.L.relative is entirely satisfactory but it does the benefit that a name like relative_all, concat_strings, etc. won't be as memorable.

@rgrinberg
Copy link
Member Author

Btw, I added 1.2 as the minimum version of the dune language for this feature

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Somehow this removes the deprecation

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
deprecated modules don't really have interfaces

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
@rgrinberg rgrinberg merged commit 6da1f19 into ocaml:master Aug 31, 2018
@rgrinberg rgrinberg deleted the wrapped-transition branch August 31, 2018 16:47
@hhugo
Copy link
Collaborator

hhugo commented Aug 31, 2018

Thanks

@hhugo
Copy link
Collaborator

hhugo commented Sep 1, 2018

When do you expect the next release of dune ?

@rgrinberg
Copy link
Member Author

I expect to make a release once polling mode is merged.

rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Sep 14, 2018
CHANGES:

- Ignore stderr output when trying to find out the number of jobs
  available (ocaml/dune#1118, fix ocaml/dune#1116, @diml)

- Fix error message when the source directory of `copy_files` does not exist.
  (ocaml/dune#1120, fix ocaml/dune#1099, @emillon)

- Highlight error locations in error messages (ocaml/dune#1121, @emillon)

- Display actual stanza when package is ambiguous (ocaml/dune#1126, fix ocaml/dune#1123, @emillon)

- Add `dune unstable-fmt` to format `dune` files. The interface and syntax are
  still subject to change, so use with caution. (ocaml/dune#1130, fix ocaml/dune#940, @emillon)

- Improve error message for `dune utop` without a library name (ocaml/dune#1154, fix
  ocaml/dune#1149, @emillon)

- Fix parsing `ocamllex` stanza in jbuild files (ocaml/dune#1150, @rgrinberg)

- Highlight multi-line errors (ocaml/dune#1131, @anuragsoni)

- Do no try to generate shared libraries when this is not supported by
  the OS (ocaml/dune#1165, fix ocaml/dune#1051, @diml)

- Fix `Flags.write_{sexp,lines}` in configurator by avoiding the use of
  `Stdune.Path` (ocaml/dune#1175, fix ocaml/dune#1161, @rgrinberg)

- Add support for `findlib.dynload`: when linking an executable using
  `findlib.dynload`, automatically record linked in libraries and
  findlib predicates (ocaml/dune#1172, @bobot)

- Add support for promoting a selected list of files (ocaml/dune#1192, @diml)

- Add an emacs mode providing helpers to promote correction files
  (ocaml/dune#1192, @diml)

- Improve message suggesting to remove parentheses (ocaml/dune#1196, fix ocaml/dune#1173, @emillon)

- Add `(wrapped (transition "..message.."))` as an option that will generate
  wrapped modules but keep unwrapped modules with a deprecation message to
  preserve compatibility. (ocaml/dune#1188, fix ocaml/dune#985, @rgrinberg)

- Fix the flags passed to the ppx rewriter when using `staged_pps` (ocaml/dune#1218, @diml)

- Add `(env var)` to add a dependency to an environment variable.
  (ocaml/dune#1186, @emillon)

- Add a simple version of a polling mode: `dune build -w` keeps
  running and restarts the build when something change on the
  filesystem (ocaml/dune#1140, @kodek16)

- Cleanup the way we detect the library search path. We no longer call
  `opam config var lib` in the default build context (ocaml/dune#1226, @diml)

- Make test stanzas honor the -p flag. (ocaml/dune#1236, fix ocaml/dune#1231, @emillon)

- Test stanzas take an optional (action) field to customize how they run (ocaml/dune#1248,
  ocaml/dune#1195, @emillon)

- Add support for private modules via the `private_modules` field (ocaml/dune#1241, fix
  ocaml/dune#427, @rgrinberg)

- Add support for passing arguments to the OCaml compiler via a
  response file when the list of arguments is too long (ocaml/dune#1256, @diml)

- Do not print diffs by default when running inside dune (ocaml/dune#1260, @diml)

- Interpret `$ dune build dir` as building the default alias in `dir`. (ocaml/dune#1259,
  @rgrinberg)

- Make the `dynlink` library available without findlib installed (ocaml/dune#1270, fix
  ocaml/dune#1264, @rgrinberg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants