Skip to content

Commit a54fe27

Browse files
committed
[android] Support caching prebuilt hermes-engine
1 parent e43500d commit a54fe27

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/react-native/ReactAndroid/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
237237
it.outputDir.set(prefabHeadersDir)
238238
}
239239

240+
def prebuiltHermesDir = findProperty("expo.prebuiltHermesDir") ?: file("${rootDir}/prebuiltHermes")
241+
def prebuiltHermesVersion = file("${prebuiltHermesDir}/.hermesversion").exists() ? file("${prebuiltHermesDir}/.hermesversion").text : null
242+
def currentHermesVersion = file("${project(':packages:react-native:ReactAndroid').projectDir}/../sdks/.hermesversion").exists() ? file("${project(':packages:react-native:ReactAndroid').projectDir}/../sdks/.hermesversion").text : null
243+
def buildHermesSource = currentHermesVersion != prebuiltHermesVersion
244+
logger.info(":ReactAndroid - buildHermesSource[${buildHermesSource}]")
245+
240246
task createNativeDepsDirectories {
241247
downloadsDir.mkdirs()
242248
thirdPartyNdkDir.mkdirs()
@@ -699,7 +705,12 @@ dependencies {
699705

700706
// It's up to the consumer to decide if hermes should be included or not.
701707
// Therefore hermes-engine is a compileOnly dependency.
702-
compileOnly(project(":packages:react-native:ReactAndroid:hermes-engine"))
708+
if (!buildHermesSource) {
709+
debugCompileOnly(files("${prebuiltHermesDir}/hermes-engine-debug.aar"))
710+
releaseCompileOnly(files("${prebuiltHermesDir}/hermes-engine-release.aar"))
711+
} else {
712+
compileOnly(project(":packages:react-native:ReactAndroid:hermes-engine"))
713+
}
703714

704715
testImplementation("junit:junit:${JUNIT_VERSION}")
705716
testImplementation("org.assertj:assertj-core:${ASSERTJ_VERSION}")

0 commit comments

Comments
 (0)