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: allow to define copying assets rules from the libraries #7013

Closed
jchavarri opened this issue Feb 6, 2023 · 4 comments
Closed

melange: allow to define copying assets rules from the libraries #7013

jchavarri opened this issue Feb 6, 2023 · 4 comments
Labels

Comments

@jchavarri
Copy link
Collaborator

jchavarri commented Feb 6, 2023

A potentially common scenario is having multiple melange.emit stanzas in the same dune project, where these emit stanzas consume the same libraries.

Currently, the dependencies on assets inside the library have to be defined using the emit alias, e.g. if a library foo depends on some asset bar.svg, the dune config will look something like:

(melange.emit
 (target output)
 (alias mel)
 (module_system commonjs))

(copy_files
 (alias mel)
 (files bar.svg))

The issue with this approach is that in a scenario like mentioned above, where there can be multiple usages of a given library by multiple emit stanzas, so users will need to write the copy_files rules for the library file N times unnecessarily.

One solution could be to define the dependency on the assets at the library level, e.g.:

(library
 (modes
  (mode
   (name melange)
   (assets bar.svg))))
@jchavarri
Copy link
Collaborator Author

I am not a big fan of the proposed solution with library.mode.assets. If this use case is generalizable to any library mode —not only melange, but also byte and native—, then it might be preferable to just add a new field runtime_deps inside the library stanza?

@rgrinberg
Copy link
Member

I would suggest a melange.runtime_deps field. I'm not sure how this field would be used outside of melange so a general runtime_deps field is premature. Sticking it into modes also isn't the style of how dune does things.

@jchavarri
Copy link
Collaborator Author

it turns out, I had already started looking into implementing this #6643. I just updated the PR and asked a question to understand how to proceed next in https://github.com/ocaml/dune/pull/6643/files#r1098380524.

@anmonteiro
Copy link
Collaborator

This was done in #7234

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

3 participants