On Fri, Dec 09, 2016 at 10:20:36AM +0100, Pino Toscano wrote:
On Thursday, 8 December 2016 10:36:45 CET Richard W.M. Jones wrote:
For a very long time we have maintained two sets of utility functions, in mllib/common_utils.ml and generator/utils.ml. This changes things so that the same set of utility functions can be shared with both directories.
It's not possible to use common_utils.ml directly in the generator because it provides several functions that use modules outside the OCaml stdlib. Therefore we add some lightweight post-processing which extracts the functions using only the stdlib:
(*<stdlib>*) ... (*</stdlib>*)
One idea here: instead of using a custom <stdlib> markup and sed code for it, what about using the standard C preprocessor for this? I.e. have comments like:
(* #ifdef STDLIB *) ... (* #endif *)
and using cpp -DSTDLIB ... to output that.
Actually I think this doesn't work because you end up with broken comments. I can't think of a good way around that at the moment. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html