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

Enhance include to depend on generated files, rather than on ones in the source tree #11525

Open
maxim092001 opened this issue Mar 11, 2025 · 3 comments
Labels
docs Documentation improvements open-to-contribution External contributors are welcomed to do a PR to solve the issue

Comments

@maxim092001
Copy link

maxim092001 commented Mar 11, 2025

Desired Behavior

According to current documentation:

Currently, the included file cannot be generated and must be present in the source tree.

It is a common use case for user to create OCaml executable that would generate a dune.inc.gen file and then include it into the dune file.

More about other use cases in official dune guide.

My current understanding is that include happens before rule generation. As a user, one may expect dune to regenerate generated file for me first before including it. Currently, I have to run dune build twice:

  • First build to generate new dune.inc.gen
  • Second build to pick up new dune.inc.gen

There are multiple approaches we can take, I am not sure what is the best one, so will list couple:

  • Add deps to include stanza to have ability to depend on some generated file/alias
  • Create include-gen stanza that would expect file to be generated by rules, rather than picking it up from source tree
    • It would probably run all rules before include and then run included rules

Example

Examples in official dune guide that have current behavior.

Thanks!

@nojb
Copy link
Collaborator

nojb commented Mar 11, 2025

Hello, note that this is already supported, using the dynamic_include stanza: https://dune.readthedocs.io/en/latest/reference/dune/dynamic_include.html.

@maxim092001
Copy link
Author

maxim092001 commented Mar 11, 2025

Hello, note that this is already supported, using the dynamic_include stanza: https://dune.readthedocs.io/en/latest/reference/dune/dynamic_include.html.

Great! Thanks Nicolas!

Then I propose to just add a link to dynamic_include from include in documentation. Would that make sense?

Replace

Currently, the included file cannot be generated and must be present in the source tree.

With

Currently, the included file cannot be generated and must be present in the source tree. To use generated include file please refer to dynamic_include

@maiste maiste added docs Documentation improvements open-to-contribution External contributors are welcomed to do a PR to solve the issue labels Mar 11, 2025
@nojb
Copy link
Collaborator

nojb commented Mar 12, 2025

Then I propose to just add a link to dynamic_include from include in documentation. Would that make sense?

Yes, this would be a good idea. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation improvements open-to-contribution External contributors are welcomed to do a PR to solve the issue
Projects
None yet
Development

No branches or pull requests

3 participants