janestreet/base

Use `write-file` instead of `bash` in dune action

Closed this issue · 1 comments

Summary

Is it possible to use write-file action instead of bash?

base/src/dune

Lines 29 to 30 in 448ea48

(rule (targets ocamlopt-flags) (deps)
(action (bash "echo '()' > ocamlopt-flags")))

--- a/src/dune
+++ b/src/dune
@@ -27,4 +27,4 @@
 (documentation)
 
 (rule (targets ocamlopt-flags) (deps)
- (action (bash "echo '()' > ocamlopt-flags")))
\ No newline at end of file
+ (action (write-file ocamlopt-flags "()")))

Additional

If write-file is not feasible, perhaps run sh can be used instead?

--- a/src/dune
+++ b/src/dune
@@ -27,4 +27,4 @@
 (documentation)
 
 (rule (targets ocamlopt-flags) (deps)
- (action (bash "echo '()' > ocamlopt-flags")))
\ No newline at end of file
+ (action (run sh "echo '()' > ocamlopt-flags")))

Hi! Our dune build rules are auto-generated from our internal jenga build-rules, and it's unlikely we'll support non-bash actions there. We can manually override some of those to use non-bash actions, but we generally only do so for Windows support. Thanks for your contribution nonetheless!