Bazel get full path of bazel-out/workspace in Skylark

1k views Asked by At

I want to integrate checkstyle with bazel following this SO thread: What is the best way to invoke Checkstyle from within Bazel?
which works perfectly as long as I provide the full harcoded path when building the classpath

checkstyle.bzl

for file in ctx.files._classpath:
    if add:
        classpath += ":"
    add=True
    classpath += "/home/user/src/repo/" + file.path
for file in ctx.files.deps:
    classpath += ":" + "/home/user/src/repo/" + file.path

The downloaded jars are living in the bazel-out dir on the same level with my WORKSPACE.

/home/user/src/repo/
- /bazel-out
- /tools
-- checkstyle.bzl
-- BUILD
- WORKSPACE

How can I get the full path of bazel-out so I can append it to file.path?

Also, it's my 3rd day working with bazel, if there is a better way to do this then please suggest.

0

There are 0 answers