diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc')
5 files changed, 46 insertions, 8 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 9ba7bb146a..80b056e56b 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 @@ -90,6 +90,9 @@ public abstract class AbstractJ2ObjcProtoAspect extends NativeAspectClass .add(attr("$xcrunwrapper", LABEL).cfg(HOST).exec() .value(Label.parseAbsoluteUnchecked( toolsRepository + "//tools/objc:xcrunwrapper"))) + .add(attr(ObjcRuleClasses.LIBTOOL_ATTRIBUTE, LABEL).cfg(HOST).exec() + .value(Label.parseAbsoluteUnchecked( + toolsRepository + "//tools/objc:libtool"))) .add(attr(":xcode_config", LABEL) .allowedRuleClasses("xcode_config") .checkConstraints() 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 882faebbce..3fff5d53bd 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 @@ -38,7 +38,6 @@ import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.CLANG_PLU import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.COMPILABLE_SRCS_TYPE; import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.DSYMUTIL; import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.HEADERS; -import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.LIBTOOL; import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.NON_ARC_SRCS_TYPE; import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.PRECOMPILED_SRCS_TYPE; import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.SRCS_TYPE; @@ -143,7 +142,14 @@ public final class CompilationSupport { * Returns the location of the xcrunwrapper tool. */ public static final FilesToRunProvider xcrunwrapper(RuleContext ruleContext) { - return ruleContext.getExecutablePrerequisite("$xcrunwrapper", Mode.HOST); + return ruleContext.getExecutablePrerequisite("$xcrunwrapper", Mode.HOST); + } + + /** + * Returns the location of the libtool tool. + */ + public static final FilesToRunProvider libtool(RuleContext ruleContext) { + return ruleContext.getExecutablePrerequisite(ObjcRuleClasses.LIBTOOL_ATTRIBUTE, Mode.HOST); } /** @@ -719,9 +725,8 @@ public final class CompilationSupport { actions.add(ObjcRuleClasses.spawnAppleEnvActionBuilder( ruleContext, appleConfiguration.getIosCpuPlatform()) .setMnemonic("ObjcLink") - .setExecutable(xcrunwrapper(ruleContext)) + .setExecutable(libtool(ruleContext)) .setCommandLine(new CustomCommandLine.Builder() - .add(LIBTOOL) .add("-static") .add("-filelist").add(objList.getExecPathString()) .add("-arch_only").add(appleConfiguration.getIosCpu()) @@ -750,9 +755,8 @@ public final class CompilationSupport { ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder( ruleContext, appleConfiguration.getIosCpuPlatform()) .setMnemonic("ObjcLink") - .setExecutable(xcrunwrapper(ruleContext)) + .setExecutable(libtool(ruleContext)) .setCommandLine(new CustomCommandLine.Builder() - .add(LIBTOOL) .add("-static") .add("-arch_only").add(appleConfiguration.getIosCpu()) .add("-syslibroot").add(AppleToolchain.sdkDir()) 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 99bf4365b7..895312c30f 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 @@ -115,6 +115,9 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF .add(attr("$xcrunwrapper", LABEL).cfg(HOST).exec() .value(Label.parseAbsoluteUnchecked( toolsRepository + "//tools/objc:xcrunwrapper"))) + .add(attr(ObjcRuleClasses.LIBTOOL_ATTRIBUTE, LABEL).cfg(HOST).exec() + .value(Label.parseAbsoluteUnchecked( + toolsRepository + "//tools/objc:libtool"))) .add(attr(":xcode_config", LABEL) .allowedRuleClasses("xcode_config") .checkConstraints() diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryRule.java index ec91db8b6c..2cb9f9cafc 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryRule.java @@ -154,7 +154,8 @@ public class ObjcProtoLibraryRule implements RuleDefinition { return RuleDefinition.Metadata.builder() .name("objc_proto_library") .factoryClass(ObjcProtoLibrary.class) - .ancestors(BaseRuleClasses.RuleBase.class, ObjcRuleClasses.XcrunRule.class) + .ancestors(BaseRuleClasses.RuleBase.class, ObjcRuleClasses.LibtoolRule.class, + ObjcRuleClasses.XcrunRule.class) .build(); } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java index bad5520b62..48981fbbe0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java @@ -61,10 +61,15 @@ import com.google.devtools.build.lib.util.FileTypeSet; * Shared rule classes and associated utility code for Objective-C rules. */ public class ObjcRuleClasses { + + /** + * Name of the attribute used for implicit dependency on the libtool wrapper. + */ + public static final String LIBTOOL_ATTRIBUTE = "$libtool"; + static final String CLANG = "clang"; static final String CLANG_PLUSPLUS = "clang++"; static final String SWIFT = "swift"; - static final String LIBTOOL = "libtool"; static final String DSYMUTIL = "dsymutil"; static final String LIPO = "lipo"; static final String STRIP = "strip"; @@ -746,12 +751,34 @@ public class ObjcRuleClasses { BaseRuleClasses.RuleBase.class, CompileDependencyRule.class, CoptsRule.class, + LibtoolRule.class, XcrunRule.class) .build(); } } /** + * Common attributes for {@code objc_*} rules that need to call libtool. + */ + public static class LibtoolRule implements RuleDefinition { + @Override + public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { + return builder + .add(attr(LIBTOOL_ATTRIBUTE, LABEL).cfg(HOST).exec() + .value(env.getToolsLabel("//tools/objc:libtool"))) + .build(); + } + @Override + public Metadata getMetadata() { + return RuleDefinition.Metadata.builder() + .name("$objc_libtool_rule") + .type(RuleClassType.ABSTRACT) + .ancestors(XcrunRule.class) + .build(); + } + } + + /** * Common attributes for {@code objc_*} rules that can optionally be set to {@code alwayslink}. */ public static class AlwaysLinkRule implements RuleDefinition { |