From 28142df72e1aad600e01711b17bb45de571a4087 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Wed, 5 Jun 2019 02:01:00 +0800 Subject: [PATCH 1/2] Add debug build support for Android native code --- ReactAndroid/build.gradle | 4 ++++ ReactAndroid/src/main/jni/react/jni/Android.mk | 8 ++++++++ ReactAndroid/src/main/jni/third-party/folly/Android.mk | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 84207fb50578dc..343543143431bc 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -33,6 +33,9 @@ def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES") // and the build will use that. def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH") +// Setup build type for NDK, supported values: {debug, release} +def nativeBuildType = System.getenv("NATIVE_BUILD_TYPE") ?: "release" + task createNativeDepsDirectories { downloadsDir.mkdirs() thirdPartyNdkDir.mkdirs() @@ -225,6 +228,7 @@ task buildReactNdkLib(dependsOn: [prepareJSC, prepareBoost, prepareDoubleConvers inputs.dir("src/main/java/com/facebook/react/modules/blob") outputs.dir("$buildDir/react-ndk/all") commandLine(getNdkBuildFullPath(), + "NDK_DEBUG=" + (nativeBuildType.equalsIgnoreCase("debug") ? "1" : "0"), "NDK_PROJECT_PATH=null", "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk", "NDK_OUT=" + temporaryDir, diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk index 1cf03a78a5ea19..1bbefaac50a967 100644 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ b/ReactAndroid/src/main/jni/react/jni/Android.mk @@ -36,6 +36,14 @@ LOCAL_MODULE := reactnativejni # Compile all local c++ files. LOCAL_SRC_FILES := $(wildcard *.cpp) +ifeq ($(APP_OPTIM),debug) + # Keep symbols by overriding strip command invoked by ndk-build. + # Note that this will take effect to all shared libraries, + # i.e. all shared libraries will NOT be stripped + # even we only override in this Android.mk + cmd-strip := +endif + # Build the files in this directory as a shared library include $(BUILD_SHARED_LIBRARY) diff --git a/ReactAndroid/src/main/jni/third-party/folly/Android.mk b/ReactAndroid/src/main/jni/third-party/folly/Android.mk index c84f2d9330b419..7da39f37737875 100644 --- a/ReactAndroid/src/main/jni/third-party/folly/Android.mk +++ b/ReactAndroid/src/main/jni/third-party/folly/Android.mk @@ -17,6 +17,14 @@ LOCAL_SRC_FILES:= \ folly/container/detail/F14Table.cpp \ folly/ScopeGuard.cpp \ +ifeq ($(APP_OPTIM),debug) + LOCAL_SRC_FILES += \ + folly/lang/Assume.cpp \ + folly/lang/SafeAssert.cpp \ + folly/FileUtil.cpp \ + folly/portability/SysUio.cpp +endif + LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) From 18cd36743c8c8680cf9741d3771e7f991ffbb598 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Tue, 4 Jun 2019 19:54:15 +0100 Subject: [PATCH 2/2] Update Android.mk --- ReactAndroid/src/main/jni/react/jni/Android.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk index 1bbefaac50a967..28c1fae096e7bf 100644 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ b/ReactAndroid/src/main/jni/react/jni/Android.mk @@ -37,10 +37,10 @@ LOCAL_MODULE := reactnativejni LOCAL_SRC_FILES := $(wildcard *.cpp) ifeq ($(APP_OPTIM),debug) - # Keep symbols by overriding strip command invoked by ndk-build. - # Note that this will take effect to all shared libraries, - # i.e. all shared libraries will NOT be stripped - # even we only override in this Android.mk + # Keep symbols by overriding the strip command invoked by ndk-build. + # Note that this will apply to all shared libraries, + # i.e. shared libraries will NOT be stripped + # even though we override it in this Android.mk cmd-strip := endif