Does dune support user-defined variables?

Like makefile, we can define custom variables.
But I didn’t find out how to do so in dune file.
Does anyone know whether dune support this?

Dune rules can depend on environment variables.

  • (env_var <var>) depends on the value of the environment variable <var>. If this variable becomes set, becomes unset, or changes value, the target will be rebuilt.

https://dune.readthedocs.io/en/stable/concepts/dependency-spec.html

It doesn’t cover all cases but maybe that’s enough for you.

1 Like

The short answer is “no”. However, you can often replace variables with files generated with (rule).

Cheers,
Nicolas

1 Like

Thanks for your help.