mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add debug build support for Android native code (#25147)
Summary: With JSI based architecture, there will be more and more C++ native code involved. Original NDK builder in RN only supports release build and that's not reasonable for native debugging. This change introduces a way to build native code in debuggable version. Simply add `NATIVE_BUILD_TYPE=Debug` environment variable during gradle build, e.g. `NATIVE_BUILD_TYPE=Debug ./gradlew clean :ReactAndroid:assembleDebug` ## Changelog [Android] [Added] - Add native debug build support to improve debugging DX Pull Request resolved: https://github.com/facebook/react-native/pull/25147 Differential Revision: D15628533 Pulled By: cpojer fbshipit-source-id: 8f5b54c4580824452d2a1236a7bd641889b001ec
This commit is contained in:
committed by
Facebook Github Bot
parent
dbad0fd607
commit
6b4e526b2d
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user