Dune: How to add a dependency on one executable to another?

Hi everyone.

I have a Dune project consisting of two executables, each defined with the executable stanza in their own subdirectories.

One of the executables uses the Bos library to invoke the other executable; it’s a “driver” of that executable.

Suppose the first exectuable is called emit and the second executable is called package.

I’d like to ensure that emit has been been built by Dune before I try to invoke it with package (otherwise, I might get a “file not found” error, or changes to emit might not be visible when I invoke package).

As far as I can tell, I cannot add arbitrary dependencies to the executable stanza of Dune.

Is there a solution? Perhaps I’m going about this the wrong way?

Perhaps you can define a rule with both executables as dependencies to do what you want?

Best wishes,
Nicolás

Another option is to extract the needed functionality from emit into a library, and then call out to the library using package.

See https://github.com/ocaml/dune/issues/3499 (Allow dependencies for executables).

The work-around I use is to copy the executable and then install the copy. The copying rule adds the dependency. e.g.

Thank you for the GitHub link and for reporting it! It describes the issue exactly. I’ll take a look at the workaround in the mean time.