-
Notifications
You must be signed in to change notification settings - Fork 647
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
Allow use of directory names for filename lines in _CoqProject #16308
Conversation
5994924
to
8504ea7
Compare
I think this feature is nice, and |
6a91ea5
to
4362cc8
Compare
I think |
What is the potential for "abuse" of I'll update the doc once #15888 is merged. |
I mean misuse rather than abuse. Some people, for example, have git submodules in their projects. If those submodules contain .v files as well, then suddenly more .v files are being picked up by _CoqProject. This is less likely to happen with |
OK, makes sense. I don't think about git submodules very much. |
However, Coq ignores The solution would be for Coq to look for _CoqProject files and use the -Q/-R assigned logical name. I don't know how important that use case is. |
I think Coq (coqc/coqtop) knowing about _CoqProject in general is not a very good idea for several reasons. I won't get into it here though. _CoqProject is used by (and intended for) coq_makefile, coqide and other IDEs like PG. |
That only happens if the submodule is in the scope of the -Q/-R, in which case that's what the _coqproject writer wanted so what's the problem? |
You are correct. |
I spoke too soon. It is a problem if the project is loaded through $COQPATH, in which case no -Q/-R info is applied.
There are other use cases that would work better with _CoqProject info. I'll create a new issue for a discussion fairly soon. |
4362cc8
to
29d6875
Compare
Changed to use the simpler "echo <filenames>" and changed Separate from this PR, did you ever consider having a single shared copy of |
The job library:ci-fiat_crypto_legacy has failed in allow failure mode |
@jfehrle There seem to be some extra files in your commit. The directory wildcards/t shouldn't be there for instance. |
OK, I removed that directory. I think all the others are needed, right? Updated. |
If it makes the test easier to read, you can also include $ cat > _CoqProject << EOF
> -R . Wildcards
>
> a.v
> b?.v
> c[1-3].v
> x/*.v
> EOF at the start of your run.t. |
29d6875
to
98e1648
Compare
I prefer it totally static as it is, thanks. |
The job library:ci-fiat_crypto_legacy has failed in allow failure mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR lacks tests (no need to use cram)
|
||
In addition, you can list individual files, for example for the two script files | ||
`File1.v` and `SubDir/File2.v` whose logical paths are `MyProject.File1` and | ||
`MyProject.SubDir.File2`. We recommend naming that directory `MyProject`, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who are we to tell the user how they should name their directories?
Moreover, this is a recommendation that might be painful to follow for users. For example, the current directory might well be the name of a cloned git repository (e.g., coq-foo
) while the logical path is quite different (e.g., Foo
). Sure, users could always rename their checkout directory to match it against the logical path, but why should they care and why do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who are we to tell the user how they should name their directories?
There's nothing wrong per se in giving advice, indeed advice can often be quite helpful. Of course it has to be good advice. Users will do what they wish.
For example, the current directory might well be the name of a cloned git repository (e.g., coq-foo) while the logical path is quite different (e.g., Foo).
A good point. I had not considered that case when I wrote this section. For a single package project, the IDE gets the -R/-Q
information from _CoqProject
and passes it to Coq, so coq-foo
is fine. But the IDE only uses a single _CoqProject
, which isn't sufficient for projects that have multiple uninstalled packages, (uninstalled because e.g. you're editing multiple packages at once). Packages that you're editing should not be in the user-contrib
directory, so you need to use $COQPATH
to point to them. COQPATH uses the directory name as the first part of the logical name, hence the recommendation.
I have a proposal that will allow handling both your coq-foo
use case and the multipackage case as well as a few others we currently don't handle. I planned to bring that up shortly after completing this PR. Whether that proposal is implemented or not, I'd love to improve this section to address your concerns. I think that would work best as a separate discussion rather than in this PR. It's really a different topic from allowing directory names in _CoqProject
. Note that I'm not really adding new recommendations in this PR, but rather moving them from one spot to another. Is this a reasonable approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover, this is a recommendation that might be painful to follow for users.
Calling this "painful" seems exaggerated. git doesn't care about the name of the directory containing a cloned git repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I agree that the advice is essentially the existing one, I agree it violates the most common conventions.
It's also pretty confusing — if you have a folder containing the suggested _CoqProject
, File1.v
, and SubDir/File2.v
, then the name of that folder is technically irrelevant in this scenario.
For a single package project, the IDE gets the -R/-Q information from _CoqProject and passes it to Coq, so coq-foo is fine.
Dashes are common in project nams, but they're illegal in logical names — you can't use -Q . my-package
, because Require my-package.foo
does not parse correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's refine the recommendations very soon, but not in this PR.
Perhaps this will be simplified in the future. The order of the entries does not | ||
matter. | ||
using a single `-R` with `.` as the :term:`physical path` for simplicity. You must also | ||
identify all the `.v` files in your package. We recommend using directory names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wary of all these recommendations. That is certainly not something I would ever recommend to a user. And in fact, this is not even the common practice in the Coq ecosystem. Common practice is to have a directory theories
and to have the corresponding option -R theories Logical
.
@@ -163,8 +169,8 @@ Then: | |||
|
|||
- Compile your project with :n:`make -f CoqMakefile` as needed. | |||
|
|||
If you add new files to your project, add them to `_CoqProject` and | |||
re-run `coq_makefile` and `make`. | |||
If you add more files to your project that are not in directories listed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that correct? Since coq_makefile
is responsible for traversing the directories, I don't understand how a new file could be located without running it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mistakenly dropped the expansion of directories in the makefile, I'll re-add that.
222c1f4
to
ac8af24
Compare
I created two new tests and dropped the cram test. They run just fine locally, but they inexplicably report they're unable to find
|
I originally suggested the use of cram tests to Jim since they could be easier to work with, however for coq_makefile this hasn't worked too well due to the special environment expected by coq_makefile. I don't have enough knowledge to set that up correctly. |
6e940b3
to
6e72168
Compare
`MyProject.SubDir.File2`. We recommend naming that directory `MyProject`, the | ||
same as the logical name:: | ||
|
||
-R . MyProject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware the new text mixes -R . MyPackage
and -R . MyProject
. That might be because the old text was already incorrect — it uses -R . MyPackage
to configure a "logical name" MyProject
, which is just wrong.
At a first look, there isn't a real distinction, so the simplest fix is to unify them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, got it. They are all MyPackage
now.
@gares The tests pass. If this looks good, I'll squash before the merge. |
6e72168
to
2e23c15
Compare
I think the failure in ci-fiat_parsers is unrelated. The log for that job shows a change made this afternoon. It worked in the previous run and I made no substantive code change to the PR since then:
|
I've restarted Fiat parsers. The commit you mention should build |
@JasonGross fiat parsers is still failing, but probably unrelated to this PR
|
Trying another fix |
Don't rush on my account. I think we can safely ignore the failure for this PR. |
other file types) in the current directory and its subdirectories: | ||
|
||
-R . MyPackage | ||
. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this little dot deserves a comment, the reader may not even see it. Could also be written ./
to make it more visible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I'd recommend putting the sources in a (sub) directory. I don't recall any project placing source files at the root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it was supposed to be formatted like this, which I fixed:
I'll refine the recommendations soon. FWIW the bignums package puts files at the root. Hard to expect people to know about or follow unwritten conventions.
~/.opam/__coq-platform.2022.01.0~8.15~beta1/.opam-switch/sources/coq-bignums.8.15.0$ more _CoqProject
-I plugin
-R . Bignums
2e23c15
to
c62c02d
Compare
Updated and squashed, please merge. Thanks to all of you who reviewed, commented and helped me! |
@gares Do you plan to |
@coqbot merge now |
@gares: You cannot merge this PR because:
|
@coqbot merge now |
UPDATED 7/27: Currently
coq_makefile
requires listing every single file in the project. Every time you add a file to the project, you have to update_CoqProject
and reruncoq_makefile
. That's a waste of energy and brain cells.This PR adds expansion of directory names, so
_CoqProject
will need far fewer entries and far fewer updates. Expansion is also applied to paths specified on thecoq_makefile
command line. (Names that start with-
or that have an extension are not expanded. If a specified directory doesn't exist, it is ignored.)For example, instead of:
you could have:
Still needs:
changelogdocumentation