0

我将 cmocka 与 Bazel 一起使用,我想在我的测试文件(用于 c 嵌入式代码)中导入 cmocka 库,例如 <cmocka.h> 但我总是得到: cmocka.h: No such file or directory。

我的构建是:

cc_library(
    name = "mock",
    srcs = ["mock_i2c.c"],
    deps = [":src"],
    visibility = ["//visibility:public"],
    linkstatic = True,
    copts = ["-I test/cmocka/include"],
)
4

1 回答 1

0

这种情况有一个包含属性,您还需要将标题添加到hdrs属性中:

cc_library(
    name = "mock",
    srcs = ["mock_i2c.c"],
    deps = [":src"],
    hdrs = glob(["test/cmocka/include/**/*.h"]),
    visibility = ["//visibility:public"],
    linkstatic = True,
    includes= ["test/cmocka/include"],
)
于 2021-06-30T20:34:59.690 回答