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

[coq top] Test case for problems with path / dir computation in dune … #5552

Closed
wants to merge 1 commit into from

Conversation

ejgallego
Copy link
Collaborator

@ejgallego ejgallego commented Apr 6, 2022

…coq top

After some more testing, I have found problems finding the directory /
file for dune coq top:

        let coq_file_build =
          let p = Common.prefix_target common coq_file_arg in
          Path.Build.relative context.build_dir p
        in
        let dir =
          let dir = Filename.dirname coq_file_arg in
          let p = Common.prefix_target common dir in
          Path.Build.relative context.build_dir p
        in

dune coq top will also fail on project that have a theories/a/b.v
layout, such as in Coq for example, when doing:

dune coq top theories/Reals/Real.v

in the above snippet, dir is set to theories/Reals which is
incorrect, as it should be the root of where the stanza is placed.

This makes dune fail with:

Error: No rule found for theories/Reals/Reals/Reals.v.d

as dir is set incorrectly.

We need to think more about this, and fix it because it is currently
only usable on flat layouts.

Let's discuss in this PR cc @rlepigre

…coq top

After some more testing, I have found problems finding the directory /
file for `dune coq top`:

```ocaml
        let coq_file_build =
          let p = Common.prefix_target common coq_file_arg in
          Path.Build.relative context.build_dir p
        in
        let dir =
          let dir = Filename.dirname coq_file_arg in
          let p = Common.prefix_target common dir in
          Path.Build.relative context.build_dir p
        in
```

`dune coq top` will also fail on project that have a `theories/a/b.v`
layout, such as in Coq for example, when doing:

```
dune coq top theories/Reals/Real.v
```

in the above snippet, `dir` is set to `theories/Reals` which is
incorrect, as it should be the root of where the stanza is placed.

We need to think more about this, and fix it because it is currently
only usable on flat layouts.

Let's discuss in this PR.
@ejgallego ejgallego added this to the 3.1.0 milestone Apr 6, 2022
@rlepigre
Copy link
Contributor

rlepigre commented Apr 7, 2022

Damn, I thought I tested something like that...

Not sure what the best fix is: we seem to need the directory quite early on, though I don't completely understand what is the role of all the ~dir arguments that are passed throughout the code. I often wondered whether I was making the right choice when coming up with the code, but I could find no hint as to what the expected directory is. Is it always the case that it is the directory containing the dune file defining the stanza of interest?

If that is the case, maybe we should extend the exploration of the workspace to build a map from directories to "stanza root" directories, if no such thing already exists?

@ejgallego
Copy link
Collaborator Author

@rlepigre indeed that part is tricky, but indeed I think we have all we need in hand, I need to think more about it, but it seems to me that we should:

  • Build the dune db, stanza scanning, etc...
  • Use the reverse map to locate the stanza
  • Use the stanza base dir as dir

This is what code in coq_rules.ml expects today, and I think would actually be cleaner! Note that the fact that coq_rules expects dir to be like that, doesn't mean it has to be that way.

