ocaml / ocaml/dune

Provide a way to call dune programatically

Open
#8,638 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

proposal
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Hey dune team,

I'm opening this issue to showcase a feature request that I came up on my usage of dune, but recently a user of one of my libraries made a clear good use-case and I didn't find any discussion online about it.

I would like to use dune as a library and call dune build/exec in my own executable/library which later can be released as a package. Why?

Allowing as a library will make authors provide better experiences for their users and could potentially do all sort of things.

Wrapping a cli

Dream could create a dream-cli which runs the eml rules on all eml files by default, or configure a folder templates where all files are compiled with dream-eml.

To give a little more context, while using Dream you need to add those rules into your dune file with certain degree of friction: https://aantron.github.io/dream/#templates, similarly happens with atd where .atd files need to be generated by an external program.

Allow any random use-case

Another possible benefit is to allow nasty hacks made by people who don't know the system well. This sounds a very bad idea but will enable more advanced users to workaround dune. This bypass of the manual rules or other methods, can release some pressure on dune development.

For example (for giving an example that I used) instead of having a menhir integration in dune you could tell menhir authors to say "no" to an integration and just use the dune programatically approach. (I'm not proposing to remove the menhir integration, but rather a future use-case)

Probably with manual rule creation most of this "features" are already available, but I have found that it's an intimidating part of the dune interface and often desired to be less boilerplat-y.

(cc @joprice)

Previous art

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing Dune's existing command-line and build-system interfaces; the issue does not name specific files, tests, or entry points. Compare the proposed library use with the esbuild and webpack APIs linked in the issue. Done means a concrete, maintainable programmatic interface is defined and its intended use cases and boundaries are documented.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.