SCONS:制作特殊的脚本构建器依赖于另一个构建器的输出
我希望标题能澄清我想问的问题,因为这有点棘手。
我为每个子目录都有一个 SCONS SConscript,如下所示(如果重要的话,在 Linux 中进行):
- src_dir
- 编译器
- SConscript
- yacc 源文件
- 脚本
- 旧脚本
- 数据
- SConscript
- yacc 的数据文件
- 编译器
数据文件我使用不带副本的variant_dir,例如:SConscript('src_dir/compiler/SConscript',variant_dir = 'obj_dir',duplicate = 0)
构建 yacc 后生成的 obj_dir 为:
- obj_dir
- 编译器
- compiler_compiler.exe
- 编译器
现在是交易。
我在数据目录中有另一个 SConscript 需要做两件事: 1.使用yacc编译器编译数据
2.获取编译器的输出并使用我无法更改的legacy_script运行它
(legacy_script,获取编译数据的输出并构建一些 h 文件以供另一个软件依赖)
第 1 点很容易实现:linux_env.Command('[output1, output2]', 'data/data_files','compiler_compiler.exe data_files output1 output2')
我的问题是第二个:如何使脚本运行程序依赖于输出另一个目标
为了澄清这一点,我需要运行 SCONS(并且仅当编译器输出发生变化时):src_dir/script/legacy_script obj_dir/data/compiler_output obj_dir/some_dir/script_output
(脚本的用法是:legacy_script input_file output_file)
我希望我说清楚了,请随时提出更多问题......
I hope the title clarifies what I want to ask because it is a bit tricky.
I have a SCONS SConscript for every subdir as follows (doing it in linux, if it matters):
- src_dir
- compiler
- SConscript
- yacc srcs
- scripts
- legacy_script
- data
- SConscript
- data files for the yacc
- compiler
I use a variant_dir without copy, for example:SConscript('src_dir/compiler/SConscript', variant_dir = 'obj_dir', duplicate = 0)
The resulting obj_dir after building the yacc is:
- obj_dir
- compiler
- compiler_compiler.exe
- compiler
Now here is the deal.
I have another SConscript in the data dir that needs to do 2 things:
1. compile the data with the yacc compiled compiler
2. Take the output of the compiler and run it with the legacy_script I can't change
(the legacy_script, takes the output of the compiled data and build some h files for another software to depend on)
number 1 is acheived easily:linux_env.Command('[output1, output2]', 'data/data_files','compiler_compiler.exe data_files output1 output2')
my problem is number 2: How do I make the script runner depend on outputs of another target
And just to clarify it, I need to make SCONS run (and only if compiler_output changes):src_dir/script/legacy_script obj_dir/data/compiler_output obj_dir/some_dir/script_output
(the script is usage is: legacy_script input_file output_file)
I hope I made myself clear, feel free to ask some more questions...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近遇到了类似的问题,当时我需要先编译 Cheetah 模板,然后从另一个生成器使用该模板从不同来源生成 HTML 文件。
如果将第一个构建器的构建输出定义为第二个构建器的源,SCons 将以正确的顺序运行它们,并且仅当中间文件发生更改时。
沃尔夫冈
I've had a similar problem recently when I needed to compile Cheetah Templates first, which were then used from another Builder to generate HTML files from different sources.
If you define the build output of the first builder as source for the second builder, SCons will run them in the correct order and only if intermediate files have changed.
Wolfgang