diff options
author | Sergio Campama <kaipi@google.com> | 2016-10-28 15:34:33 +0000 |
---|---|---|
committer | John Cater <jcater@google.com> | 2016-10-28 16:04:38 +0000 |
commit | c733d1f2427d98bf7aa032a34e6348cd122f9712 (patch) | |
tree | 56dfb3eddb1d06f9464857c5ed64fb91d3b24fda /src | |
parent | 8949c07973c52fb5c3f0ff8558c3254c3bad50b4 (diff) |
Disable protobuf modulemap generation if it's a linking target. Correctly configure protos intermediate artifacts to use the build configuration, if any provided.
--
MOS_MIGRATED_REVID=137514384
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java index 47cd02e308..9bbe1dd9da 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ProtobufSupport.java @@ -64,6 +64,7 @@ final class ProtobufSupport { private final RuleContext ruleContext; private final BuildConfiguration buildConfiguration; private final ProtoAttributes attributes; + private final IntermediateArtifacts intermediateArtifacts; // Each entry of this map represents a generation action and a compilation action. The input set // are dependencies of the output set. The output set is always a subset of, or the same set as, @@ -109,6 +110,13 @@ final class ProtobufSupport { this.buildConfiguration = buildConfiguration; this.attributes = new ProtoAttributes(ruleContext); this.inputsToOutputsMap = getInputsToOutputsMap(); + if (buildConfiguration != null) { + this.intermediateArtifacts = + ObjcRuleClasses.intermediateArtifacts(ruleContext, buildConfiguration); + } else { + this.intermediateArtifacts = + ObjcRuleClasses.intermediateArtifacts(ruleContext, ruleContext.getConfiguration()); + } } /** @@ -132,11 +140,9 @@ final class ProtobufSupport { } private void registerModuleMapGenerationAction() { - IntermediateArtifacts moduleMapIntermediateArtifacts = - ObjcRuleClasses.intermediateArtifacts(ruleContext); CompilationArtifacts.Builder moduleMapCompilationArtifacts = new CompilationArtifacts.Builder() - .setIntermediateArtifacts(moduleMapIntermediateArtifacts) + .setIntermediateArtifacts(intermediateArtifacts) .setPchFile(Optional.<Artifact>absent()) .addAdditionalHdrs(getProtobufHeaders()) .addAdditionalHdrs( @@ -144,7 +150,7 @@ final class ProtobufSupport { new CompilationSupport( ruleContext, - ObjcRuleClasses.intermediateArtifacts(ruleContext), + intermediateArtifacts, new CompilationAttributes.Builder().build()) .registerGenerateModuleMapAction(Optional.of(moduleMapCompilationArtifacts.build())); } @@ -210,12 +216,11 @@ final class ProtobufSupport { Iterable<PathFragment> userHeaderSearchPaths = ImmutableList.of(getWorkspaceRelativeOutputDir()); - IntermediateArtifacts moduleMapIntermediateArtifacts = - ObjcRuleClasses.intermediateArtifacts(ruleContext); - ObjcCommon.Builder commonBuilder = - new ObjcCommon.Builder(ruleContext) - .setIntermediateArtifacts(moduleMapIntermediateArtifacts) - .setHasModuleMap(); + ObjcCommon.Builder commonBuilder = new ObjcCommon.Builder(ruleContext); + + if (!isLinkingTarget()) { + commonBuilder.setIntermediateArtifacts(intermediateArtifacts).setHasModuleMap(); + } int actionId = 0; for (ImmutableSet<Artifact> inputProtos : inputsToOutputsMap.keySet()) { @@ -249,8 +254,6 @@ final class ProtobufSupport { } XcodeProvider.Builder xcodeProviderBuilder = new XcodeProvider.Builder(); - IntermediateArtifacts intermediateArtifacts = - ObjcRuleClasses.intermediateArtifacts(ruleContext); new XcodeSupport(ruleContext, intermediateArtifacts, getXcodeLabel(getBundledProtosSuffix())) .addXcodeSettings(xcodeProviderBuilder, getObjcProvider().get(), LIBRARY_STATIC); @@ -413,6 +416,13 @@ final class ProtobufSupport { } private IntermediateArtifacts getUniqueIntermediateArtifacts(int actionId) { + if (buildConfiguration != null) { + return new IntermediateArtifacts( + ruleContext, + getUniqueBundledProtosSuffix(actionId), + getUniqueBundledProtosPrefix(actionId), + buildConfiguration); + } return new IntermediateArtifacts( ruleContext, getUniqueBundledProtosSuffix(actionId), |