cons-discuss
[Top][All Lists]
Advanced

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

Dependency flaw in cons (and scons) ?


From: Johan Holmberg
Subject: Dependency flaw in cons (and scons) ?
Date: Thu, 21 Feb 2002 23:54:35 +0100 (MET)

Hi !

Sometimes I try to imagine how an ideal "make-like" tool should
behave. We all know that "make" has several flaws in its dependency
analysis. But Cons is said to "do the right thing", and I have come
to rely on it (it's a comfortable feeling :-).

But today when I thought about how rules with multiple targets
ought to be handled, it suddenly struck my mind that maybe Cons
fails to do the right thing in at least one case. I opened my Emacs
and typed the following Construct file:

      #---------------------------------------
      $e = cons->new();

      $e->Command( ['xxx', 'yyy'], 'aaa',
                   "/usr/bin/echo xxx-content > xxx\n".
                   "/usr/bin/echo yyy-content > yyy\n" );

      $e->Command('zzz', 'yyy', "/usr/bin/cp %< %>");
      #---------------------------------------

When I use this Construct file I get:

      $ cons zzz
      /usr/bin/echo xxx-content > xxx
      /usr/bin/echo yyy-content > yyy
      /usr/bin/cp yyy zzz
      $ cat zzz
      yyy-content

OK so far.
But now suppose I change my mind and want 'zzz' to be made from
'xxx' instead of from 'yyy'. So I change the last 'Command' in the
Construct file to:

      $e->Command('zzz', 'xxx', "/usr/bin/cp %< %>");

and rerun cons:

      $ cons zzz
      cons: "zzz" is up-to-date.
      $ cat zzz
      yyy-content

Quite weird, isn't it ???

Just out of curiosity, I also wrote a similar "SConstruct" for
SCons, and got the same (as I think) erroneous behaviour
(this was my first attempt to use SCons, so I'm not 100% sure that I
used it the right way; but it at least seems to behave exactly as
Cons in this case).

Even before this incident, I have considered the way Cons handles
rules with multiple targets, as rather "cludgy". So I was a bit
surprised to see that SCons works the same way (as it appears to me
at least).

It would be interesting to hear what others think about this.
Is it a flaw ?
And how should it work instead ?
And implemented how ?

/Johan Holmberg





reply via email to

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