[Scons-users] recording compilation commands with scons

Gary Oberbrunner garyo at oberbrunner.com
Wed Apr 24 06:33:12 EDT 2013


On Tue, Apr 23, 2013 at 10:31 PM, Handa, Ramneek <Ramneek.Handa at sc.com>wrote:


> Yes. That is a solution though a very generic one. I would like to go more

> pythonic though.

>


SCons is not always perfectly pythonic -- its goal is to make a build
system usable by anyone, without necessarily being a python expert. So
there is very little OO, inheritance, or magic in the visible parts of
SCons.

****

>

> More specifically, ****

>

> **1. **How can I intercept the call to compile the file just in

> time so that i know what the environment variables?

>

Here the best thing might be to what Francis suggested; make the call into
a list and just pass the same cmd line to your command-saver. Hooking into
the low level executor is possible, but will probably lead to breakage in
the future. Of course you can hook into all the builders you care about --
your example shows that method.


> ****

>

> **2. **How do I expand variables within python as I see some of the

> variables end up to be referring to another variable? I am specifically

> interested in CCFLAGS? Is env[‘CCFLAGS’] the right way to go (when i have

> specific env variable)?

>

env.subst(...):
http://www.scons.org/doc/HTML/scons-api/SCons.Environment.SubstitutionEnvironment-class.html#subst



> ****

>

> ** Below is the trick I am using by monkey patching the Shared and Static

> Object emitters. Is that the right direction to proceed? This works well so

> far although I am not sure if I am picking up the compilation flag from the

> source of truth or there are more manipulations likely to happen in

> static/shared object emitters?

>

The emitter is one step before the actual compilation, so it's probably
fine -- but the Executor is where it actually invokes the compiler. The
Executor is completely generic though.

--
Gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20130424/1cb8f8b1/attachment-0001.htm>


More information about the Scons-users mailing list