Is there any directive to let bazel ignore BUILD files from sub-directories?

2,731 views
Skip to first unread message

Ming Zhao

unread,
Apr 9, 2015, 12:30:05 AM4/9/15
to bazel-...@googlegroups.com
Here is the problem:

I have a project that has a collection of balze BUILD files that kind
of builds grpc, protobuf and does something basic for proto_library:
https://github.com/mzhaom/trunk

The model I followed is for each open source project, I created a
upstream directory to host its vanilla source and create a BUILD as a
sibling to describe how to build this project. It works well for most
of them, but it doesn't work for grpc because grpc has its own BUILD
file(https://github.com/grpc/grpc/blob/master/BUILD), so that bazel
complains when it processes my BUILD
file(https://github.com/mzhaom/trunk/blob/master/third_party/grpc/BUILD):

ERROR: /usr/local/home/mzhao/g/trunk/third_party/grpc/BUILD:234:10:
Label '//third_party/grpc:upstream/src/core/transport/chttp2/bin_encoder.c'
crosses boundary of subpackage 'third_party/grpc/upstream' (perhaps
you meant to put the colon here:
'//third_party/grpc/upstream:src/core/transport/chttp2/bin_encoder.c'?).

I'll try to work with grpc team to get this particular problem solved.
But I feel like as bazel becomes more and more popular, there will be
more and more projects shipped with BUILD files in the source, so
having the ability to ignore certain BUILD files might be a nice to
have feature.

Thanks.

Ulf Adams

unread,
Apr 9, 2015, 3:55:55 AM4/9/15
to Ming Zhao, bazel-...@googlegroups.com, Kristina Chodorow
There is no way to ignore build files. However, we're hoping that you can use the existing BUILD files rather than writing your own. Adding Kristina, who's more of an expert in that area.


--
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 post to this group, send email to bazel-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAN0GiO2hNaNczm3wNhUJZMMLJwHu56xkRBD9zTd1TvqFB7swpw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Kristina Chodorow

unread,
Apr 9, 2015, 10:00:28 AM4/9/15
to Ulf Adams, Ming Zhao, bazel-...@googlegroups.com
If you're embedding the source, you should probably just use the grpc targets as deps.  Something like:

cc_library(
    name = "my-grpc",
    visibility = ["//visibility:public"],
    deps = ["//third_party/grpc/upstream:grpc"],
)

Unfortunately, they don't declare any of the targets in that BUILD file as publicly visible, so you'll get a permissions error if you do that.  I think they probably should make some of them visible (maybe submit a patch for that?), but until they do, you might want to use the --nocheck_visibility option (http://bazel.io/docs/bazel-user-manual.html#flag--check_visibility).

anzd...@gmail.com

unread,
Aug 18, 2016, 8:00:02 PM8/18/16
to bazel-discuss, ulf...@google.com, ming...@gmail.com
Has this changed since?

I have a third-party subdirectory in an npm module that recently introduced a non-Bazel file called BUILD. As a result, "bazel build //..." no longer works.

benjam...@hp.com

unread,
Mar 10, 2017, 12:56:25 PM3/10/17
to bazel-discuss
There is another more compelling reason to have this feature. Some open-source projects have files named BUILD that are not Bazel build files.
One example is jshint  which has the file bin/build and it is clearly not a Bazel BUILD file and it causes bazel query //... to fail.   It'd be nice to have a way to tell bazel that some build files are to be ignored.
My current workaround is to clone the node module and manually modify it such that those files are renamed.

Thanks,
Ben Ward

George Gensure

unread,
Mar 10, 2017, 1:12:32 PM3/10/17
to benjam...@hp.com, bazel-discuss
You want --deleted-packages=<package-path,package-path...>

The package-path is the unrooted component of the package name you want to omit: '//foo/bar/omitme' => '--deleted-packages=foo/bar/omitme'

-George

--
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-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/7515b5e6-3634-4119-ac70-2b3a63eb171f%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages