[build2] Generating source code in build2 projects
Boris Kolpackov
boris at codesynthesis.com
Fri Jul 31 04:42:09 UTC 2020
Bruce Sutherland <bsutherland at soundhound.com> writes:
> So I assume we need to configure blubc as a tool in build2, and define
> dependencies from .blub to .cpp and .h files.
>
> How should we do that with build2? The documentation mentions
> generated source code, but doesn't go into much detail. Can anyone
> point me to an example of a project with a similar configuration?
Currently there are two way to do this: you can provide a rule for
compiling any .blub to .h/.cpp or you can provide an ad hoc recipe
for compiling a specific foo.blub to foo.h/foo.cpp.
To provide a rule, currently, you will have to write a build system
module that implements it (see, for example, libbuild2-rust[1]). In
the next release we are also planning to add support for ad hoc rules
that can be written directly in buildfiles (similar to ad hoc recipes
below).
An ad hoc recipe you can write directly in the buildfile and I would
suggest that you start with that since writing a rule/module is fairly
involved. The release notes for 0.13.0[2] have a number of examples
that should get you started (in particular, see the xxd example).
There is also a NASM example[3] I posted a few days ago that shows
how to define a custom target type (e.g., for .blub).
Note also that this is still an area of active development so there
might be rough edges, missing pieces, etc. So we are quite interested
in usage feedback and also don't mind doing a bit of hand-holding. So
let me know how it goes or if there are any issues. In particular, if
you have a lot of .blub, then writing ad hoc recipes could get tedious
and that's where support for ad hoc rules could be helpful.
[1] https://github.com/build2/libbuild2-rust
[2] https://build2.org/release/0.13.0.xhtml#adhoc-recipe
[3] https://lists.build2.org/archives/users/2020-July/000823.html
More information about the users
mailing list