如何确保 OMake 中引用了目录名称?
我有一套相对复杂的 OMake 文件,专为在特定平台上进行交叉编译而设计。我的源代码是C++。
我是从 Windows 构建的,需要将包含名称中包含空格的目录传递给编译器。插入到命令行中以编译文件的包含字符串的创建方式是通过以下行创建的:
public.PREFIXED_INCLUDES = $`(addprefix $(INCLUDES_OPT), $(set $(absname $(INCLUDES))))
在 OMake 文件中的其他点上,我有一行类似:
INCLUDES += $(dir "$(LIBRARY_LOCATION)/Path with spaces/include")
在命令行中间,它扩展为:
-IC:\Library location with spaces\Path with spaces\include
我想要它将扩展为:
-I"C:\Library location with spaces\Path with spaces\include"
如果可能的话,除了“INCLUDES += ...”行之外,我不想更改任何内容,尽管修改该文件中的其他内容也可以。我不想做一些事情,比如更改 PREFIXED_INCLUDES 的定义,因为它位于一套 OMake 文件中,这些文件是 SDK 的一部分,可能会在我下面发生变化。这可能吗?如果是这样,我该怎么办?如果不是,我可以通过什么方式确保通过修改少量 makefile 代码(希望是一行)来引用包含空格的内容?
I have a relatively complicated suite of OMake files designed for cross-compiling on a specific platform. My source is in C++.
I'm building from Windows and I need to pass to the compiler include directories which have spaces in their names. The way that the includes string which is inserted in the command line to compile files is created is by the line:
public.PREFIXED_INCLUDES = I have a relatively complicated suite of OMake files designed for cross-compiling on a specific platform. My source is in C++.
I'm building from Windows and I need to pass to the compiler include directories which have spaces in their names. The way that the includes string which is inserted in the command line to compile files is created is by the line:
(addprefix $(INCLUDES_OPT), $(set $(absname $(INCLUDES))))
At some other point in the OMake files I have a line like:
INCLUDES += $(dir "$(LIBRARY_LOCATION)/Path with spaces/include")
In the middle of the command line this expands to:
-IC:\Library location with spaces\Path with spaces\include
I want it to expand to:
-I"C:\Library location with spaces\Path with spaces\include"
I don't want to change anything but the "INCLUDES += ..." line if possible, although modifying something else in that file is also fine. I don't want to have to do something like change the definition of PREFIXED_INCLUDES, as that's in a suite of OMake files which are part of an SDK which may change beneath me. Is this possible? If so, how can I do it? If not, in what ways can I make sure that includes with spaces in them are quoted by modifying little makefile code (hopefully one line)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标准库函数
quote
在其参数周围添加转义引号,因此它应该完成这项工作:如果需要,请参阅 Omake 手册中的
引用
。The standard library function
quote
adds escaped quotes around its argument, so it should do the job:If needed, see
quote
in Omake manual.如果其他人遇到同样的问题,我想我会分享我最终采用的解决方案,但从未弄清楚如何用引号引起来。我最终没有将带有空格的名称加上引号,而是将路径转换为短(8.3)版本。我通过一个名为 Short.js 的简单 JScript 文件和一个单行 OMake 函数来完成此操作。
脚本:
函数:
所以现在我只使用如下所示的行来包含:
In case someone else is having the same problem, I thought I'd share the solution I eventually went with, having never figured out how to surround with quotes. Instead of putting quotes around a name with spaces in it I ended up converting the path to the short (8.3) version. I did this via a a simple JScript file called shorten.js and a one line OMake function.
The script:
The function:
So now I just use a line like the following for includes: