[Scons-users] Pass custom arguments to a builder
Gary Oberbrunner
garyo at oberbrunner.com
Mon Jan 20 11:01:05 EST 2014
On Mon, Jan 20, 2014 at 3:12 AM, delbert dev <delbertum at gmail.com> wrote:
> 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())
If I understand correctly, the only reason you create two builders is
to change src_file. You don't need to do that. All builder calls
allow you to specify "environment overrides" as keyword args, so:
extract_gtest_cmd = env.MyCmd(["Extract gtest"], os.popen('which
bash').read().strip(), src_file=gtestOutputFile)
extract_gmock_cmd = env.MyCmd(["Extract gmock"], os.popen('which
bash').read().strip(), src_file=gmockOutputFile)
Also, and this is important, action functions like your my_action take
target, source, env; you have source, target, env.
--
Gary
More information about the Scons-users
mailing list