Automatically add opam dependencies to dune-project file
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
In a dune project, automatically infer opam dependencies and add them to the dune-project file. This will save users from the drudge work of having to write these dependency lists in two different files since dune can just infer one of them.
Opam dependencies may be inferred by looking at the contents of the (libraries ...) field in dune files. Dune can then add these libraries into the (depends ...) field of the (package ...) stanza of the dune-project file. Ideally, with properly set version bounds, but to start with, it should be acceptable to add only the library names.
How to know which dependencies are opam libraries? Process of elimination. There's a limited set of libraries shipped with the OCaml distribution: str, unix, etc. We can eliminate those as coming from opam. Another set of libraries are defined in the project itself. We can eliminate those. The ones that are left over must then be from opam.
How to decide which (package ...) of the dune-project file to add the library dependencies into? The same way dune knows which library is in which package right now–using the (public_name ...) and (package ...) fields.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how dune currently reads (libraries ...) fields and associates libraries with packages through (public_name ...) and (package ...). Then inspect how dune-project package stanzas represent (depends ...). Done means dependencies are inferred while excluding OCaml-distributed and project-defined libraries, and the appropriate package stanza receives the remaining library names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100