I am trying to add external header file (like OpenCL header file) for some experimentation for tensorflow. I tried to add this into BUILD file under tensorflow/core/BUILD fi
You have to add the files as a dependency of this rule.
IIUC, you have the following structure:
tensorflow/
BUILD
WORKSPACE
tensorflow/
core/
BUILD
third_party/
include -> /opt/opencl/CL # or something like that
You want to expose the .h files in a way Bazel can understand/depend on, so open up the tensorflow/BUILD
file and add the following:
cc_library(
name = "opencl",
hdrs = glob(["third_party/include/*.h"]),
visibility = ["//visibility:public"],
)
This creates a C++ library from the .h files under third_party/include, which can be depended on from anywhere in the source tree.
Now go to your tensorflow/core/BUILD
file and add a dependency to the cc_library there:
cc_library(
name = "all_kernels",
visibility = ["//visibility:public"],
copts = tf_copts() + ["-Ithird_party/include"],
deps = [
"//:opencl",
# plus any other deps
],
)
Setting copts just changes the flags when gcc is run. Adding //:opencl
to the dependencies tells Bazel to make those files available when gcc is run.