Skip to content

Commit eb54539

Browse files
authored
Merge branch 'main' into main
2 parents 44ff298 + 3c9907a commit eb54539

4 files changed

Lines changed: 62 additions & 6 deletions

File tree

.github/workflows/build-android.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
name: Build Android Example App
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v4
2929

3030
- name: Setup JDK 17
3131
uses: actions/setup-java@v1
@@ -36,7 +36,7 @@ jobs:
3636
id: yarn-cache-dir-path
3737
run: echo "::set-output name=dir::$(yarn cache dir)"
3838
- name: Restore node_modules from cache
39-
uses: actions/cache@v2
39+
uses: actions/cache@v4
4040
id: yarn-cache
4141
with:
4242
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -49,7 +49,7 @@ jobs:
4949
run: yarn install --frozen-lockfile --cwd example
5050

5151
- name: Restore Gradle cache
52-
uses: actions/cache@v2
52+
uses: actions/cache@v4
5353
with:
5454
path: |
5555
~/.gradle/caches

.github/workflows/build-ios.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ jobs:
2626
run:
2727
working-directory: example/ios
2828
steps:
29-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v4
3030

3131
- name: Get yarn cache directory path
3232
id: yarn-cache-dir-path
3333
run: echo "::set-output name=dir::$(yarn cache dir)"
3434
- name: Restore node_modules from cache
35-
uses: actions/cache@v2
35+
uses: actions/cache@v4
3636
id: yarn-cache
3737
with:
3838
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@@ -56,7 +56,7 @@ jobs:
5656
working-directory: example
5757

5858
- name: Restore Pods cache
59-
uses: actions/cache@v2
59+
uses: actions/cache@v4
6060
with:
6161
path: |
6262
example/ios/Pods

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def reactNativeArchitectures() {
5151
}
5252

5353
apply plugin: "com.android.library"
54+
apply from: "./gradle/fix-prefab.gradle"
5455

5556
if (isNewArchitectureEnabled()) {
5657
apply plugin: "com.facebook.react"

android/gradle/fix-prefab.gradle

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
tasks.configureEach { task ->
2+
// Make sure that we generate our prefab publication file only after having built the native library
3+
// so that not a header publication file, but a full configuration publication will be generated, which
4+
// will include the .so file
5+
6+
def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
7+
def matcher = task.name =~ prefabConfigurePattern
8+
if (matcher.matches()) {
9+
def variantName = matcher[0][1]
10+
task.outputs.upToDateWhen { false }
11+
if (prepareHeaders) {
12+
task.dependsOn(prepareHeaders)
13+
}
14+
task.dependsOn("externalNativeBuild${variantName}")
15+
}
16+
17+
}
18+
19+
afterEvaluate {
20+
def abis = reactNativeArchitectures()
21+
rootProject.allprojects.each { proj ->
22+
if (proj === rootProject) return
23+
24+
def dependsOnThisLib = proj.configurations.findAll { it.canBeResolved }.any { config ->
25+
config.dependencies.any { dep ->
26+
dep.group == project.group && dep.name == project.name
27+
}
28+
}
29+
if (!dependsOnThisLib && proj != project) return
30+
31+
if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
32+
return
33+
}
34+
35+
def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
36+
// Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
37+
// generate a libnameConfig.cmake file that will contain our native library (.so).
38+
// 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
39+
variants.all { variant ->
40+
def variantName = variant.name
41+
abis.each { abi ->
42+
def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
43+
if (!searchDir.exists()) return
44+
def matches = []
45+
searchDir.eachDir { randomDir ->
46+
def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
47+
if (prefabFile.exists()) matches << prefabFile
48+
}
49+
matches.each { prefabConfig ->
50+
prefabConfig.setLastModified(System.currentTimeMillis())
51+
}
52+
}
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)