diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build')
7 files changed, 28 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java index f9cb428ec1..c01fbda176 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java @@ -144,7 +144,9 @@ public abstract class AbstractJ2ObjcProtoAspect implements ConfiguredNativeAspec j2ObjcSource.getHeaderSearchPaths(), DEPENDENT_ATTRIBUTES); - new CompilationSupport(ruleContext).registerCompileAndArchiveActions(common); + new CompilationSupport(ruleContext) + .registerCompileAndArchiveActions(common) + .registerFullyLinkAction(common.getObjcProvider()); } NestedSet<Artifact> j2ObjcTransitiveHeaderMappingFiles = j2ObjcTransitiveHeaderMappingFiles( diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java index fccce46fe1..61fc0748ac 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java @@ -102,6 +102,7 @@ abstract class BinaryLinkingTargetFactory implements RuleConfiguredTargetFactory CompilationSupport compilationSupport = new CompilationSupport(ruleContext) .registerCompileAndArchiveActions(common) + .registerFullyLinkAction(common.getObjcProvider()) .addXcodeSettings(xcodeProviderBuilder, common) .registerLinkActions( objcProvider, diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index 57e5215e23..73e07e9baa 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -255,8 +255,7 @@ public final class CompilationSupport { * @param common common information about this rule and its dependencies * @return this compilation support */ - CompilationSupport registerCompileAndArchiveActions(ObjcCommon common) - throws InterruptedException { + CompilationSupport registerCompileAndArchiveActions(ObjcCommon common) { if (common.getCompilationArtifacts().isPresent()) { registerGenerateModuleMapAction(common.getCompilationArtifacts()); Optional<CppModuleMap> moduleMap; @@ -269,8 +268,7 @@ public final class CompilationSupport { common.getCompilationArtifacts().get(), common.getObjcProvider(), moduleMap, - buildConfiguration.isCodeCoverageEnabled(), - true); + buildConfiguration.isCodeCoverageEnabled()); } return this; } @@ -283,8 +281,7 @@ public final class CompilationSupport { CompilationArtifacts compilationArtifacts, ObjcProvider objcProvider, Optional<CppModuleMap> moduleMap, - boolean isCodeCoverageEnabled, - boolean isFullyLinkEnabled) throws InterruptedException { + boolean isCodeCoverageEnabled) { ImmutableList.Builder<Artifact> objFiles = new ImmutableList.Builder<>(); for (Artifact sourceFile : compilationArtifacts.getSrcs()) { Artifact objFile = intermediateArtifacts.objFile(sourceFile); @@ -324,10 +321,6 @@ public final class CompilationSupport { for (Artifact archive : compilationArtifacts.getArchive().asSet()) { registerArchiveActions(objFiles, archive); } - - if (isFullyLinkEnabled) { - registerFullyLinkAction(objcProvider); - } } /** @@ -683,9 +676,16 @@ public final class CompilationSupport { return actions.build(); } - private void registerFullyLinkAction(ObjcProvider objcProvider) throws InterruptedException { - Artifact archive = ruleContext.getImplicitOutputArtifact(FULLY_LINKED_LIB); - + /** + * Registers an action to create an archive artifact by fully (statically) linking all + * transitive dependencies of this rule. + * + * @param objcProvider provides all compiling and linking information to create this artifact + */ + public CompilationSupport registerFullyLinkAction(ObjcProvider objcProvider) + throws InterruptedException { + Artifact outputArchive = + ruleContext.getImplicitOutputArtifact(CompilationSupport.FULLY_LINKED_LIB); ImmutableList<Artifact> ccLibraries = ccLibraries(objcProvider); ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder( ruleContext, appleConfiguration.getIosCpuPlatform()) @@ -696,7 +696,7 @@ public final class CompilationSupport { .add("-static") .add("-arch_only").add(appleConfiguration.getIosCpu()) .add("-syslibroot").add(AppleToolchain.sdkDir()) - .add("-o").add(archive.getExecPathString()) + .add("-o").add(outputArchive.getExecPathString()) .addExecPaths(objcProvider.get(LIBRARY)) .addExecPaths(objcProvider.get(IMPORTED_LIBRARY)) .addExecPaths(ccLibraries) @@ -704,8 +704,9 @@ public final class CompilationSupport { .addInputs(ccLibraries) .addTransitiveInputs(objcProvider.get(LIBRARY)) .addTransitiveInputs(objcProvider.get(IMPORTED_LIBRARY)) - .addOutput(archive) + .addOutput(outputArchive) .build(ruleContext)); + return this; } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java index db48de1e84..89541d6508 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosTest.java @@ -134,6 +134,7 @@ public final class IosTest implements RuleConfiguredTargetFactory { .registerLinkActions( common.getObjcProvider(), extraLinkArgs, extraLinkInputs, DsymOutputType.TEST) .registerCompileAndArchiveActions(common) + .registerFullyLinkAction(common.getObjcProvider()) .addXcodeSettings(xcodeProviderBuilder, common) .validateAttributes(); 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 10cf0b2610..3ff31cfe0e 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 @@ -154,7 +154,9 @@ public class J2ObjcAspect implements ConfiguredNativeAspectFactory { j2ObjcSource.getHeaderSearchPaths(), DEPENDENT_ATTRIBUTES); - new CompilationSupport(ruleContext).registerCompileAndArchiveActions(common); + new CompilationSupport(ruleContext) + .registerCompileAndArchiveActions(common) + .registerFullyLinkAction(common.getObjcProvider()); } else { common = common( ruleContext, diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java index 9c03bf3053..88e7a219d6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java @@ -113,6 +113,7 @@ public class ObjcLibrary implements RuleConfiguredTargetFactory { CompilationSupport compilationSupport = new CompilationSupport(ruleContext) .registerCompileAndArchiveActions(common) + .registerFullyLinkAction(common.getObjcProvider()) .addXcodeSettings(xcodeProviderBuilder, common) .validateAttributes(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java index b6078bb6d1..e46d8204ec 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibrary.java @@ -50,7 +50,9 @@ public class ObjcProtoLibrary implements RuleConfiguredTargetFactory { filesToBuild.addAll(common.getCompiledArchive().asSet()); - new CompilationSupport(ruleContext).registerCompileAndArchiveActions(commonBuilder.build()); + new CompilationSupport(ruleContext) + .registerCompileAndArchiveActions(commonBuilder.build()) + .registerFullyLinkAction(common.getObjcProvider()); new XcodeSupport(ruleContext) .addFilesToBuild(filesToBuild) |