[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: producing more than one target? (was: prerequisites of targets are n

From: Alessandro Vesely
Subject: Re: producing more than one target? (was: prerequisites of targets are not made?|?]
Date: Mon, 06 Dec 2004 20:01:34 +0100

"Paul D. Smith" wrote:
>   av> Is there a generic mechanism for simultaneously producing more
>   av> than one target?
> There's a trick you can use, like this:
>     foo: real.1
>     bar: real.2
>     real.1 real.2: .dummy
>     .dummy:
>             <Rule to create real.1 & real.2>
>             @touch $@

Hmmm... perhaps I haven't got it right, but I haven't been able to use that
because in the rule I miss dependencies (sources) for building real.%.
> There was a proposal for a new kind of explicit rule syntax that allowed
> you to define a rule as creating multiple targets at once.  It hasn't
> been implemented though.

I only found "Java compilation: I don't like Ant"

That thread finished off examining ways to optimize compile time by
collecting all sources in an attempt to reduce the number of compiler
calls. In facts, invoking javac involves setting up a virtual machine.
IMHO that's a compiler performance issue that doesn't pertain here.

About syntax, symmetry between pattern and explicit rules is already
broken by the different meaning of : a.y

and : %.y

So I would propose %: a.y

for saying that a rule is meant "in the pattern rule sense".
Note that you need a white space before the `%:'.

I would then describe a dependency tree like so:

   dummy.u : source1
   comp1 dummy.u %:

where the two targets dummy.u and comp1 are created simultaneously.
In case of multiple mutually dependent sources, the one liner

   comp1 comp2 dummy.u %: source1 source2

could be equivalently expressed as either

   dummy.u : source1 source2
   comp1 dummy.u %:
   comp2 dummy.u %:

or, e.g.,

   dummy.u %: source1
   dummy.u : source2
   comp1 comp2 dummy.u %:

Thus, `%:' might replace `:' in any explicit rule having only one target.

I'd need no dummy.u if the "multiple simultaneous explicit targets" (MSET)
were implemented. Any pattern rule, either `%.u:' or `comp% :', can fire
and make all the targets at once.

Dependencies need to work as usual, e.g. given another set of mutually
dependent sources

   another.u comp3 comp4 %: source3 source4

a rule like

   comp3 : comp2

implies that the first set of targets must build before the second one.
-Recall that a Java .class file acts both as object code (.o) and included
header (.h) ("imported class", in Java parlance), much like always using the
"generate headers" option that some C compilers have.

Without MSET the above can be done as

   dummy.u : source1 source2
   comp1 : dummy.u
   comp2 : dummy.u
   another.u : source3 source4
   comp3 : another.u
   comp4 : another.u
   another.u : comp2

which works unreliably.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]