scons 命令/显式依赖 [英] Scons command/explicit dependency

查看:70
本文介绍了scons 命令/显式依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似的代码片段:

I have a code snippet similar to this:

# Compile protobuf headers
env.Protoc(...)
# Move headers to 'include' (compiled via protobuf)    
env.Command([include headers...], [headers...], move_func)
# Compile program (depends on 'include' files)
out2 = SConscript('src/SConscript')
Depends(out2, [include headers...])

基本上,我有 Protoc() 编译 protobuf 文件,然后通过 env.Command() 将标头移动到 'include' 目录,最后程序是通过 'src' 中的 SConscript 文件编译.

Basically, I have Protoc() compiling protobuf files, then the headers are moved to the 'include' directory by env.Command() and finally the program is compiled through a SConscript file in the 'src'.

由于这些是被移动的头文件(src 编译所依赖的),它们没有被 scons 明确定义为依赖项(据我所知).因此,编译运行,但头文件尚未移动,因此失败.我曾尝试通过 Depends()Requires() 公开依赖项,但没有成功.

Since these are header files that are being moved (that the src compilation depends on), they are not explicitly defined as a dependency by scons (as far as I understand). Thus, the compilation runs, but the header files haven't been moved so it fails. I have tried exposing the dependency via Depends() and Requires() without success.

我知道在通常情况下,scons 应该找出"依赖关系,但我不知道它在这里如何做到这一点.

I understand that in the usual case, scons should "figure-out" dependencies, but I don't know how it could do that here.

谢谢!

推荐答案

您似乎以制作"方式思考构建过程,这是使用 SCons 时的错误方法.您不能通过将单个构建步骤放在不同的 SConscript 中,然后将它们包含在特殊顺序中来排序.您必须在实际源(例如 C/CPP 文件)和目标(如程序或 PDF 文件)之间定义适当的依赖关系.然后 SCons 能够找出正确的构建顺序,并自动遍历项目的文件夹结构.如果需要,它会在依赖图 (DAG) 指示时多次进入子文件夹.通常使用 Builder 来定义输入和输出之间的这种依赖关系……在您的情况下,Install() 构建器将是一个不错的选择.还请注意最常见的常见问题解答"列表中 #2 的提示(https://bitbucket.org/scons/scons/wiki/FrequentlyAskedQuestions).

You seem to be thinking in "make" ways about your build process, which is the wrong approach when using SCons. You can't order single build steps by putting them in different SConscripts, and then including those in a special order. You have to define proper dependencies between your actual sources (C/CPP files for example) and a target like a program or PDF file. Then SCons is able to figure out the correct build order, and will traverse through the folder structure of your project automatically. If required, it will enter subfolders more than once when the dependency graph (DAG) dictates this. Defining this kind of dependencies between inputs and outputs is usually done, using a Builder...and in your case the Install() builder would be a good fit. Please also regard the hints for #2 in the list of "most frequently-asked FAQs" ( https://bitbucket.org/scons/scons/wiki/FrequentlyAskedQuestions).

此外,我只能建议在用户指南中多读一点(http://www.scons.org/doc/production/HTML/scons-user.html )以更好地了解如何以更Sconsy"的方式做事.如果您遇到困难,请随时在 scons-users@scons.org 的邮件列表中提出更多问题(请参阅 http://www.scons.org/lists.php).最后,如果您有很多要串行执行的步骤,并且不需要任何特殊的输入/输出文件,那么 SCons 可能不是您当前任务的正确工具.它被设计为一个面向文件的构建系统,并考虑到了自动并行化,一个简单的(Python?)脚本可能更适合串行的东西......

Further, I can only recommend to read a little more in the UserGuide ( http://www.scons.org/doc/production/HTML/scons-user.html ) to get a better feeling for how to do things in a more "SConsy" way. If you get stuck, feel free to ask further questions on our mailing list at scons-users@scons.org (see http://www.scons.org/lists.php ). Finally, if you have a lot of steps that you want to execute in serial, and that don't require any special input/output files, SCons is probably not the right tool for your current task. It's designed as a file-oriented build system with automatic parallelization in mind, a simple (Python?) script might be better at the mere serial stuff...

这篇关于scons 命令/显式依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