Skip to content

feat(dune): support + prefixes for PPX CLI flags #11234

Merged
anmonteiro merged 5 commits intoocaml:mainfrom
anmonteiro:anmonteiro/melange-test-use-another-flag
Dec 25, 2024
Merged

feat(dune): support + prefixes for PPX CLI flags #11234
anmonteiro merged 5 commits intoocaml:mainfrom
anmonteiro:anmonteiro/melange-test-use-another-flag

Conversation

@anmonteiro
Copy link
Copy Markdown
Collaborator

@anmonteiro anmonteiro commented Dec 20, 2024

this is useful for cases like melange.ppx which emit alerts and allow to configure them via -alert ....

@anmonteiro anmonteiro changed the title feat(dune): support + prefixes for PPX CLI flags feat(dune): support + prefixes for PPX CLI flags Dec 20, 2024
@rgrinberg
Copy link
Copy Markdown
Member

I think this needs to be versioned. You can version this under dune's own language or melange's. Depending on how stable you'd like to keep this feature.

@anmonteiro
Copy link
Copy Markdown
Collaborator Author

Why do you think this needs to be versioned?

I believe the previous behavior would just plainly return an error, so we shouldn't have anyone depending on these features, right?

@rgrinberg
Copy link
Copy Markdown
Member

rgrinberg commented Dec 21, 2024

Suppose that somebody would try to use this feature in a publicly released project. That person would need to remember to update the constraints in their project file to require at least dune 3.18. Without the version check, it is very likely that the person would forget to add this constraint, or they might even do it incorrectly, if they misremember which version of dune introduced this feature. Downstream user of this project might then encounter build failures should they build with an older version of dune. If we add a version check, we make this scenario more or less impossible.

It's true that the above argument is applicable to basically any user visible change in dune, but I think it works best for features. As for bug fixes, it's good that users can benefit from those without opting in. I think that this PR is certainly more of a feature than a bug fix.

@anmonteiro
Copy link
Copy Markdown
Collaborator Author

absolutely, thanks for the explainer!

@anmonteiro anmonteiro force-pushed the anmonteiro/melange-test-use-another-flag branch 2 times, most recently from 8cdabdc to 493b6f9 Compare December 21, 2024 05:54
@anmonteiro
Copy link
Copy Markdown
Collaborator Author

@rgrinberg ready for another look.

with
| Yes, _ -> Right s
| _, Yes when syntax_version >= (3, 18) -> Right s
| (No | Unknown _), _ ->
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you could improve the error message here with a hint for prefix = "+" when syntax_version < (3, 18)

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
@anmonteiro anmonteiro force-pushed the anmonteiro/melange-test-use-another-flag branch from 493b6f9 to e57cc15 Compare December 23, 2024 02:39
@maiste maiste added melange Melange rules and generator enhancement and removed melange Melange rules and generator labels Dec 23, 2024
@anmonteiro anmonteiro enabled auto-merge (squash) December 25, 2024 09:10
@anmonteiro anmonteiro merged commit 30af715 into ocaml:main Dec 25, 2024
@anmonteiro anmonteiro deleted the anmonteiro/melange-test-use-another-flag branch December 25, 2024 09:10
anmonteiro added a commit to anmonteiro/dune that referenced this pull request Dec 25, 2024
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
anmonteiro added a commit that referenced this pull request Dec 25, 2024
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
ElectreAAS pushed a commit to ElectreAAS/dune that referenced this pull request Jan 27, 2025
* test(ppx): show flags starting with `+` are interpreted as library names

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* feat(dune): support `+` prefixes for PPX CLI flags

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* cr: only enabled for Dune versions starting with 3.18

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* cr: add a better error message for `prefix = "+"`

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

---------

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
ElectreAAS pushed a commit to ElectreAAS/dune that referenced this pull request Jan 27, 2025
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
chris-armstrong pushed a commit to chris-armstrong/dune that referenced this pull request Jan 29, 2025
* test(ppx): show flags starting with `+` are interpreted as library names

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* feat(dune): support `+` prefixes for PPX CLI flags

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* cr: only enabled for Dune versions starting with 3.18

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* cr: add a better error message for `prefix = "+"`

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

---------

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Chris Armstrong <chris-armstrong@users.noreply.github.com>
chris-armstrong pushed a commit to chris-armstrong/dune that referenced this pull request Jan 29, 2025
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Signed-off-by: Chris Armstrong <chris-armstrong@users.noreply.github.com>
maiste added a commit to maiste/opam-repository that referenced this pull request Mar 31, 2025
CHANGES:

### Fixed

