[Scons-users] Pass custom arguments to a builder
delbert dev
delbertum at gmail.com
Mon Jan 20 03:12:14 EST 2014
Thanks, is it possible to reuse the same builder again? I now have:
*def my_action(source, target, env):*
* with zipfile.ZipFile(env['src_file'] , "r") as z: *
* z.extractall(env['out_folder'])*
* print "Extracted : " + env['src_file'] + " to: " + env['out_folder']*
*# First "envocation"*
*my_cmd_builder = Builder(action=my_action, src_file=gtestOutputFile,
out_folder=outdir)*
*env.Append( BUILDERS = {'MyCmd' : my_cmd_builder } )*
*extract_gtest_cmd = env.MyCmd(["Extract gtest"], os.popen('which
bash').read().strip())*
*# Second "envocation"*
*my_cmd_builder2 = Builder(action=my_action, src_file=gmockOutputFile,
out_folder=outdir)*
*env.Append( BUILDERS = {'MyCmd2' : my_cmd_builder2 } )*
*extract_gmock_cmd = env.MyCmd2(["Extract gmock"], os.popen('which
bash').read().strip())*
*Default(env.Alias('obs', Depends(extract_gtest_cmd,[gmockDownload,
gtestDownload, extract_gmock_cmd])))*
Which is a lot of code to simply call a "function" twice.
On Mon, Jan 20, 2014 at 1:40 AM, William Deegan
<bill at baddogconsulting.com>wrote:
> Deblert,
>
> On Jan 19, 2014, at 4:32 PM, delbert dev <delbertum at gmail.com> wrote:
>
> I have this builder which uses global variables:
>
>
> *def my_action(source, target, env):*
> * with zipfile.ZipFile(gtestOutputFile , "r") as z: *
> * z.extractall(outdir)*
> * print "Extracted : " + source[0].abspath + " too: " +
> target[1].abspath*
> * print "a " + target[0].abspath*
> * print "a " + target[1].abspath*
> * print "a " + target[2].abspath*
> * print "s " + source[0].abspath*
>
> * print "o " + outdir *
>
>
>
> *my_cmd_builder = Builder(action=my_action)*
> *env.Append( BUILDERS = {'MyCmd' : my_cmd_builder } )*
> *my_cmd = env.MyCmd(["asdad", "asdasdads123123", "eee"], os.popen('which
> bash').read().strip())*
>
> I would like to reuse the above builder and therefore it should take the
> input/output files as arguments. But how do I do that? I have tried to pass
> them as target, source lists but it does not work.
>
>
> Pass them through Environment() variables as such:
>
> env.myBuilder(a,b,MYBUILDER_ARG_1=True)
>
> Is one way to do this.
>
> -Bill
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140120/a5a730c2/attachment.html
More information about the Scons-users
mailing list