包括无-Isystem或Symlinks的CC_Library的额外途径

发布于 2025-02-13 06:26:06 字数 1107 浏览 0 评论 0原文

我有一个库,从不同的构建系统移植,具有以下结构:

.
└── 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文