dune/example/sample-projects/with-configure-step
Jérémie Dimino 6bed864057 Better behavior when the targets of a rule already exist in the source tree (#218)
Warn when a file is both present in the source tree and generated by
a rule. Before, jbuilder would silently ignore the rule. One now has
to add a field `(fallback)` to custom rules to keep the current
behavior.
2017-08-15 11:16:11 +01:00
..
src Added an example with a configure step 2017-03-21 15:49:10 +00:00
.gitignore Added a .gitignore 2017-03-21 15:49:38 +00:00
README.org fix typo 2017-06-09 08:52:21 +01:00
config.defaults Added an example with a configure step 2017-03-21 15:49:10 +00:00
config_common.ml Added an example with a configure step 2017-03-21 15:49:10 +00:00
configure Added an example with a configure step 2017-03-21 15:49:10 +00:00
jbuild Better behavior when the targets of a rule already exist in the source tree (#218) 2017-08-15 11:16:11 +01:00
myproject.opam Added an example with a configure step 2017-03-21 15:49:10 +00:00
real_configure.ml Added an example with a configure step 2017-03-21 15:49:10 +00:00
run.t Switch examples testing to cram 2017-08-11 11:36:33 +01:00

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:

  1. 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
  2. by copying config.defaults to config and editing it. The configuration scripts will be run as part of the build using what is written in config. When config is edited, the configuration scripts will be automatically re-run
  3. 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 generates config.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 copying config.default
  • a rule to produce config.full by running real_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