dune icon indicating copy to clipboard operation
dune copied to clipboard

dune exec for adverbial commands (time, afl, ...)

Open emillon opened this issue 5 years ago • 6 comments

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

emillon avatar Feb 20 '20 14:02 emillon

What about specifying which argument is the command via an argument? For instance:

dune exec --prog-at 1 time ./x.exe

ghost avatar Feb 20 '20 16:02 ghost

maybe a different command, as it is done in esy?

x Execute command as if the package is installed

Khady avatar Feb 21 '20 05:02 Khady

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.

bobot avatar Feb 24 '20 11:02 bobot

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.

emillon avatar Feb 24 '20 12:02 emillon

Would dune build @all && dune exec works for you? So does a generic dune exec -b @all ... would be okay?

bobot avatar Feb 24 '20 12:02 bobot

Duplicate of #2691

emillon avatar Aug 01 '22 12:08 emillon