- Support HaikuOS: don't call `execve` since it's not allowed if other pthreads
  have been created. The fact that Haiku can't call `execve` from other threads
  than the principal thread of a process (a team in haiku jargon), is a
  discrepancy to POSIX and hence there is a [bug about
  it](https://dev.haiku-os.org/ticket/18665). (@Sylvain78, ocaml/dune#10953)
- Fix flag ordering in generated Merlin configurations (ocaml/dune#11503, @voodoos, fixes
  ocaml/merlin#1900, reported by @vouillon)

### Added

- Add `(format-dune-file <src> <dst>)` action. It provides a replacement to
  `dune format-dune-file` command.  (ocaml/dune#11166, @nojb)
- Allow the `--prefix` flag when configuring dune with `ocaml configure.ml`.
  This allows to set the prefix just like `$ dune install --prefix`. (ocaml/dune#11172,
  @rgrinberg)
- Allow arguments starting with `+` in preprocessing definitions (starting with
  `(lang dune 3.18)`). (@amonteiro, ocaml/dune#11234)
- Support for opam `(maintenance_intent ...)` in dune-project (ocaml/dune#11274, @art-w)
- Validate opam `maintenance_intent` (ocaml/dune#11308, @art-w)
- Support `not` in package dependencies constraints (ocaml/dune#11404, @art-w, reported
  by @hannesm)

### Changed

- Warn when failing to discover root due to reads failing. The previous
  behavior was to abort. (@KoviRobi, ocaml/dune#11173)
- Use shorter path for inline-tests artifacts. (@hhugo, ocaml/dune#11307)
- Allow dash in `dune init` project name (ocaml/dune#11402, @art-w, reported by @saroupille)
- On Windows, under heavy load, file delete operations can sometimes fail due to
  AV programs, etc. Guard against it by retrying the operation up to 30x with a
  1s waiting gap (ocaml/dune#11437, fixes ocaml/dune#11425, @MSoegtropIMC)
- Cache: we now only store the executable permission bit for files (ocaml/dune#11541,
  fixes ocaml/dune#11533, @ElectreAAS)
- Display negative error codes on Windows in hex which is the more customary
  way to display `NTSTATUS` codes (ocaml/dune#11504, @MisterDA)
maiste added a commit to maiste/opam-repository that referenced this pull request Apr 3, 2025
CHANGES:

### Fixed

- Support HaikuOS: don't call `execve` since it's not allowed if other pthreads
  have been created. The fact that Haiku can't call `execve` from other threads
  than the principal thread of a process (a team in haiku jargon), is a
  discrepancy to POSIX and hence there is a [bug about
  it](https://dev.haiku-os.org/ticket/18665). (@Sylvain78, ocaml/dune#10953)
- Fix flag ordering in generated Merlin configurations (ocaml/dune#11503, @voodoos, fixes
  ocaml/merlin#1900, reported by @vouillon)

### Added

- Add `(format-dune-file <src> <dst>)` action. It provides a replacement to
  `dune format-dune-file` command.  (ocaml/dune#11166, @nojb)
- Allow the `--prefix` flag when configuring dune with `ocaml configure.ml`.
  This allows to set the prefix just like `$ dune install --prefix`. (ocaml/dune#11172,
  @rgrinberg)
- Allow arguments starting with `+` in preprocessing definitions (starting with
  `(lang dune 3.18)`). (@amonteiro, ocaml/dune#11234)
- Support for opam `(maintenance_intent ...)` in dune-project (ocaml/dune#11274, @art-w)
- Validate opam `maintenance_intent` (ocaml/dune#11308, @art-w)
- Support `not` in package dependencies constraints (ocaml/dune#11404, @art-w, reported
  by @hannesm)

### Changed

- Warn when failing to discover root due to reads failing. The previous
  behavior was to abort. (@KoviRobi, ocaml/dune#11173)
- Use shorter path for inline-tests artifacts. (@hhugo, ocaml/dune#11307)
- Allow dash in `dune init` project name (ocaml/dune#11402, @art-w, reported by @saroupille)
- On Windows, under heavy load, file delete operations can sometimes fail due to
  AV programs, etc. Guard against it by retrying the operation up to 30x with a
  1s waiting gap (ocaml/dune#11437, fixes ocaml/dune#11425, @MSoegtropIMC)
- Cache: we now only store the executable permission bit for files (ocaml/dune#11541,
  fixes ocaml/dune#11533, @ElectreAAS)
- Display negative error codes on Windows in hex which is the more customary
  way to display `NTSTATUS` codes (ocaml/dune#11504, @MisterDA)
Sudha247 pushed a commit to Sudha247/dune that referenced this pull request Jul 23, 2025
* test(ppx): show flags starting with `+` are interpreted as library names

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* feat(dune): support `+` prefixes for PPX CLI flags

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* cr: only enabled for Dune versions starting with 3.18

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

* cr: add a better error message for `prefix = "+"`

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>

---------

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Sudha247 pushed a commit to Sudha247/dune that referenced this pull request Jul 23, 2025
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants