bazel include and absolute paths

4,385 views
Skip to first unread message

cruise...@gmail.com

unread,
Jan 20, 2016, 7:12:59 PM1/20/16
to bazel-discuss
I tried to use an absolute path in an includes attribute to handle a prefix to a 3rd party library and it appears that I can't use absolute paths in includes attributes. Should this work?

cc_binary(
name = "demo",
srcs = glob(["**/*.cpp"]),
includes=["/usr/local/include/eigen3"],
)

in includes attribute of cc_binary rule //example/eigen:demo: ignoring invalid absolute path '/usr/local/include/eigen3'

Austin Schuh

unread,
Jan 20, 2016, 7:40:07 PM1/20/16
to cruise...@gmail.com, bazel-discuss
No, this shouldn't work.

You should create a new_local_repository which creates a cc_library which contains the Eigen header files.

Austin

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/efb4b4ac-2326-4797-8dff-fa62a08940fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

cruise...@gmail.com

unread,
Jan 21, 2016, 8:51:27 PM1/21/16
to bazel-discuss, cruise...@gmail.com
That seems like a lot of effort just to cover the prefix directory that the headers are under. In this case it's coming from the homebrew install for Eigen and it seems bad that it instals that way with the prefix, but there appear to be many libraries that do this.

erik

Brian Silverman

unread,
Jan 21, 2016, 8:58:17 PM1/21/16
to cruise...@gmail.com, bazel-discuss
Bazel tends to be easier to use with files downloaded or checked into the source tree than off the system. They stay the same between systems and don't require installing dependencies to build.

For Eigen in particular, using source files not from the system and writing a BUILD file is really easy. I'm using the following BUILD file for eigen imported as third_party/eigen using git-subtree (it should work as a .BUILD file for a new_http_repository with a source tarball too):

licenses(['notice'])

cc_library(
  name = 'eigen',
  visibility = ['//visibility:public'],
  srcs = glob(['Eigen/src/**/*.h']),
  includes = ['.'],
  hdrs = glob(['Eigen/*']),
)

Reply all
Reply to author
Forward
0 new messages