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

Move react_render_debug to be consumed via prefab #34802

Closed
wants to merge 1 commit 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
36 changes: 33 additions & 3 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ plugins {
}

import com.facebook.react.tasks.internal.*
import com.facebook.react.tasks.internal.utils.*

import java.nio.file.Paths

import kotlin.Pair

import de.undercouch.gradle.tasks.download.Download
import org.apache.tools.ant.taskdefs.condition.Os
import org.apache.tools.ant.filters.ReplaceTokens
Expand All @@ -48,8 +51,25 @@ 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"
// By setting REACT_NATIVE_SKIP_PREFAB we can skip prefab publishing, to
// reduce the size of the React Native published .AAR.
def skipPrefabPublishing = System.getenv("REACT_NATIVE_SKIP_PREFAB") != null
def prefabHeadersDir = project.file("$buildDir/prefab-headers")

final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTask) {
// To export to a ReactNativePrefabProcessingEntities.kt once all
// libraries have been moved. We keep it here for now as it make easier to
// migrate one library at a time.
it.input.set(
[
new PrefabPreprocessingEntry(
"react_render_debug",
new Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/")
)
]
)
it.outputDir.set(prefabHeadersDir)
}

// We put the publishing version from gradle.properties inside ext. so other
// subprojects can access it as well.
Expand Down Expand Up @@ -300,7 +320,9 @@ android {
"reactperfloggerjni",
"react_newarchdefaults",
"turbomodulejsijni",
"fabricjni"
"fabricjni",
// prefab targets
"react_render_debug"
}
}
ndk {
Expand Down Expand Up @@ -334,6 +356,7 @@ android {

preBuild.dependsOn(prepareJSC, prepareBoost, prepareDoubleConversion, prepareFmt, prepareFolly, prepareGlog, prepareLibevent, extractNativeDependencies)
preBuild.dependsOn("generateCodegenArtifactsFromSchema")
preBuild.dependsOn(preparePrefab)

sourceSets.main {
res.srcDirs = ["src/main/res/devsupport", "src/main/res/shell", "src/main/res/views/modal", "src/main/res/views/uimanager"]
Expand Down Expand Up @@ -366,6 +389,13 @@ android {

buildFeatures {
prefab true
prefabPublishing !skipPrefabPublishing
}

prefab {
react_render_debug {
headers(new File(prefabHeadersDir, "react_render_debug").absolutePath)
}
}

publishing {
Expand Down
8 changes: 0 additions & 8 deletions ReactAndroid/cmake-utils/Android-prebuilt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,6 @@ target_include_directories(react_render_core
${REACT_COMMON_DIR}
${REACT_COMMON_DIR}/react/renderer/core)

## react_render_debug
add_library(react_render_debug SHARED IMPORTED GLOBAL)
set_target_properties(react_render_debug
PROPERTIES
IMPORTED_LOCATION
${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_debug.so)
target_include_directories(react_render_debug INTERFACE ${REACT_COMMON_DIR}/react/renderer/debug)

## react_debug
add_library(react_debug SHARED IMPORTED GLOBAL)
set_target_properties(react_debug
Expand Down
6 changes: 5 additions & 1 deletion ReactAndroid/cmake-utils/ReactNative-application.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ target_include_directories(${CMAKE_PROJECT_NAME}

target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Werror -fexceptions -frtti -std=c++17 -DWITH_INSPECTOR=1 -DLOG_TAG=\"ReactNative\")

# Prefab packages
find_package(ReactAndroid REQUIRED CONFIG)
add_library(react_render_debug ALIAS ReactAndroid::react_render_debug)

target_link_libraries(${CMAKE_PROJECT_NAME}
fabricjni
fbjni
Expand All @@ -51,7 +55,7 @@ target_link_libraries(${CMAKE_PROJECT_NAME}
react_newarchdefaults
react_render_componentregistry
react_render_core
react_render_debug
react_render_debug # prefab ready
react_render_graphics
react_render_mapbuffer
rrc_view
Expand Down
3 changes: 3 additions & 0 deletions packages/rn-tester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ android {
]
}
}
buildFeatures {
prefab true
}
packagingOptions {
pickFirst '**/libhermes.so'
pickFirst '**/libjsc.so'
Expand Down
1 change: 1 addition & 0 deletions scripts/publish-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ if (isCommitly) {
}

// -------- Generating Android Artifacts
env.REACT_NATIVE_SKIP_PREFAB = true;
if (exec('./gradlew :ReactAndroid:installArchives').code) {
echo('Could not generate artifacts');
exit(1);
Expand Down
3 changes: 3 additions & 0 deletions template/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ android {
path "$projectDir/src/main/jni/CMakeLists.txt"
}
}
buildFeatures {
prefab true
}
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
Expand Down