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

feature: dynamic_include stanza #9913

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

rgrinberg
Copy link
Member

@rgrinberg rgrinberg commented Feb 3, 2024

Introduce the [dynamic_include] stanza. It's like [(include ..)], but
doesn't allow us to generate static stanzas and a few other stanzas that can affect the entire context. Those include:

  • libraries, coq theories, and other library like stanzas
  • public executables
  • install stanzas with (section bin).
  • plugin stanzas

The limitation on generating private libraries is possible to lift, but it will take quite a bit more effort. I will do so in subsequent PR's.

TODO

  • dynamic_include in dynamic_include
  • include in dynamic_include.
  • cycle checking for the above.

Signed-off-by: Rudi Grinberg [email protected]

@rgrinberg rgrinberg force-pushed the ps/rr/feature__dynamic_include_stanza branch 2 times, most recently from a753c6c to 0c5cce0 Compare February 3, 2024 20:36
@rgrinberg rgrinberg requested a review from nojb February 3, 2024 20:49
@nojb
Copy link
Collaborator

nojb commented Feb 3, 2024

Can you say a few words for the motivation behind this addition?

About the name dynamic_include: typically my first feeling is that a "dynamic" X is something more powerful than a "plain" X, but in this case it seems to be less powerful than a plain X. In any case, I don't understand the feature well enough yet to propose a different name.

@rgrinberg
Copy link
Member Author

The main motivation is a straightforward one. Allow a way of generating rules without promoting them to the source.

Why a different name? Because this include has different semantics and limitations that are (likely) impossible to lift. So I think a different name is appropriate.

@nojb
Copy link
Collaborator

nojb commented Feb 3, 2024

Allow a way of generating rules without promoting them to the source.

Sorry for the naive question, but what does "promoting them to the source" mean here? I looked at the test, but couldn't figure out what is special about the new form (vs a normal (include)).

@rgrinberg
Copy link
Member Author

When you write (include foo), the file foo must exist in the source directory. To make foo be generated by a rule, we workaround it by making the rule promotable.

If you use this new stanza, you can skip the promotion step and use a regular rule to generate stanzas provided the limitations in the description are acceptable to you.

@nojb
Copy link
Collaborator

nojb commented Feb 3, 2024

If you use this new stanza, you can skip the promotion step and use a regular rule to generate stanzas provided the limitations in the description are acceptable to you.

I had missed that, thanks. Indeed, this is a cool addition!

Being able to define executables in this way is already a big advance; eg defining a test suite for every file in a directory.

@rgrinberg rgrinberg force-pushed the ps/rr/feature__dynamic_include_stanza branch 4 times, most recently from be69932 to 9878c10 Compare February 4, 2024 05:23
@rgrinberg rgrinberg added this to the 3.14.0 milestone Feb 4, 2024
@rgrinberg rgrinberg force-pushed the ps/rr/feature__dynamic_include_stanza branch 2 times, most recently from 99d519b to d959d5b Compare February 4, 2024 05:55
Copy link
Collaborator

@nojb nojb left a comment

Choose a reason for hiding this comment

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

LGTM (but I only looked at the code changes briefly)

@rgrinberg rgrinberg force-pushed the ps/rr/feature__dynamic_include_stanza branch from d959d5b to 01e975a Compare February 4, 2024 21:18
@rgrinberg rgrinberg force-pushed the ps/rr/feature__dynamic_include_stanza branch 7 times, most recently from 1bb0c70 to 5bffe77 Compare February 5, 2024 09:18
Introduce the [dynamic_include] stanza. It's like [(include ..)], but
doesn't allow us to generate static stanzas (see [Dune_file0] for what
those are).

Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: 55957fb9-7975-4cd6-aced-4d9d348dfbd6 -->
@rgrinberg rgrinberg force-pushed the ps/rr/feature__dynamic_include_stanza branch from 5bffe77 to 672ab25 Compare February 5, 2024 20:33
@rgrinberg rgrinberg merged commit 6a39517 into main Feb 5, 2024
24 of 27 checks passed
@rgrinberg rgrinberg deleted the ps/rr/feature__dynamic_include_stanza branch February 5, 2024 21:16
emillon added a commit to emillon/opam-repository that referenced this pull request Feb 9, 2024
CHANGES:

### Added

