Refactor use of __ANDROID__ macro
We use the __ANDROID__ macro, which is provided by the toolchain, in
numerous places. This patch refactors the usage of this by defining a
new macro, ART_TARGET_ANDROID, that is being passed during build to
ART_TARGET_CFLAGS in Android.common_build.mk on the same line as
ART_TARGET. The codebase currently assumes that the existence of the
__ANDROID__ macro implies that we are compiling art for an android
target device. This is because, currently, target builds are compiled
with target toolchains that provide the macro, while host toolchains
do not. With this change this assumption is still preserved. However,
in a future patch we will add the ability to compile art for a linux
target, and in that case the ART_TARGET_ANDROID macro won't be passed
anymore.
Change-Id: I1f3a811aa735c87087d812da27fc6b08f01bad51
diff --git a/runtime/openjdkjvm/OpenjdkJvm.cc b/runtime/openjdkjvm/OpenjdkJvm.cc
index 1f33651..ca5efe5 100644
--- a/runtime/openjdkjvm/OpenjdkJvm.cc
+++ b/runtime/openjdkjvm/OpenjdkJvm.cc
@@ -58,10 +58,10 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
// This function is provided by android linker.
extern "C" void android_update_LD_LIBRARY_PATH(const char* ld_library_path);
-#endif // __ANDROID__
+#endif // ART_TARGET_ANDROID
#undef LOG_TAG
#define LOG_TAG "artopenjdk"
@@ -325,7 +325,7 @@
}
static void SetLdLibraryPath(JNIEnv* env, jstring javaLdLibraryPath) {
-#ifdef __ANDROID__
+#ifdef ART_TARGET_ANDROID
if (javaLdLibraryPath != nullptr) {
ScopedUtfChars ldLibraryPath(env, javaLdLibraryPath);
if (ldLibraryPath.c_str() != nullptr) {