包括无-Isystem或Symlinks的CC_Library的额外途径
我有一个库,从不同的构建系统移植,具有以下结构:
.
└── foo
├── bar
│ ├── a.h
│ ├── b.h
│ └── c.h
└── something.cpp
在某种程度上。cpp:
#include "a.h"
#include "b.h"
#include "c.h"
此结构以某种方式执行并且无法更改。还有一些代码生成器生成其他代码,这些代码直接引用了文件。
然后,在构建文件中,我可以做:
cc_library(
name = "foo",
includes = ["bar"], #1
# strip_include_prefix = "bar", #2
# copts = "-Ibar", #3
srcs = ["bar/a.h","bar/b.h","bar/c.h",something.cpp], #1 #3
# srcs = ["something.cpp"], #2
# hdrs = ["bar/a.h","bar/b.h","bar/c.h"], #2
],
)
所有这些解决方案都有一些问题。
- 我不会从编译中收到任何警告。
包括
,由于-isystem
flag,strip_include_prefix
symlinks symlinks与虚拟符合虚拟的属于IDE和debuggers, 。COPTS
可能是编译器的特定于编译器,并且不是传递的。
最后,我想到了这个想法,更改Bazel行为以使用 - i
而不是 - ISYSTEM
for incode> incode> incover
,是否存在有可能这样做吗? 也许有一些更好的解决方案可以解决所有这些问题?
I have a library, ported from a different build system with following structure:
.
└── foo
├── bar
│ ├── a.h
│ ├── b.h
│ └── c.h
└── something.cpp
In something.cpp:
#include "a.h"
#include "b.h"
#include "c.h"
This structure is somehow enforced and can't be changed. There are also some code generators that generates additional code which reference mentioned files directly.
Then in BUILD file I can do:
cc_library(
name = "foo",
includes = ["bar"], #1
# strip_include_prefix = "bar", #2
# copts = "-Ibar", #3
srcs = ["bar/a.h","bar/b.h","bar/c.h",something.cpp], #1 #3
# srcs = ["something.cpp"], #2
# hdrs = ["bar/a.h","bar/b.h","bar/c.h"], #2
],
)
All of these solution have some issues.
includes
I will not get any warnings from the compilation because of the-isystem
flag,strip_include_prefix
symlinks with virtual includes are created what confuses IDEs and debuggers.copts
could be possibly compiler specific and it's not transitive.
Finally I end up with the idea it would be useful to change bazel behaviour to use -I
instead of -isystem
flag for includes
, is there any possibility to do that?
Maybe there's some better solution that address all those issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论