[Omake] Wildcards in functions used within dependencies
Aleksey Nogin
anogin at hrl.com
Fri Aug 31 17:03:13 PDT 2007
On 26.08.2007 06:39, John Billings wrote:
> Hello,
>
> I'd like to specify a rule of the form:
>
> %.done: $(CProgram %, %)
> ./$< && touch $@
>
> The problem is that the `%' does not appear to be recognised as a
> wildcard within the CProgram function call; it's interpreted as the
> literal value `%', and hence compilation fails with:
>
> Do not know how to build "%.o" required for "%"
John,
Sorry for taking so long to respond. There are two issues here.
First, there is an issue of the evaluation order - the dependencies in
the implicit ("pattern") rules are evaluated when the _implicit_ rule is
created, not when the rule is instantiated. So in the code you use, the
"$(CProgram %, %)" will be called as soon as the rule is encountered, so
you get a rule for building the program "%" out of "%.o" and an implicit
rule
%.done: "%"
...
where the second "%" is taken literally. So the error message you get is
expected and "natural".
You can change the evaluation order by using the "section rule" construct:
%.done:
section rule
%.done: $(CProgram %, %)
./$< && touch $@
One you do that, unfortunately you'd hit the second issue - currently,
OMake does not allow new rules to be created once the OMakefiles are
read and the build phase starts (the only exceptions are instantiations
of implicit rules). Because of that, in the code above the rules created
by the CProgram function will be ignored and running "omake foo.done"
will get you "Don not know how to build foo" error. Contrary to the
first issue, I do not think that this is "natural" - it was simply an
implementation choice not to allow new rules during the build phase and
I do not thing there is any good reason for that semantics.
I've filed an RFE http://bugzilla.metaprl.org/show_bug.cgi?id=691 where
I argue that creating arbitrary new rules in "section rule" should be
allowed.
Aleksey
--
Aleksey Nogin, Research Scientist
Advanced Technologies Department, Information & System Sciences Lab
HRL Laboratories, LLC, Malibu, CA
More information about the Omake
mailing list