我正在尝试在一个ArduinoJson bazel项目中使用C++。它是一个只有头的库,在src下的子目录中有标头。但是我得到了一个未声明的包含错误。
//Third-Party/ArduinoJson cc_library def是这样的:
cc_library(
name = "ArduinoJson",
hdrs = glob(["5.12.0/src/**"]),
includes = [
"5.12.0/src",
"5.12.0/src/ArduinoJson",
],
visibility = ["//visibility:public"],
)使用它的目标(序列化)确实在它的deps中有//Third-Party/ArduinoJson
以下是错误:
ERROR: /[...]/Serialization/BUILD:1:1: undeclared inclusion(s) in rule '//[...]/Serialization:Serialization':
this rule is missing dependency declarations for the following files included by '[...]/Serialization/JsonDeserializer.cpp':
'[...]/Third-Party/ArduinoJson/5.12.0/src/ArduinoJson/Data/Encoding.hpp'
'[...]/Third-Party/ArduinoJson/5.12.0/src/ArduinoJson/Serialization/FloatParts.hpp'
'[...]/Third-Party/ArduinoJson/5.12.0/src/ArduinoJson/Polyfills/math.hpp'
'[...]/Third-Party/ArduinoJson/5.12.0/src/ArduinoJson/TypeTraits/FloatTraits.hpp'
Target //[...]/Serialization:Serialization failed to build因为它只是在抱怨src子目录中的文件,例如src/Data/Encoding.hpp,我猜这可能和它有关吧?
这不是"How to resolve bazel “undeclared inclusion(s)” error?"的复制,因为这个问题是通过执行我已经使用deps所做的事情来解决的。
发布于 2018-01-10 07:13:46
确保Third-Party/ArduinoJson的子目录中没有构建文件,否则Bazel将这些文件视为包,而glob不会从它们中提取文件。
如果在这些子目录中有构建文件,则需要在这些子目录中创建cc_library规则,导出//Third-Party/ArduinoJson:ArduinoJson中所需的头部,并依赖于来自ArduinoJson的这些cc_libraries。
https://stackoverflow.com/questions/48116530
复制相似问题