Hi Jason, It sounds like we're on the same page. The reason I want an environment object is because the SCons-y way of customizing things seems to be through the Environment. My API parallels the decider() API, so usage in an SConstruct looks like this:
# The signature-making function we wish to use
def sigMaker(f):
ninfo = f.get_ninfo()
#print "Executing sigMaker"
ext_sig = hashImportantLines(f.get_contents())
ninfo.ext_sig = ext_sig
return ext_sig
# The call to register it
env.ExtSignature(sigMaker)
# The ugly hack of registering with the default environment, too.
SCons.Defaults.DefaultEnvironment().ExtSignature(sigMaker)
As I said, my API parallels that of the decider, and my implementation
does as much as possible. The problem as I understand it is that
signature-making happens in a wider range of contexts than
signature-checking.
Thanks,
Eric
On 09/19/2012 04:53 PM, Kenny, Jason L wrote:
> I am probably missing something.. but from I can see,
>
> You are wanting to modify the SCons NodeInfoBase or the class based on it
> such as FileNodeInfo to has a new ext_sig value ( in addition to the current
> csig, timestamp and size values)
> You then need tweaks to make sure the node class stores some value for
> ext_sig when we storing data about that is put in the ninfo member. ( I would
> need to look up the functions that do this in the node classes)
>
> This way when you get the decider function called you can get data that was
> stored to see if something changed. I am unclear on what you need an
> environment object for here. I would guess that what you want to be able to
> attach some function to the object so that when the Scons can get the
> signature data to store, this function can be called and generate some data
> to be stored as this ext_sig. This suggests that you want to add some API, in
> your copy of SCons, to allow some sort of global or per node registration of
> some type of callable object.
>
>
> Just some quick thoughts..
>
> Jason
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of Eric W. Anderson
> Sent: Wednesday, September 19, 2012 3:10 PM
> To: SCons developer list
> Subject: Re: [Scons-dev] Binding Environments to Nodes
>
> What I'm doing (the exact code is here
> https://bitbucket.org/eanderso/scons-custom-sig/compare/default..scons/scons:default)
> is an internal change in Scons.Node.FS.File. So in that context, I'm
> getting the environment with self.get_env(). That returns self.env if set,
> and otherwise the/a DefaultEnvironment. I can't tell you why, but I can say
> from looking at the output that may operations are done on the Node without
> env having been set. Here's a snippet of my SConstruct:
>
> env = Environment()
>
> ... bunch of stuff ...
>
> b=Builder(action="bash myscript.sh $SOURCE $TARGET")
> env.Append(BUILDERS={'B' : b})
> env.Export()
>
> i=File('myinput.txt')
> x=env.B(['myoutput.txt'],[i])
>
> This leads to my extended signature function getting called for the following
> node, environment pairs, where ...d0 is the default and ...90 is env.
>
> Node 'SConstruct' in env <0x17997d0>
> Node 'SConstruct' in env <0x17997d0>
> Node 'myinput.txt' in env <0x17997d0>
> Node 'myinput.txt' in env <0x17997d0>
> Node 'bash' in env <0x17997d0>
> Node 'bash' in env <0x17997d0>
> Node 'myinput.txt' in env <0x17997d0>
> Node 'bash' in env <0x17997d0>
> Node 'myoutput.txt' in env <0x1799790>
> Node 'myoutput.txt' in env <0x1799790>
>
> There are several different stack traces that lead to getting the default
> env; here's one:
>
> SCons.Script.main() -> _exec_main(parser, values) -> _main(parser) ->
> nodes = _build_targets(fs, options, targets, target_top) -> jobs.run(postfunc
> = jobs_postfunc) -> self.job.start() -> task = self.taskmaster.next_task() ->
> task.make_ready() -> SCons.Taskmaster.OutOfDateTask.make_ready(self) ->
> t.visited()
>
> The env I want happens when we get to my code with the following stacks
> (sorry for the data dump):
>
> SCons.Script.main() -> _exec_main(parser, values) -> _main(parser) ->
> nodes = _build_targets(fs, options, targets, target_top) -> jobs.run(postfunc
> = jobs_postfunc) -> self.job.start() -> task = self.taskmaster.next_task() ->
> task.make_ready() -> SCons.Taskmaster.OutOfDateTask.make_ready(self) ->
> t.visited()
> SCons.Script.main() -> _exec_main(parser, values) -> _main(parser) ->
> nodes = _build_targets(fs, options, targets, target_top) -> jobs.run(postfunc
> = jobs_postfunc) -> self.job.start() -> task.executed() ->
> SCons.Taskmaster.OutOfDateTask.executed(self) -> t.visited()
>
> Any thoughts would be very welcome!
> -Eric
[snip]
--
Eric W. Anderson Electrical and Computer Engineering
[email protected] Carnegie Mellon University
phone: +1-412-268-1908 Roberts Hall 244
PGP key fingerprint:
D3C5 D6FF EDED 9F1F C36D 53A3 74B7 53A6 3C74 5F12
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Scons-dev mailing list [email protected] http://two.pairlist.net/mailman/listinfo/scons-dev
