aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Mike Lewis <lewis@squareup.com>2018-03-29 10:34:53 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-29 10:36:10 -0700
commitd2f33add4d8242156828d0c146538b831cc27081 (patch)
treedbfb4d4dff223b237d2e1b9c29c89b6cf43b69ea /src/main/java
parentf2b66aa31b0a3addb2f3712c6232f4c8c65b55db (diff)
Fixing issue with external j2objc protos (reattempt at #4058)
This is a re-attempt at https://github.com/bazelbuild/bazel/pull/4058 which got reverted via https://github.com/bazelbuild/bazel/issues/4780 #4780 was being caused because cc plugin and j2objc plugin used different paths for outputs. I also manually verified that this works for both external cc_proto_librarys and external j2objc java_proto_libraries. The output files are created without a repository, but the expected filenames have them This resolves issues when having a proto_library from an external build file. cc @c-parsons @pmbethe09 Closes #4793. PiperOrigin-RevId: 190950452
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java
index 7f325a3016..c12faf2e1c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java
@@ -630,11 +630,10 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
.addAll(outputClassMappingFiles)
.build();
+ String genfilesPath = getProtoOutputRoot(ruleContext).getPathString();
+
String langPluginParameter =
- String.format(
- "%s:%s",
- Joiner.on(',').join(J2OBJC_PLUGIN_PARAMS),
- ruleContext.getConfiguration().getGenfilesFragment().getPathString());
+ String.format("%s:%s", Joiner.on(',').join(J2OBJC_PLUGIN_PARAMS), genfilesPath);
SupportData supportData = base.getProvider(ProtoSupportDataProvider.class).getSupportData();
@@ -744,11 +743,8 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
private static J2ObjcSource protoJ2ObjcSource(
RuleContext ruleContext, ImmutableList<Artifact> protoSources) {
- PathFragment objcFileRootExecPath =
- ruleContext
- .getConfiguration()
- .getGenfilesDirectory(ruleContext.getRule().getRepository())
- .getExecPath();
+ PathFragment objcFileRootExecPath = getProtoOutputRoot(ruleContext);
+
Iterable<PathFragment> headerSearchPaths =
J2ObjcLibrary.j2objcSourceHeaderSearchPaths(
ruleContext, objcFileRootExecPath, protoSources);
@@ -762,6 +758,14 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF
headerSearchPaths);
}
+ private static PathFragment getProtoOutputRoot(RuleContext ruleContext) {
+ return ruleContext
+ .getConfiguration()
+ .getGenfilesFragment()
+ .getRelative(
+ ruleContext.getLabel().getPackageIdentifier().getRepository().getPathUnderExecRoot());
+ }
+
private static boolean isProtoRule(ConfiguredTarget base) {
return base.getProvider(ProtoSourcesProvider.class) != null;
}