[Scons-users] Debugging SCons files as Python scripts

Tony Whitley tony_whitley at hotmail.com
Wed Sep 10 12:52:08 EDT 2014


Hi Dirk,

I'd have to find out about making it public though there's not much to it,
it's simply an env object that supplies a handful of the SCons methods
(like SConscript, Replace, VariantDir and the environment variables) and
stubs for some others.  I had to modify our SCons scripts very slightly,
the only significant change was making the content into a function main and
appending

try:
  Import('env')
  env = env.Clone()
  main(env)
except:
  pass

The test harness then imports them (using imp.load_source) and calls main
providing its test env. There may be a less intrusive way of doing that but
it worked.

-- 
Tony

On 7 September 2014 11:29, Dirk Bächle <tshortik at gmx.de> wrote:

> Hi Tony,
>
> On 07.09.2014 12:18, Tony Whitley wrote:
>
>> I'm working with an SCons design that is sufficiently complex to require
>> debugging of the scripts themselves. I have been using print commands to
>> debug the scripts which is slow and painful.  I have finally got round to
>> hacking a Python script that simulates parts of SCons so that I can run my
>> SCons files as Python scripts in a Python IDE with all the benefits of
>> tracing the flow, watching variables and so on.  It doesn't do any of the
>> "real" stuff like building files, it's a kind-of meta-SCons that just
>> produces the information that the SCons engine will consume when it builds
>> files.  I wondered how others test their SCons scripts, whether I've just
>> re-invented the wheel?  It seems to me this is a valuable benefit of SCons
>> being based on a widely-used language.
>>
>> It also allows for writing unit tests. I have just dipped a toe into that
>> but it looks promising.
>>
>>
> this sounds very interesting indeed. So far, I debugged my scripts by
> stepping through the build with a debugger (Eclipse+pydev)...or by "print"
> statements in the more simple cases. I don't know of any similar SConstruct
> parser out there, so let's hear more about your solution. ;)
>
> Is there a repo somewhere? Then I'd take a look...
>
> Best regards,
>
> Dirk
>
> _______________________________________________
> 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/20140910/49515187/attachment.html>


More information about the Scons-users mailing list