将lib用作外部库时,为什么会出现未声明的包含错误?

时间:2018-06-27 01:08:58

标签: windows bazel

我试图在我的bazel构建中包括一个外部库(glm),但未声明包含它是因为我不知道如何解决它以及为什么,因为如果我在提取时使用相同的BUILD脚本手动建立良好的库。

我设法对这个问题做了一个很小的复制,无论是工作情况还是不工作。

无效的示例

我的文件夹结构

  • glmExtBuild
    • WORKSPACE
    • 外部人
      • glm.BUILD

这是我的WORKSPACE文件

new_http_archive(
  name = "glmExt",
  url = "https://github.com/g-truc/glm/archive/0.9.9.0.tar.gz",
  sha256 = "514dea9ac0099dc389cf293cf1ab3d97aff080abad55bf79d4ab7ff6895ee69c",
  strip_prefix = "glm-0.9.9.0",
  build_file = "externals/glm.BUILD",
)

这是我的glm.BUILD文件

package(default_visibility = ["//visibility:public"])
cc_library(
  name= "glm",
  defines= ["GLM_ENABLE_EXPERIMENTAL", "GLM_FORCE_RADIANS", 
  "GLM_FORCE_DEPTH_ZERO_TO_ONE"],
  srcs=glob(["glm/**/*.cpp"]) + ["glm/detail/_fixes.hpp"],
  hdrs=glob(["glm/**/*.hpp"])+glob(["glm/**/*.h"]),
  includes = ["glm"],
  textual_hdrs = glob(["glm/**/*.inl"]),
  visibility = ["//visibility:public"],
)

这是我跑步时遇到的错误

bazel build @glmExt//:glm --verbose_failures --sandbox_debug

ERROR: C:/users/...../external/glmExt/BUILD.bazel:121:1: undeclared inclusion(s) in rule '@glmExt//:glm':
this rule is missing dependency declarations for the following files included by 'external/glmExt/glm/detail/glm.cpp': 
'external/glmext/glm/detail/_fixes.hpp'
'external/glmext/glm/detail/setup.hpp'
'external/glmext/glm/simd/platform.h'
'external/glmext/glm/fwd.hpp'
'external/glmext/glm/detail/setup.hpp'
'external/glmext/glm/detail/type_int.hpp'
'external/glmext/glm/detail/setup.hpp'
'external/glmext/glm/detail/type_float.hpp'
...

工作示例:

我的文件夹结构

我的WORKSPACE文件为空

这是我的构建文件

package(default_visibility = ["//visibility:public"])
cc_library(
  name= "glm",
  defines= ["GLM_ENABLE_EXPERIMENTAL", "GLM_FORCE_RADIANS", "GLM_FORCE_DEPTH_ZERO_TO_ONE"],
  srcs=glob(["glmSrc/glm/**/*.cpp"]) + ["glmSrc/glm/detail/_fixes.hpp"],
  hdrs=glob(["glmSrc/glm/**/*.hpp"])+glob(["glmSrc/glm/**/*.h"]),
  includes = ["glmSrc"],
  textual_hdrs = glob(["glmSrc/glm/**/*.inl"]),
  visibility = ["//visibility:public"],
)

然后,在运行构建命令时,它成功完成。

PS D:\......\glmBuild2> bazel build :glm --verbose_failures --sandbox_debug
INFO: Analysed target //:glm (1 packages loaded).
INFO: Found 1 target...
INFO: From Compiling glmSrc/glm/detail/glm.cpp:
glmSrc/glm/detail/glm.cpp(4): warning C4005: 'GLM_ENABLE_EXPERIMENTAL': macro redefinition
glmSrc/glm/detail/glm.cpp(4): note: command-line arguments:  see previous definition of 'GLM_ENABLE_EXPERIMENTAL'
Target //:glm up-to-date:
  C:/users/.../execroot/__main__/bazel-out/x64_windows-fastbuild/bin/libglm.a
INFO: Elapsed time: 1.830s, Critical Path: 1.30s
INFO: 3 processes, local.
INFO: Build completed successfully, 4 total actions

有人有想法吗? 谢谢

更新:

bazel version
Build label: 0.14.0
Build target: bazel-out/x64_windows-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jun 1 13:06:29 2018 (1527858389)
Build timestamp: 1527858389
Build timestamp as int: 1527858389

Bazel问题: https://github.com/bazelbuild/bazel/issues/5485

1 个答案:

答案 0 :(得分:0)

我在balzel 0.15.0上的linux上尝试了第一个示例,并且一旦添加了“”,所有示例都可以工作。放入includes的{​​{1}}属性中。您有可能在linux上对其进行测试吗?那是Windows的唯一问题吗?您使用哪种bazel版本?

感谢您的澄清。