[Scons-users] How to tell if a node is an explicit command-line argument?

William Blevins wblevins001 at gmail.com
Sun Jul 26 21:57:49 EDT 2015


I can make a full patch if I can find a smarter way to see if a node "was
explicitly" called on the command-line.  The rest of the patch is pretty
straight-forward, but I think this would be a big help for packagers.

-Will

On Sun, Jul 26, 2015 at 9:46 PM, Gary Oberbrunner <garyo at oberbrunner.com>
wrote:

> Sure, this seems very helpful!
>
> On Sun, Jul 26, 2015 at 9:37 PM, William Blevins <wblevins001 at gmail.com>
> wrote:
>
>> Does this interest anyone?  I think it could be a very convenient debug
>> mechanism because environment information queries currently require scripts
>> modifications.
>>
>> V/R,
>> William
>>
>> On Sat, Jul 25, 2015 at 4:23 PM, William Blevins <wblevins001 at gmail.com>
>> wrote:
>>
>>> Bill,
>>>
>>> Long story short, I was investigating making a new debug option.  The
>>> option would perform print env.Dump() for a node's builder environment, but
>>> I wanted to print on for explicit targets.
>>>
>>> Here is a working patch delta, but my check seems a bit sketchy.
>>>
>>> diff -r e6d4edfedcb4 src/engine/SCons/Node/__init__.py
>>> --- a/src/engine/SCons/Node/__init__.py    Mon Jun 29 07:04:53 2015 -0400
>>> +++ b/src/engine/SCons/Node/__init__.py    Mon Jun 29 10:54:02 2015 -0400
>>> @@ -1141,6 +1141,12 @@
>>>          the command interpreter literally."""
>>>          return 1
>>>
>>> +    def generate_dump(self):
>>> +        env = self.get_build_env()
>>> +        if env:
>>> +            return env.Dump()
>>> +        return None
>>> +
>>>      def render_include_tree(self):
>>>          """
>>>          Return a text representation, suitable for displaying to the
>>> diff -r e6d4edfedcb4 src/engine/SCons/Script/Main.py
>>> --- a/src/engine/SCons/Script/Main.py    Mon Jun 29 07:04:53 2015 -0400
>>> +++ b/src/engine/SCons/Script/Main.py    Mon Jun 29 10:54:02 2015 -0400
>>> @@ -300,6 +300,13 @@
>>>                  if tree:
>>>                      print
>>>                      print tree
>>> +
>>> +        if self.options.debug_dump:
>>> +            t = self.targets[0]
>>> +            if t.get_path() in SCons.Script.COMMAND_LINE_TARGETS:
>>> +                print 'Environment dump for node: ' + str(t)
>>> +                print t.generate_dump()
>>> +
>>>          SCons.Taskmaster.OutOfDateTask.postprocess(self)
>>>
>>>      def make_ready(self):
>>> @@ -653,6 +660,7 @@
>>>      if "findlibs" in debug_values:
>>>          SCons.Scanner.Prog.print_find_libs = "findlibs"
>>>      options.debug_includes = ("includes" in debug_values)
>>> +    options.debug_dump = ("dump" in debug_values)
>>>      print_memoizer = ("memoizer" in debug_values)
>>>      if "memory" in debug_values:
>>>          memory_stats.enable(sys.stdout)
>>> diff -r e6d4edfedcb4 src/engine/SCons/Script/SConsOptions.py
>>> --- a/src/engine/SCons/Script/SConsOptions.py    Mon Jun 29 07:04:53
>>> 2015 -0400
>>> +++ b/src/engine/SCons/Script/SConsOptions.py    Mon Jun 29 10:54:02
>>> 2015 -0400
>>> @@ -673,7 +673,7 @@
>>>          "tree"          : '; please use --tree=all instead',
>>>      }
>>>
>>> -    debug_options = ["count", "duplicate", "explain", "findlibs",
>>> +    debug_options = ["count", "duplicate", "dump", "explain",
>>> "findlibs",
>>>                       "includes", "memoizer", "memory", "objects",
>>>                       "pdb", "prepare", "presub", "stacktrace",
>>>                       "time"]
>>>
>>>
>>> V/R,
>>> William
>>>
>>> On Sat, Jul 25, 2015 at 4:00 PM, William Blevins <wblevins001 at gmail.com>
>>> wrote:
>>>
>>>> SCons.Node has a function set_explicit, but after reading the function
>>>> description, I don't think that is what this does?
>>>>
>>>> On Sat, Jul 25, 2015 at 3:56 PM, Bill Deegan <bill at baddogconsulting.com
>>>> > wrote:
>>>>
>>>>> William,
>>>>>
>>>>>
>>>>> On Sat, Jul 25, 2015 at 3:53 PM, William Blevins <
>>>>> wblevins001 at gmail.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Sat, Jul 25, 2015 at 3:52 PM, William Blevins <
>>>>>> wblevins001 at gmail.com> wrote:
>>>>>>
>>>>>>> Yes, but here is an example in case:
>>>>>>>
>>>>>>> File "a.c" exists
>>>>>>> File "b.c" exists
>>>>>>>
>>>>>>> FS node representing "a.c" is node_a and representing "b.c" is node_b
>>>>>>>
>>>>>>> If I run "scons" or "scons a.o", then node_b.is_explicit_target (or
>>>>>>> some other function name) returns False.
>>>>>>> If I run "scons b.o" or "scons a.o b.o", then
>>>>>>> node_b.is_explicit_target return True for both cases, but
>>>>>>> node_b.is_explicit_target return True only for the second case.
>>>>>>>
>>>>>>>
>>>>>> Copy-pasta error fixed below:
>>>>>> If I run "scons b.o" or "scons a.o b.o", then
>>>>>> node_b.is_explicit_target return True for both cases, but
>>>>>> node_a.is_explicit_target return True only for the second case.
>>>>>>
>>>>>
>>>>> Isn't this what you'd expect?
>>>>> I guess I'm missing where this doesn't answer your original question?
>>>>> Also you can get the list of  command line arguments raw..
>>>>>
>>>>> -Bill
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> V/R,
>>>>>>> William
>>>>>>>
>>>>>>> On Sat, Jul 25, 2015 at 3:32 PM, Bill Deegan <
>>>>>>> bill at baddogconsulting.com> wrote:
>>>>>>>
>>>>>>>> So you mean if scons was run as: scons a/b/c/d.exe ?
>>>>>>>>
>>>>>>>> On Sat, Jul 25, 2015 at 2:13 PM, William Blevins <
>>>>>>>> wblevins001 at gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Is there an easy way to determine if a Node was specified
>>>>>>>>> explicitly as a command-line argument?
>>>>>>>>>
>>>>>>>>> V/R,
>>>>>>>>> William
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Scons-users mailing list
>>>>>>>>> Scons-users at scons.org
>>>>>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Scons-users mailing list
>>>>>>>> Scons-users at scons.org
>>>>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Scons-users mailing list
>>>>>> Scons-users at scons.org
>>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Scons-users mailing list
>>>>> Scons-users at scons.org
>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>
>>>>>
>>>>
>>>
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>>
>
>
> --
> Gary
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20150726/65290880/attachment.html>


More information about the Scons-users mailing list