[Scons-users] strange behavior around env.AddMethod
Gary Oberbrunner
garyo at oberbrunner.com
Wed Oct 23 08:13:27 EDT 2013
The generator doesn't make a copy of env. Later, during the build phase,
whatever env contains at that point will be used by your action. (See what
it contains at the very end of your SConstruct; that's what all the
builders/actions will see during the build phase.) You might want to have
your generator return a different function depending on the SHARED_LIB
value.
On Wed, Oct 23, 2013 at 7:49 AM, Rob Deckers <Rob.Deckers at vanderlande.com>wrote:
> Hi,****
>
> ** **
>
> I am adjusting a part to run tests on a remote target.****
>
> We have 2 kinds of files that should be copied to the target.****
>
> ** **
>
> ‘normal’ test dependency files, which will be copied to
> env['TESTTARGET_DIR']****
>
> And shared libraries, which should be copied to another directory
> env['LIBTARGET_DIR']****
>
> ** **
>
> I have created 2 single source builders that use a generator.****
>
> One uses this function:****
>
> def _libtest_dependency_action_generator(source, target, env,
> for_signature):****
>
> env['SHARED_LIB'] = True****
>
> return _test_dependency_action_generator(source, target, env,
> for_signature)****
>
> ** **
>
> the other this one:****
>
> def _scripttest_dependency_action_generator(source, target, env,
> for_signature):****
>
> env['SHARED_LIB'] = False****
>
> return _test_dependency_action_generator(source, target, env,
> for_signature)****
>
> ** **
>
> A few function’s deeper, where the actually copy takes place, I have
> something like:****
>
> def _copyto_target_dir_action_method(env, source, compress=False,
> rel_dir=None, **keywords): ****
>
> if env['SHARED_LIB']:****
>
> target = env['LIBTARGET_DIR']****
>
> else:****
>
> target = env['TESTTARGET_DIR']****
>
> ** **
>
> The copy function is added to the environment in the generate function
> with:
> env.AddMethod(_copyto_target_dir_action_method, "CopyToTargetDir")
>
> ****
>
> So far, so good.****
>
> Now the strange thing:****
>
> When I use:****
>
> _copyto_target_dir_action_method(env, <other vars>)****
>
> ** **
>
> env['SHARED_LIB'] still contain’s it’s value, BUT when I use:****
>
> env.CopyToTargetDir(<other vars>)****
>
> ** **
>
> the if env['SHARED_LIB']: always returns false.****
>
> ** **
>
> What is going on?****
>
> ** **
>
> ** Disclaimer **
>
> This e-mail, including any attachments, may include proprietary and
> confidential information of Vanderlande Industries and may only be read by
> the person or those persons to whom it is addressed.
> This document is forwarded to you in such a form (e-mail) that Vanderlande
> Industries cannot guarantee the completeness and/or correctness of its
> contents and information.
> If you have received this e-mail message in error, please notify us
> immediately. Please also delete this document from your computer.
> This document may not be reproduced, copied, distributed, published,
> modified, or furnished to third parties, without the prior written consent
> of Vanderlande Industries.
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
>
>
--
Gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20131023/f8b8f2b8/attachment.html
More information about the Scons-users
mailing list