aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
diff options
context:
space:
mode:
authorGravatar Cal Peyser <cpeyser@google.com>2017-03-23 21:34:10 +0000
committerGravatar Yue Gan <yueg@google.com>2017-03-24 12:18:54 +0000
commitea862bac70646d519388955a71d6189a0f01459e (patch)
tree5bf8f6334cf055315f06f538b56b00e6bcb19af5 /src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
parentd6052e320cafbf28eb851b0c5df8ddee2b94a34e (diff)
Finish implementing binary stripping for --experimental_objc_crosstool=all.
This involves: (1) Adding the -g compiler flag (2) If the target is a test, do not add linker flags. (3) Move relevant tests to crosstool case. -- PiperOrigin-RevId: 151055080 MOS_MIGRATED_REVID=151055080
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
index e91de27387..6f561a4731 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java
@@ -37,6 +37,7 @@ import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
+import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.cpp.CcLibraryHelper;
import com.google.devtools.build.lib.rules.cpp.CcLibraryHelper.Info;
@@ -79,6 +80,15 @@ public class CrosstoolCompilationSupport extends CompilationSupport {
private static final String LLVM_COVERAGE_MAP_FORMAT = "llvm_coverage_map_format";
/** Produce artifacts for coverage in gcc coverage mapping format. */
private static final String GCC_COVERAGE_MAP_FORMAT = "gcc_coverage_map_format";
+ /**
+ * Enabled if this target's rule is not a test rule. Binary stripping should not be applied in
+ * the link step. TODO(b/36562173): Replace this behavior with a condition on bundle creation.
+ *
+ * <p>Note that the crosstool does not support feature negation in FlagSet.with_feature, which
+ * is the mechanism used to condition linker arguments here. Therefore, we expose
+ * "is_not_test_target" instead of the more intuitive "is_test_target".
+ */
+ private static final String IS_NOT_TEST_TARGET_FEATURE_NAME = "is_not_test_target";
private static final Iterable<String> ACTIVATED_ACTIONS =
ImmutableList.of(
@@ -200,6 +210,12 @@ public class CrosstoolCompilationSupport extends CompilationSupport {
return this;
}
+ private StrippingType getStrippingType(ExtraLinkArgs extraLinkArgs) {
+ return Iterables.contains(extraLinkArgs, "-dynamiclib")
+ ? StrippingType.DYNAMIC_LIB
+ : StrippingType.DEFAULT;
+ }
+
@Override
CompilationSupport registerLinkActions(
ObjcProvider objcProvider,
@@ -267,7 +283,7 @@ public class CrosstoolCompilationSupport extends CompilationSupport {
ruleContext.registerAction(executableLinkAction);
if (objcConfiguration.shouldStripBinary()) {
- registerBinaryStripAction(binaryToLink, StrippingType.DEFAULT);
+ registerBinaryStripAction(binaryToLink, getStrippingType(extraLinkArgs));
}
return this;
@@ -393,8 +409,11 @@ public class CrosstoolCompilationSupport extends CompilationSupport {
} else {
activatedCrosstoolSelectables.add(GCC_COVERAGE_MAP_FORMAT);
}
- activatedCrosstoolSelectables.addAll(ruleContext.getFeatures());
+ if (!TargetUtils.isTestRule(ruleContext.getRule())) {
+ activatedCrosstoolSelectables.add(IS_NOT_TEST_TARGET_FEATURE_NAME);
+ }
+ activatedCrosstoolSelectables.addAll(ruleContext.getFeatures());
return configuration
.getFragment(CppConfiguration.class)
.getFeatures()