I picked that particular logic as it was natural to me that for example, for a project with theories/dune, we do (cd theories && coqc foo/bar/m.v) instead of (cd theories/foo/bar/m.v && coqc ... but YMMV.

Don't worry too much about it, I can take care of the fix, should be a very small patch (I just read your mail)

@ejgallego
Copy link
Collaborator Author

And yes, we need to document dir and other parameters much better!

The thing is that coq_rules was the first implementation of (include_subdirs qualified) so we didn't know too well what we were doing.

@ejgallego
Copy link
Collaborator Author

Note that dune build foo/bar/foo.v does already properly locate the right path for the target, so I'd be surprised if we can't just follow what dune build does, then just use the reverse map.

@ejgallego
Copy link
Collaborator Author

In particular, Targets.interpret_targets is the function that takes care of understanding the filename argument to dune build

@rgrinberg rgrinberg added the coq label Apr 15, 2022
@rgrinberg rgrinberg modified the milestones: 3.1.0, 3.2.0 Apr 15, 2022
@rgrinberg rgrinberg modified the milestones: 3.2.0, 3.3.0 May 4, 2022
rlepigre pushed a commit to rlepigre/dune that referenced this pull request Jun 11, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Rodolphe Lepigre <lepigre@mpi-sws.org>
rlepigre pushed a commit to rlepigre/dune that referenced this pull request Jun 11, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Rodolphe Lepigre <lepigre@mpi-sws.org>
rlepigre pushed a commit to rlepigre/dune that referenced this pull request Jun 11, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Rodolphe Lepigre <lepigre@mpi-sws.org>
rlepigre pushed a commit to rlepigre/dune that referenced this pull request Jun 11, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Rodolphe Lepigre <lepigre@mpi-sws.org>
rlepigre pushed a commit to rlepigre/dune that referenced this pull request Jun 11, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Rodolphe Lepigre <lepigre@mpi-sws.org>
rlepigre pushed a commit to rlepigre/dune that referenced this pull request Jun 16, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Rodolphe Lepigre <lepigre@mpi-sws.org>
@rgrinberg
Copy link
Member

Replaced by @rlepigre's PR

@rgrinberg rgrinberg closed this Jun 16, 2022
Alizter pushed a commit to Alizter/dune that referenced this pull request Jun 20, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Rodolphe Lepigre <lepigre@mpi-sws.org>
Alizter pushed a commit to Alizter/dune that referenced this pull request Jun 20, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
Alizter pushed a commit to Alizter/dune that referenced this pull request Jun 20, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
Alizter pushed a commit to Alizter/dune that referenced this pull request Jun 20, 2022
This was reported in ocaml#5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
rgrinberg pushed a commit that referenced this pull request Jun 21, 2022
This was reported in #5552.

Co-authored-by: Emilio Jesus Gallego Arias <e+git@x80.org>

Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
emillon added a commit to emillon/opam-repository that referenced this pull request Jul 20, 2022
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.4.0)

CHANGES:

- Make `dune describe` correctly handle overlapping implementations
  for virtual libraries (ocaml/dune#5971, fixes ocaml/dune#5747, @esope)

- Building the `@check` alias should make sure the libraries and executables
  don't have dependency cycles (ocaml/dune#5892, @rgrinberg)

- [ctypes] Add support for the `errno` parameter using the `errno_policy` field
  in the ctypes settings. (ocaml/dune#5827, @droyo)

- Fix `dune coq top` when it is invoked on files from a subdirectory of the
  directory containing the associated stanza (ocaml/dune#5784, fixes ocaml/dune#5552, @ejgallego,
  @rlepigre, @Alizter)

- Fix hint when an invalid module name is found. (ocaml/dune#5922, fixes ocaml/dune#5273, @emillon)

- The `(cat)` action now supports several files. (ocaml/dune#5928, fixes ocaml/dune#5795, @emillon)

- Dune no longer uses shimmed `META` files for OCaml 5.x, solely using the ones
  installed by the compiler. (ocaml/dune#5916, @dra27)

- Fix handling of the `(deps)` field in `(test)` stanzas when there is an
  `.expected` file. (ocaml/dune#5952, ocaml/dune#5951, fixes ocaml/dune#5950, @emillon)

- Ignore insignificant filesystem events. This stops RPC in watch mode from
  flashing errors on insignificant file system events such as changes in the
  `.git/` directory. (ocaml/dune#5953, @rgrinberg)

- Fix parsing more error messages emitted by the OCaml compiler. In
  particular, messages where the excerpt line number started with a blank
  character were skipped. (ocaml/dune#5981, @rgrinberg)

- env stanza: warn if some rules are ignored because they appear after a
  wildcard rule. (ocaml/dune#5898, fixes ocaml/dune#5886, @emillon)

- On Windows, XDG_CACHE_HOME is taken to be the `FOLDERID_InternetCache` if
  unset, and XDG_CONFIG_HOME and XDG_DATA_HOME are both taken to be
  `FOLDERID_LocalAppData` if unset.  (ocaml/dune#5943, fixes ocaml/dune#5808, @nojb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants