dc0a6d4401 | ||
---|---|---|
.. | ||
src | ||
.gitignore | ||
README.org | ||
config.defaults | ||
config_common.ml | ||
configure | ||
dune | ||
myproject.opam | ||
real_configure.ml | ||
run.t |
README.org
This project shows how to add a configure step to a project using jbuilder.
In order to keep things composable, it offers several way to configure the project:
- with the classic
./configure <args...>
. When doing this, the configuration script are run immediately and the resulting configuration is frozen for the rest of the build - by copying
config.defaults
toconfig
and editing it. The configuration scripts will be run as part of the build using what is written inconfig
. Whenconfig
is edited, the configuration scripts will be automatically re-run - by doing nothing. The configuration scripts will be run as part of the build
using the default values provided in
config.defaults
Technically this is how it works:
configure
is a simple OCaml script that:
- parses the command line
- generates a
config
file using what was given on the command line - calls
ocaml real_configure.ml
real_configure.ml
does some stuff and generatesconfig.full
config.full
is what is used by the rest of the build.
Now in order to support (2) and (3), we setup the following rules in
the toplevel jbuild
:
- a rule to produce
config
by copyingconfig.default
- a rule to produce
config.full
by runningreal_configure.ml
The reason it all work as described is because if Jbuilder knows how to build a file and this file is already present in the source tree, it will always prefer the file that's already there