Have dune produce the .exe in the directory where the (executable ...) directive appears?

When dune runs it keeps things nice and tidy by putting build artifacts in the _build directory. Probably the biggest obstacle when converting a codebase from, say, omake, is that omake puts executables in the current directory and you may have workflows that depend on this.

Is there an easy recipe to have dune generate symlinks to executables that it builds and stick them in the directory that the (executable ...) stanza appears in?

1 Like

I agree, I’ve been doing these symlinks by hand for a while now.

I’m no dune wizard but I think that you can add the following stanza in your dune file:

(rule
 (copy foo.exe foo))

and it will make it so that the executable that dune names foo.exe will then be copied under the name foo in your source tree (probably in the same directory as the dune file where the stanza is I’d guess) when you ask dune to build foo. You can then even create rules that depend on foo(rather than foo.exe). It might need dune>=2 .

See promote option of executable stanza.

Best regards

2 Likes

Wow, I read through the list of options for executable twice and didn’t parse that that’s what promote did.

Totally works. Thanks!

have a look for “promote” in the manual.