如果您尝试在 下构建所有内容 third_party/flatbuffers
,它建议的命令 - bazel query //third_party/flatbuffers:*
- 是一个好主意,但由于此 repo 的奇怪设置,它会失败。
运行时 bazel query @flatbuffers//... --keep_going
,我得到以下输出:
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers___init___py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers__version_py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers_builder_py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers_compat_py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers_encode_py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers_flexbuffers_py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers_number_types_py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers_packer_py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers_table_py
@flatbuffers//:flatbuffer_py_strip_prefix_python_flatbuffers_util_py
@flatbuffers//:flatbuffers
@flatbuffers//:flatc
@flatbuffers//:flatc_headers
@flatbuffers//:flatc_library
@flatbuffers//:platform_freebsd
@flatbuffers//:platform_openbsd
@flatbuffers//:public_headers
@flatbuffers//:runtime_cc
@flatbuffers//:runtime_py
@flatbuffers//:runtime_py_srcs
@flatbuffers//:windows
@flatbuffers//grpc/src/compiler:common_headers
@flatbuffers//grpc/src/compiler:cpp_generator
@flatbuffers//grpc/src/compiler:distribution
@flatbuffers//grpc/src/compiler:go_generator
@flatbuffers//grpc/src/compiler:java_generator
@flatbuffers//grpc/src/compiler:python_generator
@flatbuffers//grpc/src/compiler:python_generator_private
@flatbuffers//grpc/src/compiler:swift_generator
@flatbuffers//grpc/src/compiler:ts_generator
@flatbuffers//grpc/tests:grpc_test
@flatbuffers//reflection:distribution
@flatbuffers//reflection:reflection_fbs_schema
@flatbuffers//src:code_generators
@flatbuffers//src:distribution
@flatbuffers//src:flatbuffers
@flatbuffers//src:flatc
@flatbuffers//src:flatc_library
@flatbuffers//src:generate_fbs
进去 third_party/flatbuffers/BUILD.oss
看看你需要哪些。我怀疑是 @flatbuffers//:flatbuffers
.
根据您的说法,我猜这并不一定是可重现的,所以我们可以放心地进行破解而不必担心将其与 Bazel 集成?
尝试这样的操作:
# Outputs are built into a tree you can find at the path `$(bazel info execution_root)`
$ bazel build //third_party/flatbuffers/...
# You'll also need to build everything else you're depending on...
然后,将该 execution_root
路径复制到您的 cmake 脚本中。这可能会让您摆脱困境。
但是,该路径有一个哈希,它不能跨机器工作;您需要与 bazel 集成才能获得进一步的效果。
像这样:
# In the root BUILD file
cc_binary(
srcs = ["your_file_name.cc"],
deps = [
"@flatbuffers//:flatbuffers", # Or whichever one you find you need
... # Other deps you need here.
],
copts = ["-std=c++17"],
)