rules_proto_grpc
rules_proto_grpc copied to clipboard
Control output path not to include label.package name?
Description
We have our own folder structure that we have protos into which is causing an issue with the generated import paths.
e.g. given the following .proto folder structure:
protos/google/protobuf/descriptor.proto
protos/company/common/common.proto (which imports descriptor.proto).
When invoking the rules, they append the package as the output folder from here https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/internal/common.bzl#L352-L353
e.g
bazel build protos//company/common:common_proto
This causes a failure in the generated #import statements from protoc.
The final output as it is right now is:
out/google/protobuf/_rpg_premerge_descriptor_proto_objc_pb
out/google/protobuf/google/protobuf/.h,.m
out/company/common/_rpg_premerge_common_proto_objc_pb
out/company/common/company/common/.h.m
However the imports protoc outputs are all relative to the structure we use so it the case above it outputs #import "../../google/protobuf" which fails compilation for common proto given the output folder structure the rules_proto_grpc use.
What we want is:
out/google/protobuf/_rpg_premerge_descriptor_proto_objc_pb/...
out/google/protobuf/.h,.m # <-----
out/company/common/_rpg_premerge_common_proto_objc_pb/...
out/company/common/.h.m # <-----
Is there a workaround or something we are missing in achieving this?
How are you using the generated Obj-C library? If you are using objc_proto_library, the target should have the correct includes attr to ensure the generated imports are valid when used from a downstream objc_library.
@aaliddell we use objc_proto_compile and feed that into an apple_framework from https://github.com/bazel-ios/rules_ios.
Not sure if its happening because of that or not, I should try to get you a sample scenario perhaps to demonstrate it...
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.
So the way this works internally is that the objc_proto_library is setting the includes attr correctly to hide the label name:
https://github.com/rules-proto-grpc/rules_proto_grpc/blob/58f568397f3707e072c3e94493c380edea04337c/objc/objc_grpc_library.bzl#L38
Looking into rules_ios it appears you might be able to propagate that attr through the kwargs, so you could try:
apple_framework(
name = "something",
includes = ["something_pb"],
...
)
Otherwise, you could try using objc_proto_library from these rules and pass the library to the deps attr of apple_framework, but that might complain about having no srcs.