Skip to content

Commit

Permalink
--
Browse files Browse the repository at this point in the history
MOS_MIGRATED_REVID=100930529
  • Loading branch information
Rumou Duan authored and lberki committed Aug 20, 2015
1 parent ee082d0 commit 28fe4da
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,19 +642,21 @@ CompilationSupport registerJ2ObjcCompileAndArchiveActions(ObjcProvider objcProvi
}

for (J2ObjcSource j2ObjcSource : j2ObjcSources) {
J2ObjcSource sourceToCompile =
j2ObjcSource.getSourceType() == SourceType.JAVA && stripJ2ObjcDeadCode
? j2ObjcSource.toPrunedSource(ruleContext)
: j2ObjcSource;
IntermediateArtifacts intermediateArtifacts =
ObjcRuleClasses.j2objcIntermediateArtifacts(ruleContext, sourceToCompile);
CompilationArtifacts compilationArtifact = new CompilationArtifacts.Builder()
.addNonArcSrcs(sourceToCompile.getObjcSrcs())
.setIntermediateArtifacts(intermediateArtifacts)
.setPchFile(Optional.<Artifact>absent())
.build();
registerCompileAndArchiveActions(compilationArtifact, intermediateArtifacts, objcProvider,
ruleContext.getConfiguration().isCodeCoverageEnabled());
if (j2ObjcSource.hasSourceFiles()) {
J2ObjcSource sourceToCompile =
j2ObjcSource.getSourceType() == SourceType.JAVA && stripJ2ObjcDeadCode
? j2ObjcSource.toPrunedSource(ruleContext)
: j2ObjcSource;
IntermediateArtifacts intermediateArtifacts =
ObjcRuleClasses.j2objcIntermediateArtifacts(ruleContext, sourceToCompile);
CompilationArtifacts compilationArtifact = new CompilationArtifacts.Builder()
.addNonArcSrcs(sourceToCompile.getObjcSrcs())
.setIntermediateArtifacts(intermediateArtifacts)
.setPchFile(Optional.<Artifact>absent())
.build();
registerCompileAndArchiveActions(compilationArtifact, intermediateArtifacts, objcProvider,
ruleContext.getConfiguration().isCodeCoverageEnabled());
}
}

return this;
Expand All @@ -668,7 +670,8 @@ private void registerJ2ObjcDeadCodeRemovalActions(Iterable<J2ObjcSource> j2ObjcS
NestedSet<Artifact> j2ObjcHeaderMappingFiles = provider.getHeaderMappingFiles();

for (J2ObjcSource j2ObjcSource : j2ObjcSources) {
if (j2ObjcSource.getSourceType() == SourceType.JAVA) {
if (j2ObjcSource.getSourceType() == SourceType.JAVA
&& j2ObjcSource.hasSourceFiles()) {
Iterable<Artifact> sourceArtifacts = j2ObjcSource.getObjcSrcs();
Iterable<Artifact> prunedSourceArtifacts =
j2ObjcSource.toPrunedSource(ruleContext).getObjcSrcs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.RuleContext;
Expand Down Expand Up @@ -137,6 +138,13 @@ public SourceType getSourceType() {
return sourceType;
}

/**
* Returns whether this {@link J2ObjcSource} contains any ObjC source (.m, .mm) files.
*/
public boolean hasSourceFiles() {
return !Iterables.isEmpty(objcSrcs);
}

@Override
public final boolean equals(Object other) {
if (!(other instanceof J2ObjcSource)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ static Iterable<Artifact> j2ObjcLibraries(RuleContext ruleContext) {

// TODO(bazel-team): Refactor the code to stop flattening the nested set here.
for (J2ObjcSource j2ObjcSource : J2ObjcSrcsProvider.buildFrom(ruleContext).getSrcs()) {
j2objcLibraries.add(j2objcIntermediateArtifacts(ruleContext, j2ObjcSource).archive());
if (j2ObjcSource.hasSourceFiles()) {
j2objcLibraries.add(j2objcIntermediateArtifacts(ruleContext, j2ObjcSource).archive());
}
}

return j2objcLibraries.build();
Expand Down

0 comments on commit 28fe4da

Please sign in to comment.