samoht / assemblage

A collection of tools to manage the configuration of OCaml projects
54 stars 4 forks source link

generating code #121

Closed smondet closed 9 years ago

smondet commented 9 years ago

Hi

I was trying to make assemblage generate a file info.ml with the version number (and maybe other things later) at build time (for atd2cconv).

I don't manage to get it right, I've tried a bunch of variants of this (that type-check but fail at setup or make time):

let version = "0.0.1-beta"

let info_module =
  let name = "atd2cconv_info" in
  unit name
    (other name
       [
         Action.rule
           ~phase:`Prepare
           ~targets:[`N (unit name (`Path ["src/lib"]), `Ml)]
           (* ~targets:[`Self  `Ml] *)
           ~prereqs:[]
           (fun a resolver flags ->
              let build_dir = Resolver.build_dir resolver in
              Action.create
                ~dir:build_dir
                "echo 'let version = %S' > atd2cconv_info.ml"
                version);
       ]
    )

let lib_atd2cconv =
  lib "atd2cconv"
    ~deps:[pkg "atd"; pkg "nonstd"; pkg "smart_print" ]
    (`Units [
        info_module;
        unit "atd2cconv" (`Path ["src/lib"]);
      ])

any help on that common pattern?

dbuenzli commented 9 years ago

This API no longer exists.