ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.63k stars 406 forks source link

feature-wish: `#! /usr/bin/env dune-run` #1884

Open smondet opened 5 years ago

smondet commented 5 years ago

Something to build executables in $TMPDIR and run them which could look like:

#! /usr/bin/env dune-run
#! dune-run --libraries cmdliner,base

let () = print_string "Hello world\n"

(the second-line of #! is what nix-shell does also http://chriswarbo.net/projects/nixos/nix_shell_shebangs.html )

ghost commented 5 years ago

Why not, but we might as well use the same syntax as dune files rather than invent something new:

#! /usr/bin/env dune run
#! (libraries cmdliner base) (preprocess (pps ppx_sexp_conv)) ...

...

We should also compile that in the xdg cache dir, to avoid recompiling it on every run. For instance in ~/.cache/dune/scripts/<hash-of-file-contents>/.