Why do I get undeclared inclusion error when using the lib as external library?

975 views Asked by At

I am trying to include an external library (glm) in my bazel build, but I get undeclared inclusion the thing is I don't understand how to fix it and why, Because if I use the same BUILD script when I extract manually the library it builds fine.

I managed to make a very small repro of this problem, both the working case and the not working.

The not working example

My folder structure

  • glmExtBuild
    • WORKSPACE
    • externals
      • glm.BUILD

This is my WORKSPACE file

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",
)

This is my glm.BUILD file

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"],
)

And this is the errors that I get when I run

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'
...

The working example:

My folder structure

My WORKSPACE file is empty

And this is my BUILD file

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"],
)

Then when running the build command it finished successfully.

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

Does anybody have an idea? Thanks

Update:

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 issue: https://github.com/bazelbuild/bazel/issues/5485

1

There are 1 answers

6
hlopko On

I tried the first example on linux, with bazel 0.15.0, and all worked once I added "." into includes attribute of glm. Do you have a possibility to test it on linux? Is it windows-only issue then? Which bazel version do you use?

Thanks for clarifications.