aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
index 082fe72374..db2e28470b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
@@ -174,13 +174,10 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
toolchainMap.put(config.getCpu(), CppHelper.getToolchain(ruleContext));
}
- NativeLibs nativeLibs =
- NativeLibs.fromLinkedNativeDeps(
- ruleContext,
- androidSemantics.getNativeDepsFileName(),
- depsByArchitecture,
- toolchainMap,
- configurationMap);
+ NativeLibs nativeLibs = shouldLinkNativeDeps(ruleContext)
+ ? NativeLibs.fromLinkedNativeDeps(ruleContext, androidSemantics.getNativeDepsFileName(),
+ depsByArchitecture, toolchainMap, configurationMap)
+ : NativeLibs.fromPrecompiledObjects(ruleContext, depsByArchitecture);
// TODO(bazel-team): Resolve all the different cases of resource handling so this conditional
// can go away: recompile from android_resources, and recompile from android_binary attributes.
@@ -1703,6 +1700,19 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
}
/**
+ * Returns whether to use NativeDepsHelper to link native dependencies.
+ */
+ public static boolean shouldLinkNativeDeps(RuleContext ruleContext) {
+ TriState attributeValue = ruleContext.attributes().get(
+ "legacy_native_support", BuildType.TRISTATE);
+ if (attributeValue == TriState.AUTO) {
+ return !ruleContext.getFragment(AndroidConfiguration.class).getLegacyNativeSupport();
+ } else {
+ return attributeValue == TriState.NO;
+ }
+ }
+
+ /**
* Returns the multidex mode to apply to this target.
*/
public static MultidexMode getMultidexMode(RuleContext ruleContext) {