Setup a Gradle build inside ReactAndroid/hermes-engine to download Hermes sources

Summary:
This Diff sets up a small Gradle build inside `ReactAndroid/hermes-engine`
The idea is to kickoff a small project where we can download Hermes sources and start a compilation of
the Hermes sources from there.

Specifically the used paths are:

- `/sdk/hermes` for the unzipping
- `/sdk/download/hermes.tar.gz` for the tarball location
- `/sdk/hermes/.hermesversion` for the hermes version.

allow-large-files

Changelog:
[Internal] [Changed] - Setup a Gradle build inside `hermes-engine` to download Hermes sources

Reviewed By: hramos

Differential Revision: D34210236

fbshipit-source-id: 97034f5608dfb3fcd1d74e9851944f7a60e52ea1
This commit is contained in:
Nicola Corti 2022-03-04 07:27:13 -08:00 committed by Facebook GitHub Bot
parent a159416333
commit 191fc0f7cc
3 changed files with 49 additions and 3 deletions

5
.gitignore vendored
View File

@ -24,6 +24,7 @@ project.xcworkspace
# Gradle
/build/
/packages/react-native-gradle-plugin/build/
/packages/rn-tester/build
/packages/rn-tester/android/app/.cxx/
/packages/rn-tester/android/app/build/
/packages/rn-tester/android/app/gradle/
@ -34,6 +35,7 @@ project.xcworkspace
/ReactAndroid/gradle/
/ReactAndroid/gradlew
/ReactAndroid/gradlew.bat
/ReactAndroid/hermes-engine/build/
/template/android/app/build/
/template/android/build/
@ -72,6 +74,7 @@ package-lock.json
# Hermes
/sdks/hermes
/sdks/download
# Test generated files
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
@ -85,8 +88,6 @@ package-lock.json
# ReactCommon subdir shouldn't have Xcode project
/ReactCommon/**/*.xcodeproj
/packages/rn-tester/build
/packages/rn-tester/android/app/build/*
# Libs that shouldn't have Xcode project
/Libraries/FBLazyVector/**/*.xcodeproj

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
plugins {
id("de.undercouch.download")
}
def customDownloadDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR")
def downloadsDir = customDownloadDir ? new File(customDownloadDir) : rootProject.file("sdks/download")
def hermesDir = rootProject.file("sdks/hermes")
def hermesVersion = "main"
def hermesVersionFile = rootProject.file("sdks/.hermesversion")
if (hermesVersionFile.exists()) {
hermesVersion = hermesVersionFile.text
}
task downloadHermes(type: Download) {
src("https://github.com/facebook/hermes/tarball/${hermesVersion}")
onlyIfNewer(true)
overwrite(false)
dest(new File(downloadsDir, "hermes.tar.gz"))
}
// This task is called by the CI to download all the extrenal source code tarballs.
task downloadNdkBuildDependencies() {
dependsOn(downloadHermes)
}
task unzipHermes(dependsOn: downloadHermes, type: Copy) {
from(tarTree(downloadHermes.dest)) {
eachFile { file ->
// We flatten the unzip as the tarball contains a `facebook-hermes-<SHA>`
// folder at the top level.
if (file.relativePath.segments.size() > 1) {
file.relativePath = new org.gradle.api.file.RelativePath(!file.isDirectory(), file.relativePath.segments.drop(1))
}
}
}
into(hermesDir)
}

View File

@ -15,6 +15,7 @@ pluginManagement {
include(
":ReactAndroid",
":ReactAndroid:hermes-engine",
":packages:react-native-codegen:android",
":packages:rn-tester:android:app"
)
@ -32,4 +33,4 @@ plugins {
// you can configure your custom Gradle Enterprise instance
if (File("./gradle/gradle-enterprise.gradle.kts").exists()) {
apply(from = "./gradle/gradle-enterprise.gradle.kts")
}
}