scons - Builder with optional source -


i want make builder 1 or more optional sources.

i tried this:

env.append(builders = {'my_builder': builder(action = action(do_something))})  def do_something(target, source, env):     if source[1]:         do_optional_stuff(source[1])     do_other_stuff(target, source[0])  ...  env.my_builder(target.txt, [source1, none])    # fails env.my_builder(target.txt, [source2, source3]) # okay 

the trouble is, 'nonetype' object has no attribute 'get_ninfo' when pass in none, because scons expecting node arguments, , none isn't acceptable.

is there can do?

edit:

as noted in answer below, it's possible solve simple case of 1 optional argument, varying length of source list. doesn't work making arbitrary arguments optional, i'd still interested in way that.

instead of adding bogus element, check length of source list (or better yet, iterate on list starting after first element):

def do_something(target, source, env):     if len(source) > 1:         do_optional_stuff(source[1])     # or:     # opt_src in source[1:]:     #   do_optional_stuff(opt_src)     do_main_stuff(target, source[0])  env.append(builders = {'my_builder': builder(action = action(do_something))})  env.my_builder('target-2.txt', ['foo.txt']) env.my_builder('target-1.txt', ['foo.txt', 'bar.txt']) 

one issue approach need ensure sources listed in right order. depending on details of you're doing, might able filter source list matching file names or extensions. after all, python code, have full power of language @ disposal.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -