diff options
| author | Ruben Brunk <rubenbrunk@google.com> | 2013-09-09 02:21:31 -0700 |
|---|---|---|
| committer | Ruben Brunk <rubenbrunk@google.com> | 2013-09-10 18:13:38 -0700 |
| commit | a77f3a243aad5632832fa822e1ac07bb4b5d5668 (patch) | |
| tree | 49c5e7ec1f6e0b22a160a7e7bae3446b5723de7a | |
| parent | 52c2312b9e12d74068dff23e106be1af0f26251a (diff) | |
| download | platform_libnativehelper-kitkat-cts-dev.tar.gz platform_libnativehelper-kitkat-cts-dev.tar.bz2 platform_libnativehelper-kitkat-cts-dev.zip | |
Add support for ndk libnativehelper build.android-cts-4.4_r1android-4.4_r1.0.1android-4.4_r1android-4.4_r0.9android-4.4_r0.8android-4.4_r0.7kitkat-cts-dev
Bug: 10680559
Change-Id: I18491baac6acc4486f2e87175c922b40b5c17179
| -rw-r--r-- | ALog-priv.h | 66 | ||||
| -rw-r--r-- | Android.mk | 29 | ||||
| -rw-r--r-- | JNIHelp.cpp | 3 | ||||
| -rw-r--r-- | JniConstants.cpp | 3 | ||||
| -rw-r--r-- | include/nativehelper/JNIHelp.h | 14 |
5 files changed, 97 insertions, 18 deletions
diff --git a/ALog-priv.h b/ALog-priv.h new file mode 100644 index 0000000..7b3ed97 --- /dev/null +++ b/ALog-priv.h @@ -0,0 +1,66 @@ +/* + * Copyright 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVEHELPER_ALOGPRIV_H_ +#define NATIVEHELPER_ALOGPRIV_H_ + +#include <android/log.h> + +#ifndef LOG_NDEBUG +#ifdef NDEBUG +#define LOG_NDEBUG 1 +#else +#define LOG_NDEBUG 0 +#endif +#endif + + +/* + * Basic log message macros intended to emulate the behavior of log/log.h + * in system core. This should be dependent only on ndk exposed logging + * functionality. + */ + +#ifndef ALOG +#define ALOG(priority, tag, fmt...) \ + __android_log_print(ANDROID_##priority, tag, fmt) +#endif + +#ifndef ALOGV +#if LOG_NDEBUG +#define ALOGV(...) ((void)0) +#else +#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) +#endif +#endif + +#ifndef ALOGD +#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) +#endif + +#ifndef ALOGI +#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) +#endif + +#ifndef ALOGW +#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) +#endif + +#ifndef ALOGE +#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) +#endif + +#endif @@ -18,7 +18,6 @@ LOCAL_PATH := $(call my-dir) local_src_files := \ JNIHelp.cpp \ JniConstants.cpp \ - JniInvocation.cpp \ toStringArray.cpp @@ -27,7 +26,9 @@ local_src_files := \ # include $(CLEAR_VARS) -LOCAL_SRC_FILES := $(local_src_files) +LOCAL_SRC_FILES := \ + $(local_src_files) \ + JniInvocation.cpp LOCAL_SHARED_LIBRARIES := liblog LOCAL_MODULE_TAGS := optional LOCAL_MODULE := libnativehelper @@ -37,6 +38,26 @@ LOCAL_SHARED_LIBRARIES += libcutils libstlport libdl LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk include $(BUILD_SHARED_LIBRARY) +# +# NDK-only build for the target (device). +# - Relies only on NDK exposed functionality. +# - This doesn't include JniInvocation. +# + +include $(CLEAR_VARS) +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := libnativehelper_compat +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include/nativehelper +LOCAL_CFLAGS := -Werror +LOCAL_SRC_FILES := $(local_src_files) +LOCAL_LDFLAGS := -llog +LOCAL_SDK_VERSION := 17 +LOCAL_NDK_STL_VARIANT := stlport_static +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk +include $(BUILD_SHARED_LIBRARY) + + # # Build for the host. @@ -45,7 +66,9 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := libnativehelper LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := $(local_src_files) +LOCAL_SRC_FILES := \ + $(local_src_files) \ + JniInvocation.cpp LOCAL_CFLAGS := -Werror LOCAL_C_INCLUDES := libcore/include LOCAL_SHARED_LIBRARIES := liblog diff --git a/JNIHelp.cpp b/JNIHelp.cpp index 4b77680..ef4d862 100644 --- a/JNIHelp.cpp +++ b/JNIHelp.cpp @@ -20,8 +20,9 @@ #include "JniConstants.h" #include "JNIHelp.h" -#include "cutils/log.h" +#include "ALog-priv.h" +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> diff --git a/JniConstants.cpp b/JniConstants.cpp index 52e3c1f..d6ac62d 100644 --- a/JniConstants.cpp +++ b/JniConstants.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +#define LOG_TAG "JniConstants" + +#include "ALog-priv.h" #include "JniConstants.h" #include "ScopedLocalRef.h" diff --git a/include/nativehelper/JNIHelp.h b/include/nativehelper/JNIHelp.h index 8a630fe..455ce25 100644 --- a/include/nativehelper/JNIHelp.h +++ b/include/nativehelper/JNIHelp.h @@ -26,7 +26,6 @@ #define NATIVEHELPER_JNIHELP_H_ #include "jni.h" -#include "cutils/log.h" #include <unistd.h> #ifndef NELEM @@ -190,19 +189,6 @@ inline std::string jniGetStackTrace(JNIEnv* env, jthrowable exception = NULL) { #endif -/* Logging macros. - * - * Logs an exception. If the exception is omitted or NULL, logs the current exception - * from the JNI environment, if any. - */ -#define LOG_EX(env, priority, tag, ...) \ - IF_ALOG(priority, tag) jniLogException(env, ANDROID_##priority, tag, ##__VA_ARGS__) -#define LOGV_EX(env, ...) LOG_EX(env, LOG_VERBOSE, LOG_TAG, ##__VA_ARGS__) -#define LOGD_EX(env, ...) LOG_EX(env, LOG_DEBUG, LOG_TAG, ##__VA_ARGS__) -#define LOGI_EX(env, ...) LOG_EX(env, LOG_INFO, LOG_TAG, ##__VA_ARGS__) -#define LOGW_EX(env, ...) LOG_EX(env, LOG_WARN, LOG_TAG, ##__VA_ARGS__) -#define LOGE_EX(env, ...) LOG_EX(env, LOG_ERROR, LOG_TAG, ##__VA_ARGS__) - /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's |
