[Scons-users] Dependencie with Sconscripts and builder's environment

Vasily just.one.man at yandex.ru
Wed Oct 12 05:22:21 EDT 2016


Maybe varlist should be taken into account for all actions then? What's the
motivation for it working only for some actions but not for other?
12 окт. 2016 г. 10:12 пользователь "Dirk Bächle" <tshortik at gmx.de> написал:

> Hi Albert,
>
> On 12.10.2016 01:27, Albert Arquer wrote:
>
>> Hi Dirk,
>>
>> sorry for all the questions but I am not that experienced in python.
>>
>> I have been looking around the scons sources and I have found the
>> get_presig function implemented in FunctionAction.
>>
>> However my question is, how can I overrinde this class from my
>> sconscripts? Modifying the scons libraries is not an option...
>>
>>
> okay...what you basically need is the knowledge that functions are
> first-class objects in Python. So you can assign them and treat them in the
> same way as normal variables. So, in your SConscript you do
>
>     import SCons.Action
>     import SCons.Builder
>
>     def myBuildMethod():
>         ...
>
>     # Create Action
>     myFuncAct = SCons.Action.Action(myBuildMethod)
>     # Get at the original presig function
>     origPresig = myFuncAct.get_presig
>
>     # Define our own version of it, where we append the variable of
> interest
>     def wrappedPresig():
>         return origPresig + env.subst("$COMMAND")
>
>     # Set this as our new presig method
>     myFuncAct.get_presig = wrappedPresig
>
>     # Now create a proper Builder with our monkey-patched presig function
>     myBuilder = SCons.Builder.Builder(myFuncAct)
>
>
> , all from the top of my head and untested. ;)
> I hope this helps you further already, but other Python experts might
> chime in on this as well.
>
> 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/20161012/4f5ac21c/attachment.html>


More information about the Scons-users mailing list