Re: Value/Alias Nodes default to up-to-date

Brad Kraemer <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <DS7PR10MB5055CE9EAF2C387F0F7FEF03F7499@DS7PR10MB5055.namprd10.prod.outlook.com>
Simply that I can use the Node returned by Alias() in places where a 
Node is expected (for instance in the example I've given Depends(t1, a1))..

Now you may ask why wouldn't I use Command(), since that it's defined 
purpose? In this case I wanted the special property of Alias Node's 
(they exist in their own namespace, outside the standard FS namespace). 
Well why would I need this target to exist outside the standard FS 
namespace? Simply because I have some internal Action's that I want to 
run (in the process of building) that are not specific to any target 
(that the user can specify). i.e. $ scons / , or $ scons . is not going 
to pick up these Alias Node targets (and thats exactly what I want).


My reasons for wanting this are more abstract at this point (as I said 
I'm experimenting around the limitations of SCons). But to save some 
time here, I'm literally looking for a Yes or No answer, with regards to 
the Alias/Value node's up-to-date behavior.

Specifically, check the file: /SCons/Node/__init__.py:1520

  def children_are_up_to_date(self):
      """Alternate check for whether the Node is current:  If all of
      our children were up-to-date, then this Node was up-to-date, too.
      The SCons.Node.Alias and SCons.Node.Python.Value subclasses
      rebind their current() method to this method."""
      # Allow the children to calculate their signatures.
      self.binfo = self.get_binfo()
      if self.always_build:
          return None
      state = 0
      for kid in self.children(None):
          s = kid.get_state()
          if s and (not state or s > state):
              state = s
      return (state == 0 or state == SCons.Node.up_to_date)


*Both Value/Alias Node's use this method to cite there up-to-date state. 
As written, with either no children or children with unchanging states a 
Value/Alias will always be considered up-to-date (i.e. it is considered 
built/up-to-date directly after creation). Is this correct?


If this behavior is correct what is the purpose of the 'built_value' 
business on Value Node's? I don't fully grasp how Value Node's are meant 
to work in the standard case...


On 2022-01-02 8:05 p.m., Bill Deegan wrote:
> Still don't really understand what you're trying to do.
>
> What do you mean by this "allowing me to make Action()'s with 
> dependency orderings"?
>
> On Sun, Jan 2, 2022 at 3:10 PM Brad Kraemer 
> <[email protected]> wrote:
>
>     * Fixed subject line (the original line from the mailer daemon
>     added JUNK, as this one doesn't allow unconfirmed posters, i.e. I
>     should have waited for the mailing-list confirmation before
>     sending the first e-mail off)
>
>
>     Currently, just experimenting with some SCons features. At this
>     time I was creating an Alias() because I wanted the Alias() object
>     (which is namespaced outside the regular FS namespace), allowing
>     me to make Action()'s with dependency orderings. While not having
>     these actions kicked off by running something like '$ scons /'
>     (which something like Command() would).
>
>
>     I realize this is outside the intended use of these functions.
>     However, the doc's don't forbid it so it's clean in my eyes.
>
>     The Command() part is just for something to depend on (can replace
>     it with Program() or any other builder, my issue is with the
>     Alias() lines).
>
>
>     Your reasoning makes sense, however, if my Alias is never out of
>     date (i.e. on creation it's meant to be considered already built),
>     why can I run AlwaysBuild() and thus force it to build (is this
>     the equivalent of rebuilding something already up-to-date)?
>
>     Just looking at the sources, it seems these Node's are meant to be
>     built at least once (however, Value() in particular does seem to
>     have a parameter to be considered built on creation). Or am I off
>     base with this?
>
>
>     On 2022-01-02 5:30 p.m., Bill Deegan wrote:
>>     Maybe you explain what you're trying to do, rather than how
>>     you're currently trying to do it?
>>     Because this looks like a mess of hard to understand code and
>>     there's very likely a better way to do this.
>>
>>     Those aliases would never be out of date with a static source.
>>     Your command has no source listed, so it will also never be out
>>     of date..(after the first time, if the file t1 was actually built)..
>>
>>     -Bill
>>
>>
>>     On Sun, Jan 2, 2022 at 2:20 PM Bill Deegan
>>     <[email protected]> wrote:
>>
>>         also why **JUNK** in subject?
>>
>>         On Sun, Jan 2, 2022 at 2:20 PM Bill Deegan
>>         <[email protected]> wrote:
>>
>>             What output do you see when you run your example?
>>
>>
>>             On Sun, Jan 2, 2022 at 7:56 AM Brad Kraemer
>>             <[email protected]> wrote:
>>
>>                 Hello,
>>
>>                 I filed a GitHub Issue
>>                 <https://github.com/SCons/scons/issues/4079> and got
>>                 bounced to this mailing list. So here we go again:
>>
>>                 Value/Alias nodes (as created by the Alias() and
>>                 Value() functions/methods receptively) default to
>>                 up-to-date.
>>
>>                 SCons 4.1.0
>>
>>                 Python 3.9
>>
>>                 Installed from nixpkgs (NixOS, $ nix-env -iA nixos.scons)
>>
>>                 Linux
>>
>>                 Reproduction (SConstruct):
>>
>>                 def print_target_1(target, source, env):
>>                     print("Target 1 built")
>>                   
>>                 def print_alias_1(target, source, env):
>>                     print("[I'm not getting called]")
>>                   
>>                 def print_alias_2(target, source, env):
>>                     print("I'm getting called because of AlwaysBuild() workaround")
>>                   
>>                 t1 = Command("t1", [], Action(print_target_1, cmdstr=None))
>>                 Default(t1)
>>                   
>>                 v = Value("_")
>>                 a1 = Alias("a1", v, Action(print_alias_1, cmdstr=None))
>>                 a2 = Alias("a2", v, Action(print_alias_2, cmdstr=None))
>>                 Depends(t1, a1)
>>                 Depends(t1, a2)
>>                   
>>                 AlwaysBuild(a2)
>>
>>
>>                 Invoke via executing '$ scons' from the directory
>>                 where the above SConstruct file exists.
>>
>>
>>                 Thanks,
>>
>>                 simplejack-src
>>
>>
>>                 _______________________________________________
>>                 Scons-users mailing list
>>                 [email protected]
>>                 https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>>
>>     _______________________________________________
>>     Scons-users mailing list
>>     [email protected]
>>     https://pairlist4.pair.net/mailman/listinfo/scons-users
>     _______________________________________________
>     Scons-users mailing list
>     [email protected]
>     https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
> _______________________________________________
> Scons-users mailing list
> [email protected]
> https://pairlist4.pair.net/mailman/listinfo/scons-users

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.