dune exec for adverbial commands (time, afl, ...)
Hi,
dune exec can be used to build an executable and run it, with optional arguments. But it's not possible to execute in a way where it's not the main command.
For example there is no way to say build x.exe and run time ./x.exe or afl-fuzz ./x.exe @@ (I've heard the term adverbial commands because time or afl-fuzz describe "how" ./x.exe is executed).
The feature itself looks straightforward but the concrete syntax is not. Let me suggest the following:
dune exec time ./x.exe(we scan all arguments and look for things that look like executables)dune exec time %{bin:./x.exe}(we reuse the pform from dune files)
A workaround is to define an alias with a custom action based on (run), but this does not work for interactive use.
Thanks!
cc @let-def
What about specifying which argument is the command via an argument? For instance:
dune exec --prog-at 1 time ./x.exe
maybe a different command, as it is done in esy?
x Execute command as if the package is installed
I agree with @Khady more generally many more things than just the binary are needed. So If you want dune exec to keep up to date the local installation something like: dune exec -p pkg1 -p pkg2 ... which will be the same than (deps (package pkg1) (package pkg2)) in rule is needed. Perhaps dune exec -P for building all the packages.
I think that's useful but it seems that it's a slightly different feature. In my use case, the executables are not public for example.
Would dune build @all && dune exec works for you? So does a generic dune exec -b @all ... would be okay?
Duplicate of #2691