[build2] Yacc module?

Boris Kolpackov boris at codesynthesis.com
Wed Sep 4 14:29:02 UTC 2019

Joachim Kuebart <joachim.kuebart at gmail.com> writes:

> I've started with the yacc module[0], but I'm not claiming to really
> understand what I'm doing yet ;-). I'm currently stuck where none of
> my compile_rule's methods are being called by the test even though I
> added y{**} and a corresponding file.. will need to look into that
> later.

I took a look and the problem is actually in your test's buildfile:

exe{basics}: {hxx ixx txx cxx}{**} y{**} $libs

While the .y dependency is there, the link rule doesn't recognize
and thus match it. If however, I add this before:

./: y{**}

I get:

trace: yacc::compile_rule::match: match((2,2), .../libbuild2-yacc/libbuild2-yacc-tests/basics/y{hello.y})
trace: yacc::compile_rule::apply: apply((2,2), .../libbuild2-yacc/libbuild2-yacc-tests/basics/y{hello.y})

This does the trick because the alias rule (the `./` target is an alias)
matches all of the target's prerequisites.

> That works of course, I was thinking whether there would be a way of
> automatically adding that whenever a .y file is an (indirect)
> dependency. But perhaps too much automation is not such a good idea
> either.

Yes, we haven't done anything like this before and while it could be
possible, it's probably best to start with explicit linking and
wait for more clarity.

> On the "yacc" branch [1], I have included a OpenBSD's yacc which has
> no dependencies except for one OpenBSD library function which I also
> included. I haven't looked at libyacc yet though. If we were to go
> down the route of including yacc, I think it should be installed
> somewhere out of the user's path (i.e. libexec/) and called directly.

I am not sure we would normally even want to install it. It can just
be used from its build directory.

> The advantage would be that it would work and work the same on all
> platforms. The disadvantage would be that it wouldn't use the user's
> own yacc/bison/... in case they wanted to use some special features.

We can always leave it up to the user to decide whether they want to
use the same yacc (and which one) everywhere.

More information about the users mailing list