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

melange: expose a mechanism to enable conditional compilation #7717

Closed
jchavarri opened this issue May 12, 2023 · 1 comment
Closed

melange: expose a mechanism to enable conditional compilation #7717

jchavarri opened this issue May 12, 2023 · 1 comment
Labels

Comments

@jchavarri
Copy link
Collaborator

Desired Behavior

While virtual libraries are a great mechanism to support conditional compilation, and Melange already supports them, sometimes it is useful to introduce branching at the module level.

For example, cppo allows to check for defined values to conditionally compile some code.

One could generate a cppo rule like:

(rule
 (targets foo.ml)
 (deps
  (:first-dep foo.cppo.ml))
 (action
  (run %{bin:cppo} -D MELANGE %{first-dep} -o %{targets})))

Some other analog rule would be defined for native, but without the -D MELANGE part.

Unfortunately at the moment, it is not possible to express from a dune file which rules are applied only for Melange targets, or only for OCaml targets.

A similar feature was added for foreign stubs in #5649.

cc @davesnx @anmonteiro

@anmonteiro
Copy link
Collaborator

I believe this has been superseded by #10222. Please reopen if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants