Skip to content

Conversation

@art-w
Copy link
Contributor

@art-w art-w commented Jan 28, 2026

(builds on top of #1398 which provides ocaml-config:ox to detect OxCaml)

This PR is a rebase of @lukemaurer 's patches from oxcaml/odoc (+ small fixes from #22). I hope this will make it easier to keep everything uptodate, and that it isn't too much of a stretch as Odoc already supports multiple versions of the OCaml AST using cppo. (Note that the preprocessor was originally using OCAML_VERSION=(5,2,0) as a heuristic to check for OxCaml, but since dune 3.21 we can be exact.)

(chdir
%{workspace_root}
(run %{bin:cppo} -V OCAML:%{ocaml_version} -D "OXCAML" %{x} -o %{targets}))))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rules duplication, here and in src/loader/dune, are rather inconvenient but I didn't find how to avoid it: cppo only accepts variables with integer values in conditionals, but dune %{ocaml-config:ox} is a boolean with no way to cast it to an int (?). I tried cppo -D "OXCAML %{ocaml-config:ox} but then the variable can't be used in #if. Please let me know if you know a better way!

@art-w art-w marked this pull request as draft January 28, 2026 14:55
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.

2 participants