Update Android.bp to always enable NEON

Relax Cpu unittest to allow ARM emulator to run.

Bug: libyuv:863, libyuv:877, b/178283356
Change-Id: I3c751574219fdf731a3f9d4a79934a349acba446
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/2950938
Reviewed-by: Wan-Teh Chang <wtc@google.com>
This commit is contained in:
Frank Barchard 2021-06-10 12:27:10 -07:00 committed by Frank Barchard
parent 6ea7647b6e
commit d19f69d9df
3 changed files with 61 additions and 15 deletions

View File

@ -1,6 +1,32 @@
package {
default_applicable_licenses: ["external_libyuv_files_license"],
}
// Added automatically by a large-scale-change
//
// large-scale-change included anything that looked like it might be a license
// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
//
// Please consider removing redundant or irrelevant files from 'license_text:'.
// See: http://go/android-license-faq
license {
name: "external_libyuv_files_license",
visibility: [":__subpackages__"],
license_kinds: [
"SPDX-license-identifier-BSD",
],
license_text: [
"LICENSE",
"LICENSE_THIRD_PARTY",
"PATENTS",
],
}
cc_library {
name: "libyuv",
vendor_available: true,
product_available: true,
host_supported: true,
vndk: {
enabled: true,
},
@ -61,9 +87,21 @@ cc_library {
"-DHAVE_JPEG",
],
arch: {
arm: {
cflags: ["-mfpu=neon"],
},
},
shared_libs: ["libjpeg"],
export_include_dirs: ["include"],
apex_available: [
"//apex_available:platform",
"com.android.media.swcodec",
],
min_sdk_version: "29",
}
// compatibilty static library until all uses of libyuv_static are replaced
@ -72,6 +110,11 @@ cc_library_static {
name: "libyuv_static",
vendor_available: true,
whole_static_libs: ["libyuv"],
apex_available: [
"//apex_available:platform",
"com.android.media.swcodec",
],
min_sdk_version: "29",
}
cc_test {
@ -108,19 +151,19 @@ cc_test {
}
cc_test {
name: "i444tonv12_eg",
name: "cpuid",
gtest: false,
srcs: [
"util/i444tonv12_eg.cc",
"util/cpuid.c",
],
static_libs: ["libyuv"],
}
cc_test {
name: "cpuid",
name: "i444tonv12_eg",
gtest: false,
srcs: [
"util/cpuid.c",
"util/i444tonv12_eg.cc",
],
static_libs: ["libyuv"],
}
@ -136,6 +179,15 @@ cc_test {
static_libs: ["libyuv"],
}
cc_test {
name: "yuvconstants",
gtest: false,
srcs: [
"util/yuvconstants.c",
],
static_libs: ["libyuv"],
}
cc_test {
name: "yuvconvert",
gtest: false,
@ -145,12 +197,3 @@ cc_test {
static_libs: ["libyuv"],
shared_libs: ["libjpeg"],
}
cc_test {
name: "yuvconstants",
gtest: false,
srcs: [
"util/yuvconstants.c",
],
static_libs: ["libyuv"],
}

View File

@ -133,7 +133,7 @@ int GetXCR0() {
#pragma optimize("g", on)
#endif
// based on libvpx arm_cpudetect.c
// Based on libvpx arm_cpudetect.c
// For Arm, but public to allow testing on any CPU
LIBYUV_API SAFEBUFFERS int ArmCpuCaps(const char* cpuinfo_name) {
char cpuinfo_line[512];

View File

@ -229,7 +229,10 @@ TEST_F(LibYUVBaseTest, TestLinuxNeon) {
}
#if defined(__linux__) && defined(__ARM_NEON__)
if (FileExists("/proc/cpuinfo")) {
EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("/proc/cpuinfo"));
if (kCpuHasNEON != ArmCpuCaps("/proc/cpuinfo")) {
// This can happen on ARM emulator but /proc/cpuinfo is from host.
printf("WARNING: Neon build enabled but CPU does not have NEON\n");
}
} else {
printf("WARNING: unable to load \"/proc/cpuinfo\"\n");
}