[Scons-dev] Patch for potential new debug option

William Blevins wblevins001 at gmail.com
Sat Aug 8 17:59:41 EDT 2015


On Sat, Aug 8, 2015 at 5:48 PM, Bill Deegan <bill at baddogconsulting.com>
wrote:

> If I run "scons --debug=dumpenv", won't it still do a build?
> So I could get a lot of extra output if I just redirect stdout.
>
> Does the output go to stdout or stderr?
>

The way the patch is written no.  It replaces the BuildTask, but since the
build task is unique it sorta depends on the order in which they are
specified... so there should probably be a check in that code to make sure
only one build task has been selected.


>
> -Bill
>
> On Sat, Aug 8, 2015 at 11:28 AM, William Blevins <wblevins001 at gmail.com>
> wrote:
>
>>
>> On Aug 8, 2015 1:47 PM, "Jason Kenny" <dragon512 at live.com> wrote:
>> >
>> > My only concern with this feature is that it can dump a lot of data.
>> Given Parts for example I would have lots of environment that would be
>> dumped. such information is generally only useful when you can map a given
>> environment to the correct file ( or part file in my case) or build actions
>> (such as this is the environment for link foo.so or this was the
>> environment for making hello.o).
>>
>> I am mapping a target to its build env and outputting the env data.  Just
>> like your example :)
>> >
>> > Jason
>> >
>> > From: William Blevins
>> > Sent: Saturday, August 8, 2015 12:22 AM
>> > To: SCons developer list
>> > Subject: [Scons-dev] Patch for potential new debug option
>> >
>> > Here is a patch for dumping build environments via the command-line.
>> >
>> > I couldn't ever figure out a good way to get only explicitly lister
>> targets (non-default commandline targets).  It will essentially print the
>> node.get_env().Dump() for all targets with a build_env defined.
>> >
>> > I could potentially change it from "--debug=envdump" to something like
>> "--envdump=<VARIABLE>" so that it could print a particular variable rather
>> than the whole env.
>> >
>> > Does this interest anyone or waste of chars?
>> >
>> >> diff -r 682b8a7a51fb src/engine/SCons/Script/Main.py
>> >> --- a/src/engine/SCons/Script/Main.py    Mon Jun 29 15:37:44 2015 -0400
>> >> +++ b/src/engine/SCons/Script/Main.py    Thu Aug 06 23:44:50 2015 -0400
>> >> @@ -391,6 +391,21 @@
>> >>      def prepare(self):
>> >>          pass
>> >>
>> >> +class EnvDumpTask(SCons.Taskmaster.AlwaysTask):
>> >> +    """SCons task for --debug=envdump.  Prints env dump for
>> BUILD_TARGETS."""
>> >> +    def prepare(self):
>> >> +        pass
>> >> +
>> >> +    def execute(self):
>> >> +        for target in self.targets:
>> >> +            if target.get_build_env():
>> >> +                print 'Environment dump for target: ' + str(target)
>> >> +                print target.get_env().Dump()
>> >> +
>> >> +    def executed(self):
>> >> +        pass
>> >> +
>> >> +
>> >> class QuestionTask(SCons.Taskmaster.AlwaysTask):
>> >>      """An SCons task for the -q (question) option."""
>> >>      def prepare(self):
>> >> @@ -657,6 +672,7 @@
>> >>      if "memory" in debug_values:
>> >>          memory_stats.enable(sys.stdout)
>> >>      print_objects = ("objects" in debug_values)
>> >> +    options.debug_envdump = ( "envdump" in debug_values )
>> >>      if print_objects:
>> >>          SCons.Debug.track_instances = True
>> >>      if "presub" in debug_values:
>> >> @@ -1210,8 +1226,13 @@
>> >>          failure_message = "done building targets (errors occurred
>> during build)."
>> >>      else:
>> >>          failure_message = "building terminated because of errors."
>> >> +
>> >> +    if options.debug_envdump:
>> >> +        task_class = EnvDumpTask
>> >> +
>> >>      if options.question:
>> >>          task_class = QuestionTask
>> >> +
>> >>      try:
>> >>          if options.clean:
>> >>              task_class = CleanTask
>> >> diff -r 682b8a7a51fb src/engine/SCons/Script/SConsOptions.py
>> >> --- a/src/engine/SCons/Script/SConsOptions.py    Mon Jun 29 15:37:44
>> 2015 -0400
>> >> +++ b/src/engine/SCons/Script/SConsOptions.py    Thu Aug 06 23:44:50
>> 2015 -0400
>> >> @@ -673,7 +673,7 @@
>> >>          "tree"          : '; please use --tree=all instead',
>> >>      }
>> >>
>> >> -    debug_options = ["count", "duplicate", "explain", "findlibs",
>> >> +    debug_options = ["count", "duplicate", "explain", "envdump",
>> "findlibs",
>> >>                       "includes", "memoizer", "memory", "objects",
>> >>                       "pdb", "prepare", "presub", "stacktrace",
>> >>                       "time"]
>> >>
>> >
>> >
>> > V/R,
>> > William
>> >
>> > ________________________________
>> > _______________________________________________
>> > Scons-dev mailing list
>> > Scons-dev at scons.org
>> > https://pairlist2.pair.net/mailman/listinfo/scons-dev
>> >
>> >
>> > _______________________________________________
>> > Scons-dev mailing list
>> > Scons-dev at scons.org
>> > https://pairlist2.pair.net/mailman/listinfo/scons-dev
>> >
>>
>>
>> _______________________________________________
>> Scons-dev mailing list
>> Scons-dev at scons.org
>> https://pairlist2.pair.net/mailman/listinfo/scons-dev
>>
>>
>
> _______________________________________________
> Scons-dev mailing list
> Scons-dev at scons.org
> https://pairlist2.pair.net/mailman/listinfo/scons-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20150808/e947d2bd/attachment.html>


More information about the Scons-dev mailing list