mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-05-28 17:07:08 +00:00
fix(android): add prefab script (#4640)
This commit is contained in:
@@ -56,6 +56,7 @@ def isNewArchitectureEnabled() {
|
||||
apply plugin: "com.android.library"
|
||||
apply plugin: "kotlin-android"
|
||||
apply from: '../nitrogen/generated/android/ReactNativeVideo+autolinking.gradle'
|
||||
apply from: './fix-prefab.gradle'
|
||||
|
||||
if (isNewArchitectureEnabled()) {
|
||||
apply plugin: "com.facebook.react"
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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.findAll { it.canBeResolved }.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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user