[Omake] implicit rules with more than one wildcard

Aleksey Nogin nogin at cs.caltech.edu
Mon Jul 3 12:11:26 PDT 2006


On 03.07.2006 11:49, Ted Sandler wrote:

> Does OMake have a way of parameterizing targets on more than 
> one argument?  Here's an example of what I have in mind:
> 
>   %_vs_%.out: $1.foo $2.bar
>     cat $1.foo $2.bar > $1_vs_$2.out

No, this is not currently supported. It should be possible to add 
something like this to OMake (and my guess is that it would be 
reasonable straightforward to do so), but so far we never had a need for it.

> If not, are there work arounds? 

There are a number of options. One of them is to use the so-called 
"active rules" where the body of the rule can be computed.

For example,

%.out:
    section rule
       match %
       case $'(.*)_vs(.*).out'
          $1_vs_$2.out: $1.foo $2.bar
             cat $+ > $@

The main difference between the "true" parameterized ("implicit") rule 
and what I wrote here is that this rule will be selected for all the 
.out files, regardless of whether it has a "_vs_" in it and whether 
$1.foo with $2.bar are buildable or not.

Of course, if you know in advance all the possible values for $1 and $2, 
you can just write something like

foreach(f1, ab cd ef)
    foreach(f2, gh ij kl)
       $(f1)_vs_$(f2): $(f1).foo $(f2).bar
          cat $+ > $@

Hope this helps.

-- 
Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin at cs.caltech.edu (office), aleksey at nogin.org (personal)
Office: Moore 04, tel: (626) 395-2200


More information about the Omake mailing list