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

Enable reusing the specification of options in a dfyconfig.toml #5337

Closed
keyboardDrummer opened this issue Apr 19, 2024 · 2 comments · Fixed by #5359
Closed

Enable reusing the specification of options in a dfyconfig.toml #5337

keyboardDrummer opened this issue Apr 19, 2024 · 2 comments · Fixed by #5359
Labels
area: build-system Support for dependencies in Dafny, generation of target language build files kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny

Comments

@keyboardDrummer
Copy link
Member

To enable reusing the specification of options, Dafny should allow using a Dafny project file as a source file, either directly on the CLI or in the includes section of a project file. This allows specifying a tree of project files. Elements from this tree are merged into a single Dafny project. The merging is done bottom up, where later elements override the options set by earlier ones. Overriding an excludes can be done by setting the same path in an includes.

  • A positive side-effect of this change is that there no longer is a special treatment for the first file that is passed to the CLI, since previously only that could be a project file.
@keyboardDrummer keyboardDrummer added kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny area: build-system Support for dependencies in Dafny, generation of target language build files labels Apr 19, 2024
@robin-aws
Copy link
Member

This sounds useful! I initially thought we wouldn't need both this feature and #5336 since they behave similarly, but I think the use cases are pretty different: organizing similar groups of code internally in a project, as opposed to dependencies between projects that may be maintained by independent groups of people.

I'd suggest if we implement this we deprecate the {:options ...} attribute, since a co-located project file seems like a much cleaner and flexible solution.

@keyboardDrummer
Copy link
Member Author

keyboardDrummer commented Apr 19, 2024

I should clarify. The intended usage here is:

/src/common/commonOptions.dfyconfig.toml
/src/shared/dfyconfig.toml <- includes `commonOptions.dfyconfig.toml`
/src/java/dfyconfig.toml <- includes `commonOptions.dfyconfig.toml`, depends on `shared/dfyconfig.toml`
/src/rust/dfyconfig.toml <- includes `commonOptions.dfyconfig.toml`, depends on `shared/dfyconfig.toml`

Where commonOptions.dfyconfig.toml likely only has an [options] section and doesn't include any .dfy files.

keyboardDrummer added a commit that referenced this issue May 1, 2024
Fixes #5337

### Description
- Add the field `base` to Dafny project files, which allows a project
file to inherit fields from another one. Options from the current file
override options from the base. Includes from the current file override
excludes from the base, and excludes from the current file override
includes from the base. The base may itself also have a base.
- Small improvements to project file error reporting. See the updates in
existing tests for more information.

### How has this been tested?
 - Added the test `cli/projectFile/base/included.dfy`

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build-system Support for dependencies in Dafny, generation of target language build files kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants