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

Replace CPPO with µCPPO #175

Merged

Conversation

Leonidas-from-XIV
Copy link
Member

This removes a build dependency and replaces the conditional compilation with a mucppo, a CPPO subset meant for embedding in builds: https://github.com/Leonidas-from-XIV/mucppo

The advantage is that it sheds another dependency from Yojson and given it is only needed at compile time, the tool is quickly built (as it is a single file) and never installed into the users switch.

@Leonidas-from-XIV Leonidas-from-XIV force-pushed the remove-cppo branch 4 times, most recently from 34e6373 to 89f22f1 Compare April 26, 2024 08:44
@panglesd
Copy link
Collaborator

Just a small comment: If the goal is to remove dependencies, an alternative approach would have been to make the preprocessed output "promoted" in the tree, and directly used when installing through opam. So that (even if we kept using cppo) we could move cppo from the build dependencies to the test dependencies.

We used to have this in odoc: we use ocaml-crunch to generate a module from static files, promoted the result and did not include ocaml-crunch to the dependencies. See the dune file at that time. We now more simply include ocaml-crunch as a dependency... (ocaml/odoc#1044).

(But your approach is also valid of course!)

@Leonidas-from-XIV
Copy link
Member Author

I used such an approach in xml2js to allow people to use the generated source without the CoffeeScript compiler, the issues with this are twofold:

  1. People started making PRs to the generated source, which were entirely unusable as a run of the compiler would overwrite them
  2. In the case of Yojson one needs to run the build anyway to compile the .ml sources, so whether the preprocessing happens here makes no difference to the user. In the case of PPX, it would be rather unusual to have the preprocessed source in the tree.

In the long end, my goal would be to get rid of all variants but Basic and Safe, at which point we might be able to completely get rid of any preprocessing and use e.g. functors or the like. This has the advantage that it works a lot better with Merlin and the code is much easier to read if it doesn't contain flights of code that are not run. For example JSON5 PR is written in a way where it supports both ASTs yet doesn't require any additional conditional compilation.

In the end this is just a small step which removes a (in the grand scheme of things) small dependency, it doesn't preclude any further improvements in the future as you suggest :-)

This removes a build dependency and replaces the conditional compilation
with a tool vendored and used at compile time.

mucppo is marked as vendored since it should just be copied from
upstream and not modified in-tree.
@Leonidas-from-XIV Leonidas-from-XIV merged commit 11fe582 into ocaml-community:master May 31, 2024
3 of 4 checks passed
@Leonidas-from-XIV Leonidas-from-XIV deleted the remove-cppo branch May 31, 2024 07:38
Leonidas-from-XIV added a commit to Leonidas-from-XIV/opam-repository that referenced this pull request May 31, 2024
CHANGES:

*2024-05-31*

### Added

- Added support for JSON5 (@dhilst, @gorm-issuu, @gertsonderby, ocaml-community/yojson#152)

### Removed

- Remove CPPO dependency to make the Yojson installation lighter
  (@Leonidas-from-XIV, ocaml-community/yojson#175)
avsm pushed a commit to avsm/opam-repository that referenced this pull request Sep 5, 2024
CHANGES:

*2024-05-31*

### Added

- Added support for JSON5 (@dhilst, @gorm-issuu, @gertsonderby, ocaml-community/yojson#152)

### Removed

- Remove CPPO dependency to make the Yojson installation lighter
  (@Leonidas-from-XIV, ocaml-community/yojson#175)
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