如何强制 SConscript 构建器更改目录?
目前,我正在尝试将一个百万 sloc 遗留项目从乏味的 .cmd 脚本移植到 SCons。其中一部分是VC++,其他是Delphi。为 C++ 片段创建 SConscript 是一件轻而易举的事。
为了构建 delphi 部分,我编写了一个非常简单的构建器,它可以检测它是程序还是库项目。通过 SConscript 链接后调用构建器会使 scons 调用 dcc32 $subdir/project.dpr ,这会误导 dcc32 在当前目录而不是 $subdir 中查找单元。
有没有办法告诉 scons 在执行 sconscript 中的命令之前输入 $subdir 或者我应该在构建器中修复它?
先感谢您
currently I'm trying to port a million-sloc legacy project from dull .cmd scripts to SCons. Parts of it are VC++, others are Delphi. Creating SConscripts for the C++ pieces was a breeze.
To build the delphi part I've written a very simple builder which detects whether it is a program or library project. Calling the builder after chaining via SConscript makes scons to call dcc32 $subdir/project.dpr what misleads dcc32 to look for units in the current directory instead of the $subdir.
Is there a way to tell scons to enter the $subdir before executing commands residing in the sconscript or should I fix it within the builder?
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SCons 在读取它们时已经更改为子目录 SConscripts 的目录,因此看起来问题必须在实际构建器中修复。
一旦脚本被解析,并且 SCons 正在运行构建命令,它就会保留在顶级目录中。然后使用相对于该顶级目录的路径名发出命令。更改此行为的方法是在构建器中使用
chdir
关键字。scons 手册页中的示例如下:
您需要指定
.file
组件,因为使用chdir
不会更改传递给构建器的名称,即它们仍然相对于顶级目录。SCons already changes to the directory of sub-directory SConscripts when reading them, so it looks like the problem is going to have to be fixed in the actual builder.
Once the scripts are parsed, and SCons is running the build commands, it stays in the top-level directory. Commands are then issued using path names relative to that top-level directory. The way to change this behavior is to use the
chdir
keyword in your Builder.The example from the scons man page is as follows:
You need to specify the
.file
component as the use ofchdir
does not change the names passed to the builder, i.e. they are still relative to the top-level directory.