Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt
index 890e61c007d5b3e0a9a69d37ef10e8aa3ce5c6b6..91acd7b2930fedb4eca2461ba99287721ca1f38f 100644
--- a/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt
+++ b/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt
@@ -80,7 +80,9 @@ class ReactPlugin : Plugin<Project> {
configureRepositories(project)
}

- configureReactNativeNdk(project, extension)
+ if(!project.gradle.startParameter.taskNames.any { it.contains("clean") }) {
+ configureReactNativeNdk(project, extension)
+ }
configureBuildConfigFieldsForApp(project, extension)
configureDevServerLocation(project)
configureBackwardCompatibilityReactMap(project)
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@
"react-native-builder-bob": "0.40.13",
"shelljs": "0.10.0",
"typescript": "5.8.3"
},
"resolutions": {
"@react-native/gradle-plugin@npm:0.82.0": "patch:@react-native/gradle-plugin@npm%3A0.82.0#~/.yarn/patches/@react-native-gradle-plugin-npm-0.82.0-10aedc0588.patch"
}
}
15 changes: 3 additions & 12 deletions packages/react-native-reanimated/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ file(GLOB_RECURSE REANIMATED_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS

find_package(fbjni REQUIRED CONFIG)
find_package(ReactAndroid REQUIRED CONFIG)
find_package(react-native-worklets REQUIRED CONFIG)

add_library(reanimated SHARED ${REANIMATED_COMMON_CPP_SOURCES}
${REANIMATED_ANDROID_CPP_SOURCES})
Expand All @@ -69,8 +70,7 @@ target_include_directories(
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
"${REACT_NATIVE_DIR}/ReactCommon/jsiexecutor"
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
"${REACT_NATIVE_WORKLETS_DIR}/Common/cpp"
"${REACT_NATIVE_WORKLETS_DIR}/android/src/main/cpp")
)

set_target_properties(reanimated PROPERTIES LINKER_LANGUAGE CXX)

Expand All @@ -80,15 +80,6 @@ else()
set(BUILD_TYPE "release")
endif()

add_library(worklets SHARED IMPORTED)

set_target_properties(
worklets
PROPERTIES
IMPORTED_LOCATION
"${REACT_NATIVE_WORKLETS_DIR}/android/build/intermediates/cmake/${BUILD_TYPE}/obj/${ANDROID_ABI}/libworklets.so"
)

set_target_properties(reanimated PROPERTIES LINKER_LANGUAGE CXX)
# remove dead code sections
set_target_properties(reanimated PROPERTIES LINK_FLAGS "-Wl,--gc-sections")
Expand All @@ -108,4 +99,4 @@ target_link_libraries(
ReactAndroid::jsi
fbjni::fbjni
android
worklets)
react-native-worklets::worklets)
2 changes: 2 additions & 0 deletions packages/react-native-worklets/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ apply plugin: "com.android.library"
apply plugin: "maven-publish"
apply plugin: "de.undercouch.download"

apply from: "./fix-prefab.gradle"


android {
compileSdkVersion safeExtGet("compileSdkVersion", 34)
Expand Down
53 changes: 53 additions & 0 deletions packages/react-native-worklets/android/fix-prefab.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
tasks.configureEach { task ->
// Make sure that we generate our prefab publication file only after having built the native library
// so that not a header publication file, but a full configuration publication will be generated, which
// will include the .so file

def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
def matcher = task.name =~ prefabConfigurePattern
if (matcher.matches()) {
def variantName = matcher[0][1]
task.outputs.upToDateWhen { false }
task.dependsOn("externalNativeBuild${variantName}")
}
}

afterEvaluate {
def abis = reactNativeArchitectures()
rootProject.allprojects.each { proj ->

if (proj === rootProject) return

def dependsOnThisLib = proj.configurations.any { config ->
config.dependencies.any { dep ->
dep.group == project.group && dep.name == project.name
}
}

if (!dependsOnThisLib && proj != project) return

if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
return
}

def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
// Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
// generate a libnameConfig.cmake file that will contain our native library (.so).
// See this condition: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt;l=207-219?q=createPrefabBuildSystemGlue
variants.all { variant ->
def variantName = variant.name
abis.each { abi ->
def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
if (!searchDir.exists()) return
def matches = []
searchDir.eachDir { randomDir ->
def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
if (prefabFile.exists()) matches << prefabFile
}
matches.each { prefabConfig ->
prefabConfig.setLastModified(System.currentTimeMillis())
}
}
}
}
}
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6964,6 +6964,13 @@ __metadata:
languageName: node
linkType: hard

"@react-native/gradle-plugin@patch:@react-native/gradle-plugin@npm%3A0.82.0#~/.yarn/patches/@react-native-gradle-plugin-npm-0.82.0-10aedc0588.patch":
version: 0.82.0
resolution: "@react-native/gradle-plugin@patch:@react-native/gradle-plugin@npm%3A0.82.0#~/.yarn/patches/@react-native-gradle-plugin-npm-0.82.0-10aedc0588.patch::version=0.82.0&hash=60e1b9"
checksum: 10/493d986f2b23678dacd32a5e20a1c4b94e981b5d1abdf6fd35a9fb195b61900250dabb05d54e64af7e779c5b2e55cb96f431c16db0ba326ae8c0d43c5956616d
languageName: node
linkType: hard

"@react-native/js-polyfills@npm:0.79.6":
version: 0.79.6
resolution: "@react-native/js-polyfills@npm:0.79.6"
Expand Down