从文件返回值的构建器

时间:2015-11-09 16:04:33

标签: python scons

有没有办法让构建器返回Value而不是File?我的构建系统中的几个步骤遵循以下模式:

  1. 从文件中读取值
  2. 根据文件生成值,例如计算'foo'这个词出现的次数。
  3. 根据此值生成Action
  4. 所以我可能想要这样的命令:

    source_value = env.SomeBuilder(<value target>, 'input_file.txt')
    env.Command('output.txt', source_value,
         'my_function $SOURCE $TARGET')
    

    此处的示例显示了如何从Value创建Value,而不是从Value创建File

1 个答案:

答案 0 :(得分:0)

是的,请查看UserGuide(http://www.scons.org/doc/production/HTML/scons-user.html)第20章“Pseudo-Builders”中的repositories { ivy { // Change the values here to match your environment. url 'http://archiecobbs.github.io/ivyroundup/repo/modules/' layout 'pattern', { artifact '[organisation]/[module]/[revision]/ivy.[ext]' } } } configurations { ivyFiles } dependencies { ivyFiles 'org.apache.geronimo.specs:activation:1.1@xml' } task downloadIvyFiles(type: Copy) { from configurations.ivyFiles into temporaryDir } 。它允许您调用自己的方法/函数,您可以在其中访问源名称,打开文件,读取和处理其内容,然后创建并返回AddMethod()节点(未经测试,从头顶开始):

Value