aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
diff options
context:
space:
mode:
authorGravatar Michael Staib <mstaib@google.com>2016-06-29 23:15:52 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-06-30 11:41:04 +0000
commit588a6a04c748a02f583d552660434d74190bb3ba (patch)
tree2b94b915b25cf71ce5bbe6b4219e6b5ed1ec2e2c /src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
parenteb6e6afca74146393dedad9ce10a9e56d9f6cb1b (diff)
Support copy-only native code in modern native support for android_binary.
legacy_native_support makes it so that Bazel copies .so's instead of linking. This allows Bazel to include third-party native code without running an NDK. Turning it off allows Bazel to actually compile native code, but at the cost of this copy case no longer working without an NDK, and creating an unnecessary shared library which will most likely never be used. This CL makes it so that if no actual source code or static libraries are in the transitive closure, the linker is not run at the android_binary level. This means that legacy_native_support as a separate concept can be removed, and it is - the attribute remains, but is a no-op. This will be removed in a future change. The matching flag (--legacy_android_native_support) has already been removed. RELNOTES: The link mode for Android native code is now automatically determined based on the transitive closure of cc_libraries, and legacy_native_support is now a no-op. --legacy_android_native_support has been removed. -- MOS_MIGRATED_REVID=126244755
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, 7 insertions, 17 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 0048c1565f..c1f129d029 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,10 +174,13 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
toolchainMap.put(config.getCpu(), CppHelper.getToolchain(ruleContext));
}
- NativeLibs nativeLibs = shouldLinkNativeDeps(ruleContext)
- ? NativeLibs.fromLinkedNativeDeps(ruleContext, androidSemantics.getNativeDepsFileName(),
- depsByArchitecture, toolchainMap, configurationMap)
- : NativeLibs.fromPrecompiledObjects(ruleContext, depsByArchitecture);
+ NativeLibs nativeLibs =
+ NativeLibs.fromLinkedNativeDeps(
+ ruleContext,
+ androidSemantics.getNativeDepsFileName(),
+ depsByArchitecture,
+ toolchainMap,
+ configurationMap);
// 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.
@@ -1698,19 +1701,6 @@ 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) {