Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug build support for Android native code #25147

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions ReactAndroid/src/main/jni/react/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 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

# Build the files in this directory as a shared library
include $(BUILD_SHARED_LIBRARY)

Expand Down
8 changes: 8 additions & 0 deletions ReactAndroid/src/main/jni/third-party/folly/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down