Closed jemeador closed 1 year ago
Hmm, in theory we could just disable setting includes
when output mode is set non-default, since the current include points to a directory that I don't think exists. If you run bazel clean
and relist your bazel-out/armeabi-v7a-opt/bin/external/my_defs_repo/my_defs
directory after a build with includes = [name_pb]
removed, do you still see the foo_message_cc_pb
directory?
If I recall correctly, the foo_message_cc_pb
is absent if includes = [name_pb]
is removed
Could you try using the branch cpp-output-mode
?
http_archive(
name = "rules_proto_grpc",
sha256 = "90a2c4516891484841259239b83ae050a109cabb8466f2410e7b387b71bc89c9",
strip_prefix = "rules_proto_grpc-6a5dd8156e29c151fa4babdbd1780dfd6a00271c",
urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/6a5dd8156e29c151fa4babdbd1780dfd6a00271c.tar.gz"],
)
This works! I'll play with it a bit and see if I can get the headers pulled in as -isystem
instead of -iquote
I was able to get this hammered into shape with something like this
I changed the cpp_proto_library
(and grpc) rule to use includes = '.'
. Ideally, includes
would be configurable, but default to something reasonable.
protos are in //mydefs/package_name
//my_defs/BUILD.bazel:
cpp_proto_library(
name = "foo_message_cc",
protos = [":foo_message_proto"],
copts = ["-I", "$(GENDIR)/my_defs/"],
deps = [
":bar_message_cc",
],
output_mode = "NO_PREFIX",
)
proto_library(
name = "foo_message_proto",
strip_import_prefix = "/mydefs",
srcs = ["package_name/foo_message.proto"],
deps = [
":bar_message_proto",
],
)
This gives me the -isystem
path I need without redundancy.
Closed by #276
Description
I'm trying to get the most out of Bazel for our C++ builds, and the first step is breaking up some monolithic
cpp_proto_library
rules. I've created some automation in my project to split up a small set of giant protobuf files into a large set of fine-grainedproto_library
andcpp_proto_library
build rules. The automation produces build rules that work just fine when using clang. Unfortunately, this does not work on our target platform. On ARM, gcc8 complains about argument lists being too long.I get this error because I now have hundreds of compiler flags for every
cc_*
rule that indirectly depends on the full set of generated protos and C++ headers. Running the build with-s
shows the problem:There is a pair of
-isystem
flags for every one of the nearly 1000cpp_*_library
rules.I can use
output_mode = "NO_PREFIX"
incpp_*_library
to get all headers in one output directory, but Bazel still tries to include some rule-specific paths instead of the flattened-out directory. This is what my output directory looks like underbazel-out/armeabi-v7a-opt/bin/external/my_defs_repo/my_defs
:Changing the
cpp_*_library
rules to omit the lineincludes = [name_pb],
from the underlyingcc_library
rule fixes the problem. The redundantfoo_message_cc_pb
andbar_message_cc_pb
directories are omitted, and only one include path is necessary. Can we allow the configuration ofincludes
to make the best use ofoutput_mode = "NO_PREFEIX"
in this situation? Ideally, the rule would continue to transitively include these headers as system headers as well (with my change, they are only available under an-iquote
path).