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

Add an option to enable libraries on specific contexts based on the modes field #10362

Open
jchavarri opened this issue Apr 2, 2024 · 0 comments
Labels

Comments

@jchavarri
Copy link
Collaborator

In a project with both native and Melange libraries, one might want to keep the former in default context, and move all Melange libraries to a different context melange, so that library name collisions can be avoided (see related issue #10222).

To do this, Dune currently requires going through all libraries that include (modes melange), and add (enabled_if (= %{context_name} "melange")).

Besides that, if one wants to properly separate namespaces, all existing OCaml libraries should be annotated with the equivalent (enabled_if (= %{context_name} "default")).

This is quite noisy for projects with tens or hundreds of libraries. Besides, the enabled_if conditions are mostly redundant with the information already available in the library modes field.

I wonder if there could be some setting in such scenarios where a single addition to the dune-project or dune-workspace file could include the (= %{context_name} "xxx") condition to each library, depending on its mode, e.g.:

  • If the library has (modes melange): adds (enabled_if (= %{context_name} "melange"))
  • If the library doesn't have (modes melange): adds (enabled_if (= %{context_name} "default"))
  • If the library has (modes :standard melange): doesn't add any condition (library is available in both contexts)

This setting could be activated through a new stanza (melange_use_mode_as_context true).

cc @anmonteiro @davesnx @andreypopp

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

1 participant