Open
Description
Usecase
(* Assume this exists *)
module Gen : sig
val v : ?doc:string -> ?meta:B0_meta.t -> prog:B0_unit.t -> Fpath.t -> B0_unit.t
val file : u : B0_srscs.sel
end
(* Compile this with Metaocaml. A metaocaml program that prints out regular ocaml code *)
let meta_gen = B0_ocaml.exe "meta_gen" ~srcs:[ `File (Fpath.v "some/source/file.ml")]
let gen_file = Gen.v ~prog:meta_gen Fpath.(v "gen_file.ml")
(* Compile this with normal Ocaml *)
let mylib = B0_ocaml.libname "mylib"
let mylib_lib = B0_ocaml.lib mylib ~srcs:[ Gen.file gen_file ]
Implementation
Based on my current understanding of how things work, this could be implemented in a few ways:
- Add an
~env
argument toB0_ocaml.{lib,exe}
They would then be responsible for passing those along to the tool spawns. The type should probably be something like(B0_build.t -> string String.Map.t)
so that a tool spawn can generate the environment, such as a call toopam env
- Add an
env
key to the meta that gets passed to B0_ocaml.lib and B0_ocaml.exe. Again,B0_ocaml.{lib,exe}
would be responsible for looking up that value and passing it to the tool spaws - Add a wrapper around
B0_unit.t
to build that unit with a set of env vars. I'm not entirely clear how or if this would work, I need to look more that the unit definition/registration code. - Probably some mechanism with B00_ocaml. From what I can tell, its only possible to mess with the environment from inside a
(B0_build.t -> ...)
, and theres no mechanism to do that with the high levelB0_ocaml.{lib,exe}
Or this is already possible and I completely missed it.
If you like any of these I could take a stab at implementing and submitting a pr.
Metadata
Metadata
Assignees
Labels
No labels