janestreet / base

Standard library for OCaml
MIT License
848 stars 124 forks source link

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

Closed vitoyucepi closed 11 months ago

vitoyucepi commented 11 months ago

Summary

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

https://github.com/janestreet/base/blob/448ea48a6a9f1d6f84cdfcf8d6dabcde724417db/src/dune#L29-L30

--- 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")))
dkalinichenko-js commented 11 months ago

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!