Commit d6e80deb authored by Johann's avatar Johann
Browse files

Clean Android build defaults

Disable unit-tests. The logging in GTest would need to be adjusted.

Restructure ARM cpu detection. Flatten if-else logic.

Change #if defined(HAVE_*) to #if HAVE_* because we only need to check
for features that the library was actually built with. This should have
been harmless, as disabled feature sets wouldn't have any features to
call.

Change-Id: Iea21aa42ce5f049c53ca0376d25bcd0f36f38284
parent 5daaa838
...@@ -588,13 +588,18 @@ process_toolchain() { ...@@ -588,13 +588,18 @@ process_toolchain() {
fi fi
# Enable unit tests if we have a working C++ compiler # Enable unit tests if we have a working C++ compiler
case "$tgt_cc" in case "$toolchain" in
vs*) *-vs*)
soft_enable unit_tests;; soft_enable unit_tests
;;
*-android-*)
# GTestLog must be modified to use Android logging utilities.
;;
*) *)
check_cxx "$@" <<EOF && soft_enable unit_tests check_cxx "$@" <<EOF && soft_enable unit_tests
int z; int z;
EOF EOF
;;
esac esac
} }
......
...@@ -36,6 +36,9 @@ static int arm_cpu_env_mask(void) ...@@ -36,6 +36,9 @@ static int arm_cpu_env_mask(void)
int arm_cpu_caps(void) int arm_cpu_caps(void)
{ {
/* This function should actually be a no-op. There is no way to adjust any of
* these because the RTCD tables do not exist: the functions are called
* statically */
int flags; int flags;
int mask; int mask;
if (!arm_cpu_env_flags(&flags)) if (!arm_cpu_env_flags(&flags))
...@@ -43,19 +46,19 @@ int arm_cpu_caps(void) ...@@ -43,19 +46,19 @@ int arm_cpu_caps(void)
return flags; return flags;
} }
mask = arm_cpu_env_mask(); mask = arm_cpu_env_mask();
#if defined(HAVE_EDSP) #if HAVE_EDSP
flags |= HAS_EDSP; flags |= HAS_EDSP;
#endif #endif /* HAVE_EDSP */
#if defined(HAVE_MEDIA) #if HAVE_MEDIA
flags |= HAS_MEDIA; flags |= HAS_MEDIA;
#endif #endif /* HAVE_MEDIA */
#if defined(HAVE_NEON) #if HAVE_NEON
flags |= HAS_NEON; flags |= HAS_NEON;
#endif #endif /* HAVE_NEON */
return flags & mask; return flags & mask;
} }
#elif defined(_MSC_VER) #elif defined(_MSC_VER) /* end !CONFIG_RUNTIME_CPU_DETECT */
/*For GetExceptionCode() and EXCEPTION_ILLEGAL_INSTRUCTION.*/ /*For GetExceptionCode() and EXCEPTION_ILLEGAL_INSTRUCTION.*/
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN #define WIN32_EXTRA_LEAN
...@@ -74,7 +77,7 @@ int arm_cpu_caps(void) ...@@ -74,7 +77,7 @@ int arm_cpu_caps(void)
* instructions via their assembled hex code. * instructions via their assembled hex code.
* All of these instructions should be essentially nops. * All of these instructions should be essentially nops.
*/ */
#if defined(HAVE_EDSP) #if HAVE_EDSP
if (mask & HAS_EDSP) if (mask & HAS_EDSP)
{ {
__try __try
...@@ -88,7 +91,7 @@ int arm_cpu_caps(void) ...@@ -88,7 +91,7 @@ int arm_cpu_caps(void)
/*Ignore exception.*/ /*Ignore exception.*/
} }
} }
#if defined(HAVE_MEDIA) #if HAVE_MEDIA
if (mask & HAS_MEDIA) if (mask & HAS_MEDIA)
__try __try
{ {
...@@ -101,7 +104,7 @@ int arm_cpu_caps(void) ...@@ -101,7 +104,7 @@ int arm_cpu_caps(void)
/*Ignore exception.*/ /*Ignore exception.*/
} }
} }
#if defined(HAVE_NEON) #if HAVE_NEON
if (mask & HAS_NEON) if (mask & HAS_NEON)
{ {
__try __try
...@@ -115,14 +118,13 @@ int arm_cpu_caps(void) ...@@ -115,14 +118,13 @@ int arm_cpu_caps(void)
/*Ignore exception.*/ /*Ignore exception.*/
} }
} }
#endif #endif /* HAVE_NEON */
#endif #endif /* HAVE_MEDIA */
#endif #endif /* HAVE_EDSP */
return flags & mask; return flags & mask;
} }
#elif defined(__linux__) #elif defined(__ANDROID__) /* end _MSC_VER */
#if defined(__ANDROID__)
#include <cpu-features.h> #include <cpu-features.h>
int arm_cpu_caps(void) int arm_cpu_caps(void)
...@@ -137,19 +139,20 @@ int arm_cpu_caps(void) ...@@ -137,19 +139,20 @@ int arm_cpu_caps(void)
mask = arm_cpu_env_mask(); mask = arm_cpu_env_mask();
features = android_getCpuFeatures(); features = android_getCpuFeatures();
#if defined(HAVE_EDSP) #if HAVE_EDSP
flags |= HAS_EDSP; flags |= HAS_EDSP;
#endif #endif /* HAVE_EDSP */
#if defined(HAVE_MEDIA) #if HAVE_MEDIA
flags |= HAS_MEDIA; flags |= HAS_MEDIA;
#endif #endif /* HAVE_MEDIA */
#if defined(HAVE_NEON) #if HAVE_NEON
if (features & ANDROID_CPU_ARM_FEATURE_NEON) if (features & ANDROID_CPU_ARM_FEATURE_NEON)
flags |= HAS_NEON; flags |= HAS_NEON;
#endif #endif /* HAVE_NEON */
return flags & mask; return flags & mask;
} }
#else // !defined(__ANDROID__)
#elif defined(__linux__) /* end __ANDROID__ */
#include <stdio.h> #include <stdio.h>
int arm_cpu_caps(void) int arm_cpu_caps(void)
...@@ -175,27 +178,27 @@ int arm_cpu_caps(void) ...@@ -175,27 +178,27 @@ int arm_cpu_caps(void)
char buf[512]; char buf[512];
while (fgets(buf, 511, fin) != NULL) while (fgets(buf, 511, fin) != NULL)
{ {
#if defined(HAVE_EDSP) || defined(HAVE_NEON) #if HAVE_EDSP || HAVE_NEON
if (memcmp(buf, "Features", 8) == 0) if (memcmp(buf, "Features", 8) == 0)
{ {
char *p; char *p;
#if defined(HAVE_EDSP) #if HAVE_EDSP
p=strstr(buf, " edsp"); p=strstr(buf, " edsp");
if (p != NULL && (p[5] == ' ' || p[5] == '\n')) if (p != NULL && (p[5] == ' ' || p[5] == '\n'))
{ {
flags |= HAS_EDSP; flags |= HAS_EDSP;
} }
#if defined(HAVE_NEON) #if HAVE_NEON
p = strstr(buf, " neon"); p = strstr(buf, " neon");
if (p != NULL && (p[5] == ' ' || p[5] == '\n')) if (p != NULL && (p[5] == ' ' || p[5] == '\n'))
{ {
flags |= HAS_NEON; flags |= HAS_NEON;
} }
#endif #endif /* HAVE_NEON */
#endif #endif /* HAVE_EDSP */
} }
#endif #endif /* HAVE_EDSP || HAVE_NEON */
#if defined(HAVE_MEDIA) #if HAVE_MEDIA
if (memcmp(buf, "CPU architecture:",17) == 0){ if (memcmp(buf, "CPU architecture:",17) == 0){
int version; int version;
version = atoi(buf+17); version = atoi(buf+17);
...@@ -204,14 +207,13 @@ int arm_cpu_caps(void) ...@@ -204,14 +207,13 @@ int arm_cpu_caps(void)
flags |= HAS_MEDIA; flags |= HAS_MEDIA;
} }
} }
#endif #endif /* HAVE_MEDIA */
} }
fclose(fin); fclose(fin);
} }
return flags & mask; return flags & mask;
} }
#endif // defined(__linux__) #else /* end __linux__ */
#else
#error "--enable-runtime-cpu-detect selected, but no CPU detection method " \ #error "--enable-runtime-cpu-detect selected, but no CPU detection method " \
"available for your platform. Reconfigure with --disable-runtime-cpu-detect." "available for your platform. Reconfigure with --disable-runtime-cpu-detect."
#endif #endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment