diff options
-rw-r--r-- | Android.mk | 10 | ||||
-rw-r--r-- | base/files/file_util_posix.cc | 2 | ||||
-rw-r--r-- | base/logging.cc | 8 | ||||
-rw-r--r-- | base/message_loop/message_pump_libevent.cc | 2 | ||||
-rw-r--r-- | build/build_config.h | 29 |
5 files changed, 33 insertions, 18 deletions
diff --git a/Android.mk b/Android.mk index ba440dda68..85f2af5742 100644 --- a/Android.mk +++ b/Android.mk @@ -18,7 +18,7 @@ LOCAL_PATH := $(call my-dir) # ======================================================== libchromeCommonCppExtension := .cc -libchromeCommonCFlags := -D__BRILLO__ -Wall -Werror \ +libchromeCommonCFlags := -Wall -Werror \ -Wno-char-subscripts -Wno-missing-field-initializers \ -Wno-unused-function -Wno-unused-parameter libchromeCommonCppFlags := -Wno-deprecated-register -Wno-sign-promo \ @@ -334,6 +334,8 @@ libchromeCommonUnittestSrc := \ base/vlog_unittest.cc \ testing/multiprocess_func_list.cc \ +libchromeHostCFlags := -D__ANDROID_HOST__ + # libchrome shared library for target # ======================================================== include $(CLEAR_VARS) @@ -343,7 +345,7 @@ LOCAL_CPP_EXTENSION := $(libchromeCommonCppExtension) LOCAL_CFLAGS := $(libchromeCommonCFlags) LOCAL_CPPFLAGS := $(libchromeCommonCppFlags) LOCAL_C_INCLUDES := $(libchromeCommonCIncludes) -LOCAL_SHARED_LIBRARIES := libevent +LOCAL_SHARED_LIBRARIES := libevent liblog LOCAL_STATIC_LIBRARIES := libmodpb64 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) include $(BUILD_SHARED_LIBRARY) @@ -353,7 +355,7 @@ include $(BUILD_SHARED_LIBRARY) ifeq ($(HOST_OS),linux) include $(CLEAR_VARS) LOCAL_MODULE := libchrome-host -LOCAL_CFLAGS := $(libchromeCommonCFlags) -DHOST +LOCAL_CFLAGS := $(libchromeCommonCFlags) $(libchromeHostCFlags) LOCAL_CPPFLAGS := $(libchromeCommonCppFlags) LOCAL_CPP_EXTENSION := $(libchromeCommonCppExtension) LOCAL_C_INCLUDES := $(libchromeCommonCIncludes) @@ -454,7 +456,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libchrome-host_test LOCAL_SRC_FILES := $(libchromeCommonUnittestSrc) LOCAL_CPP_EXTENSION := $(libchromeCommonCppExtension) -LOCAL_CFLAGS := $(libchromeCommonCFlags) -DUNIT_TEST +LOCAL_CFLAGS := $(libchromeCommonCFlags) $(libchromeHostCFlags) -DUNIT_TEST LOCAL_CPPFLAGS := $(libchromeCommonCppFlags) LOCAL_C_INCLUDES := $(libchromeCommonCIncludes) LOCAL_SHARED_LIBRARIES := libchrome-host libevent-host diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc index 3def74e866..48c969d0e4 100644 --- a/base/files/file_util_posix.cc +++ b/base/files/file_util_posix.cc @@ -454,7 +454,7 @@ bool GetTempDir(FilePath* path) { } else { #if defined(OS_ANDROID) return PathService::Get(base::DIR_CACHE, path); -#elif (defined(__BRILLO__) && !defined(HOST)) +#elif defined(__ANDROID__) *path = FilePath("/data/local/tmp"); #else *path = FilePath("/tmp"); diff --git a/base/logging.cc b/base/logging.cc index 71528ad3f4..594c222450 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -62,7 +62,7 @@ typedef pthread_mutex_t* MutexHandle; #include "base/posix/safe_strerror.h" #endif -#if defined(OS_ANDROID) +#if defined(OS_ANDROID) || defined(__ANDROID__) #include <android/log.h> #endif @@ -559,7 +559,7 @@ LogMessage::~LogMessage() { if ((g_logging_destination & LOG_TO_SYSTEM_DEBUG_LOG) != 0) { #if defined(OS_WIN) OutputDebugStringA(str_newline.c_str()); -#elif defined(OS_ANDROID) +#elif defined(OS_ANDROID) || defined(__ANDROID__) android_LogPriority priority = (severity_ < 0) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_UNKNOWN; switch (severity_) { @@ -576,7 +576,11 @@ LogMessage::~LogMessage() { priority = ANDROID_LOG_FATAL; break; } +#if defined(OS_ANDROID) __android_log_write(priority, "chromium", str_newline.c_str()); +#else + __android_log_write(priority, NULL, str_newline.c_str()); +#endif // defined(OS_ANDROID) #endif ignore_result(fwrite(str_newline.data(), str_newline.size(), 1, stderr)); fflush(stderr); diff --git a/base/message_loop/message_pump_libevent.cc b/base/message_loop/message_pump_libevent.cc index 66296e3999..e022c8c989 100644 --- a/base/message_loop/message_pump_libevent.cc +++ b/base/message_loop/message_pump_libevent.cc @@ -17,7 +17,7 @@ #include "base/time/time.h" #include "base/trace_event/trace_event.h" -#if defined(__BRILLO__) +#if defined(__ANDROID__) || defined(__ANDROID_HOST__) #include <event2/event.h> #include <event2/event_compat.h> #include <event2/event_struct.h> diff --git a/build/build_config.h b/build/build_config.h index 5181b2bf46..bf3f43ee4f 100644 --- a/build/build_config.h +++ b/build/build_config.h @@ -15,19 +15,30 @@ #ifndef BUILD_BUILD_CONFIG_H_ #define BUILD_BUILD_CONFIG_H_ -// Add Brillo-specific defines. -#if defined(__BRILLO__) +// A brief primer on #defines: +// +// - __ANDROID__ is automatically defined by the Android toolchain (see +// https://goo.gl/v61lXa). It's not defined when building host code. +// - __ANDROID_HOST__ is defined via -D by Android.mk when building host code +// within an Android checkout. +// - ANDROID is defined via -D when building code for either Android targets or +// hosts. Use __ANDROID__ and __ANDROID_HOST__ instead. +// - OS_ANDROID is a Chrome-specific define used to build Chrome for Android +// within the NDK. +#if defined(__ANDROID__) #define __linux__ 1 -#define NO_TCMALLOC -// Unset ANDROID, which is just used for building Chrome on Android. -#undef ANDROID + +// The Chrome OS implementation of this library is currently built on Android. +#define OS_CHROMEOS 1 #if defined(__BIONIC__) #define __UCLIBC__ 1 -#define OS_CHROMEOS 1 -#endif // __BIONIC__ +#endif // defined(__BIONIC__) +#endif // defined(__ANDROID__) -#endif +#if defined(__ANDROID__) || defined(__ANDROID_HOST__) +#define NO_TCMALLOC +#endif // defined(__ANDROID__) || defined(__ANDROID_HOST__) // A set of macros to use for platform detection. #if defined(__native_client__) @@ -41,8 +52,6 @@ #else #define OS_NACL_SFI #endif -#elif defined(ANDROID) -#define OS_ANDROID 1 #elif defined(__APPLE__) // only include TargetConditions after testing ANDROID as some android builds // on mac don't have this header available and it's not needed unless the target |