I have two questions regarding dune build flags.
what are the default (standard) flags for ocamlopt, ocamlc, js_of_ocaml
and
how to set default flags for the entire project (i.e. one containing many libs and exes)
As far as I understand I need a dune file in the root with the env stanza, something like
(env
(release
(ocamlopt_flags (:standard -O3 -unbox-closures))))
How to add js_of_ocaml flags to it?
The default depend on the build profile and are hard-coded in dune. You can find out the set of active flags for a given directory by running dune printenv
. If you have no special configuration, this will give you the set of default flags:
$ dune printenv .
(
(flags
(-w
@a-4-29-40-41-42-44-45-48-58-59-60-40
-strict-sequence
-strict-formats
-short-paths
-keep-locs))
(ocamlc_flags (-g))
(ocamlopt_flags (-g))
)
$ dune printenv --profile release .
(
(flags (-w -40))
(ocamlc_flags (-g))
(ocamlopt_flags (-g))
)
To set the flags globally, you should indeed write an env
stanza as you mentioned.
jsoo flags are currently not covered by this mechanism, but they indeed should. Do you mind opening an issue on the dune github project to track this feature?
2 Likes
I think it’s reported already, is it the same issue?
opened 06:50PM - 05 Dec 18 UTC
closed 01:56AM - 09 Nov 21 UTC
jsoo
I want to use different js_of_ocaml flags in my project, depending on whether we… are in dev or release profile.
Dune [already adds](https://github.com/ocaml/dune/blob/55531596991f0f2d3b60f24183ea0eb3f80c2fd6/src/js_of_ocaml_rules.ml#L12) `--pretty` and `--source-maps-inline` in dev, however, there are more jsoo options to play with, and I get dramatically better debugging with the [recommended settings](https://ocsigen.org/js_of_ocaml/dev/manual/options):
```
For Debugging: "–pretty –no-inline –debug-info" + eventually "–disable staticeval –disable share"
For Production: "–opt 3". It minimize the generated javascript by applying various optimizations until a fix-point is reached
```
I tried using an `env` block, but couldn't make it work any way I tried it. Is there an existing way to do this, and if not:
- can a way to do this be added?
- can we pick better defaults for the dev and production env?