-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dune): support
+
prefixes for PPX CLI flags (#11234)
* test(ppx): show flags starting with `+` are interpreted as library names Signed-off-by: Antonio Nuno Monteiro <[email protected]> * feat(dune): support `+` prefixes for PPX CLI flags Signed-off-by: Antonio Nuno Monteiro <[email protected]> * cr: only enabled for Dune versions starting with 3.18 Signed-off-by: Antonio Nuno Monteiro <[email protected]> * cr: add a better error message for `prefix = "+"` Signed-off-by: Antonio Nuno Monteiro <[email protected]> --------- Signed-off-by: Antonio Nuno Monteiro <[email protected]>
- Loading branch information
1 parent
0a43607
commit 30af715
Showing
2 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Create ppx1 and exe: | ||
|
||
$ cat > dune-project <<EOF | ||
> (lang dune 3.7) | ||
> EOF | ||
$ cat > dune <<EOF | ||
> (library | ||
> (name ppx) | ||
> (kind ppx_rewriter) | ||
> (modules ppx) | ||
> (ppx.driver (main Ppx.main))) | ||
> (executable | ||
> (name the_exe) | ||
> (modules the_exe) | ||
> (preprocess (pps ppx --alert ++foo))) | ||
> EOF | ||
$ cat > ppx.ml <<EOF | ||
> let main () = | ||
> let out = ref "" in | ||
> let args = | ||
> [ ("-o", Arg.Set_string out, "") | ||
> ; ("--impl", Arg.Set_string (ref ""), "") | ||
> ; ("--as-ppx", Arg.Set (ref false), "") | ||
> ; ("--cookie", Arg.Set (ref false), "") | ||
> ; ("--alert", Arg.Set_string (ref ""), "") | ||
> ] | ||
> in | ||
> let anon _ = () in | ||
> Arg.parse (Arg.align args) anon ""; | ||
> let out = open_out !out in | ||
> close_out out; | ||
> EOF | ||
$ touch the_exe.ml | ||
|
||
$ dune build ./the_exe.exe | ||
File "dune", line 9, characters 30-35: | ||
9 | (preprocess (pps ppx --alert ++foo))) | ||
^^^^^ | ||
Error: PPX args starting with `+' cannot be used before version 3.18 of the | ||
dune language | ||
Hint: Upgrade your dune-project to `(lang dune 3.18)' | ||
[1] | ||
|
||
Works since Dune 3.18 | ||
|
||
$ cat > dune-project <<EOF | ||
> (lang dune 3.18) | ||
> EOF | ||
$ dune build ./the_exe.exe |