Hi Bazelites,
I'm trying out new_local_repository, and cc_binary isn't play nicely with it. I've set up a "local repository" at /tmp/mylib, which consists of the files getx.h and getx.cc. In WORKSPACE of my project, I add
new_local_repository(
name = "mylib",
path = "/tmp/mylib",
build_file = "mylib.BUILD",
)
In mylib.BUILD, I have
cc_library(
name = "getx",
hdrs = ["getx.h"],
srcs = ["getx.cc"],
visibility = ["//visibility:public"],
)
Then in my main project, I have system/hello.cc (the "system" package just being a convenient one to stick it in), which #include-s getx.h. Its compilation rule is
cc_binary(
name = "hello",
srcs = ["hello.cc"],
deps = ["@mylib//:getx"],
copts = ["-I/tmp/mylib"],
)
Then when I "bazel build system:hello", Bazel complains:
in cc_binary rule //system:hello: The include path '/tmp/mylib' references a path outside of the execution root..
As an alternative, I split the -I flag into two components:
copts = ["-I", "/tmp/mylib"]
In this case, Bazel complains:
undeclared inclusion(s) in rule '//system:hello'
But unlike the previous case, if I build with -s, it spits out a command line, which runs successfully if I invoke it manually.
Am I missing something, or is cc_binary being overly cautious?
Thanks,
Onath