- Introduce a `(dynamic_include ..)` stanza. This is like `(include foo)` but
  allows `foo` to be the target of a rule. Currently, there are some
  limitations on the stanzas that can be generated. For example, public
  executables, libraries are currently forbidden. (ocaml/dune#9913, @rgrinberg)

- Introduce `$ dune promotion list` to print the list of available promotions.
  (ocaml/dune#9705, @moyodiallo)

- If Sherlodoc is installed, add a search bar in generated HTML docs (ocaml/dune#9772,
  @EmileTrotignon)

- Add `only_sources` field to `copy_files` stanza (ocaml/dune#9827, fixes ocaml/dune#9709,
  @jchavarri)

- The `(foreign_library)` stanza now supports the `(enabled_if)` field. (ocaml/dune#9914,
  @nojb)

### Fixed

- Fix `$ dune install -p` incorrectly recognizing packages that are supposed to
  be filtered (ocaml/dune#9879, fixes ocaml/dune#4814, @rgrinberg)

- subst: correctly handle opam files in opam/ subdirectory (ocaml/dune#9895, fixes ocaml/dune#9862,
  @emillon)

- Odoc private rules are not set up if a library is not available due to
  `enabled_if` (ocaml/dune#9897, @rgrinberg and @jchavarri)

### Changed

- When dune language 3.14 is enabled, resolve the binary in `(run %{bin:..}
  ..)` from where the binary is built. (ocaml/dune#9708, @rgrinberg)

- boot: remove single-command bootstrap. This was an alternative bootstrap
  strategy that was used in certain conditions. Removal makes the bootstrap a
  bit slower on Linux when only a single core is available, but bootstrap is
  now reproducible in all cases. (ocaml/dune#9735, fixes ocaml/dune#9507, @emillon)
emillon added a commit to emillon/opam-repository that referenced this pull request Feb 12, 2024
CHANGES:

### Added

- Introduce a `(dynamic_include ..)` stanza. This is like `(include foo)` but
  allows `foo` to be the target of a rule. Currently, there are some
  limitations on the stanzas that can be generated. For example, public
  executables, libraries are currently forbidden. (ocaml/dune#9913, @rgrinberg)

- Introduce `$ dune promotion list` to print the list of available promotions.
  (ocaml/dune#9705, @moyodiallo)

- If Sherlodoc is installed, add a search bar in generated HTML docs (ocaml/dune#9772,
  @EmileTrotignon)

- Add `only_sources` field to `copy_files` stanza (ocaml/dune#9827, fixes ocaml/dune#9709,
  @jchavarri)

- The `(foreign_library)` stanza now supports the `(enabled_if)` field. (ocaml/dune#9914,
  @nojb)

### Fixed

- Fix `$ dune install -p` incorrectly recognizing packages that are supposed to
  be filtered (ocaml/dune#9879, fixes ocaml/dune#4814, @rgrinberg)

- subst: correctly handle opam files in opam/ subdirectory (ocaml/dune#9895, fixes ocaml/dune#9862,
  @emillon)

- Odoc private rules are not set up if a library is not available due to
  `enabled_if` (ocaml/dune#9897, @rgrinberg and @jchavarri)

### Changed

- When dune language 3.14 is enabled, resolve the binary in `(run %{bin:..}
  ..)` from where the binary is built. (ocaml/dune#9708, @rgrinberg)

- boot: remove single-command bootstrap. This was an alternative bootstrap
  strategy that was used in certain conditions. Removal makes the bootstrap a
  bit slower on Linux when only a single core is available, but bootstrap is
  now reproducible in all cases. (ocaml/dune#9735, fixes ocaml/dune#9507, @emillon)
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

### Added

- Introduce a `(dynamic_include ..)` stanza. This is like `(include foo)` but
  allows `foo` to be the target of a rule. Currently, there are some
  limitations on the stanzas that can be generated. For example, public
  executables, libraries are currently forbidden. (ocaml/dune#9913, @rgrinberg)

- Introduce `$ dune promotion list` to print the list of available promotions.
  (ocaml/dune#9705, @moyodiallo)

- If Sherlodoc is installed, add a search bar in generated HTML docs (ocaml/dune#9772,
  @EmileTrotignon)

- Add `only_sources` field to `copy_files` stanza (ocaml/dune#9827, fixes ocaml/dune#9709,
  @jchavarri)

- The `(foreign_library)` stanza now supports the `(enabled_if)` field. (ocaml/dune#9914,
  @nojb)

### Fixed

- Fix `$ dune install -p` incorrectly recognizing packages that are supposed to
  be filtered (ocaml/dune#9879, fixes ocaml/dune#4814, @rgrinberg)

- subst: correctly handle opam files in opam/ subdirectory (ocaml/dune#9895, fixes ocaml/dune#9862,
  @emillon)

- Odoc private rules are not set up if a library is not available due to
  `enabled_if` (ocaml/dune#9897, @rgrinberg and @jchavarri)

### Changed

- When dune language 3.14 is enabled, resolve the binary in `(run %{bin:..}
  ..)` from where the binary is built. (ocaml/dune#9708, @rgrinberg)

- boot: remove single-command bootstrap. This was an alternative bootstrap
  strategy that was used in certain conditions. Removal makes the bootstrap a
  bit slower on Linux when only a single core is available, but bootstrap is
  now reproducible in all cases. (ocaml/dune#9735, fixes ocaml/dune#9507, @emillon)
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