Using an executable as library in dune

I’m building a project using dune and I’m facing the following situation. Essentially, my project depends on another project, not developed by me, from which I want to use some parts of the source code.

Here is more or less my project tree


The problem is that external-project has a dune file that builds it as an executable, instead of a library. Therefore, I cannot include it as a library in my dune file. Ideally, I don’t want to modify the dune file inside of external-project.

I’ve tried a series of combinations. Here is the current status of my dune file:

(dirs external-project)

 (name myexec)
 (libraries containers)
 (modules Myexec)
 (promote (until-clean) (into ".."))

(env (dev (flags (:standard -warn-error -A))))

Which allows me to compile external-project correctly, but then does not allow me to reference any of its files. I also tried (dirs external-project external-project/src) but to no success.

So, my question is: is there a way for me to reference external-project as a library, even though it is build as an executable?

Thanks for your help!

dune has a subdir stanza which allows to modify/add dune rules in a directory without to modify files there. I think it was made exactly for cases like yours, with vendoring that shouldn’t be edited.

Reference at Stanza Reference — Dune documentation