[英]How do you tell a Clang CompilerInvocation to use a framework?
I have code that builds a CompilerInvocation
with the Clang static libraries. 我有使用Clang静态库构建
CompilerInvocation
代码。 I would like to tell that invocation to use specific frameworks, just like using the -framework
Clang front-end option. 我想告诉您使用特定框架的调用,就像使用
-framework
Clang前端选项一样。 In particular, I'm looking for these "side effects" of using a framework: 特别是,我正在寻找使用框架的这些“副作用”:
<Framework/Header.h>
. <Framework/Header.h>
类的路径标识的框架头。 At this point, I think that I've looked everywhere in the option sub-objects of the CompilerInvocation
class, and the closest thing that I can identify related to that is the header search path. 在这一点上,我认为我已经在
CompilerInvocation
类的option子对象中到处查找了,而我能识别的与此相关的最接近的事物是标题搜索路径。 I can't seem to find a way to tell the CompilerInvocation
to look for a specific framework. 我似乎找不到找到告诉
CompilerInvocation
寻找特定框架的方法。
How is that supposed to happen? 那应该如何发生? I'm using a manually-built
CompilerInvocation
instead of building it through command-line arguments because that seems to be the only way to pass a memory buffer as a source unit instead of a file. 我使用的是手动构建的
CompilerInvocation
而不是通过命令行参数构建它,因为这似乎是将内存缓冲区作为源单位而不是文件的唯一途径。
I haven't found the way to do it through the CompilerInvocation
object, but you can get a CompilerInvocation
from command-line arguments using clang:: createInvocationFromCommandLine
. 我还没有找到通过
CompilerInvocation
对象执行此操作的方法,但是您可以使用clang:: createInvocationFromCommandLine
从命令行参数获取CompilerInvocation
。 When using -framework
arguments, the resulting invocation can correctly #include
framework headers. 使用
-framework
参数时,所产生的调用可以正确地#include
框架标头。 This isn't awesome, but it works (other than the compiler will complain that the frameworks are unused linker input, probably because no linking phase occurs). 这不是很了不起,但是可以(除了编译器会抱怨这些框架是未使用的链接器输入,可能是因为没有链接阶段发生)。
Of course, this means that a way through the CompilerInvocation
has to exist, because that's the only thing that's returned. 当然,这意味着通过一种方式
CompilerInvocation
必须存在,因为这是所返回的唯一的事情。 I could believe that the logic to get frameworks from the framework path is private, though. 我可以相信,从框架路径获取框架的逻辑是私有的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.