Skip to content

Commit

Permalink
[Discord] Adding release hermesc publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Flewp committed Jul 22, 2024
1 parent 44676a3 commit 82b7e0f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/react-native/ReactAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,17 @@ val createReactNdkLibraryZipArchiveForDiscord by
destinationDirectory.set(layout.projectDirectory)
}

// This is the task to run to create a .zip of hermesc for CI machines
val createHermescReleaseZipArchiveForDiscord by
tasks.registering(Zip::class) {
dependsOn(":packages:react-native:ReactAndroid:hermes-engine:buildHermescReleaseBinary")
archiveFileName = "hermescForDiscord.zip"
from(layout.projectDirectory.dir("hermes-engine/build/hermesc-release/bin"))

// Place this .zip right into our ReactAndroid directory
destinationDirectory = layout.projectDirectory
}

repositories {
// Normally RNGP will set repositories for all modules,
// but when consumed from source, we need to re-declare
Expand Down Expand Up @@ -868,5 +879,11 @@ publishing {
artifactId = "discord-rn-libs"
artifact(tasks.named("createReactNdkLibraryZipArchiveForDiscord").get())
}
create<MavenPublication>("hermescReleaseZip") {
groupId = "com.facebook.react"
version = "test"
artifactId = "discord-hermesc-release"
artifact(tasks.named("createHermescReleaseZipArchiveForDiscord").get())
}
}
}
52 changes: 52 additions & 0 deletions packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ val hermesDir =
}
val hermesBuildDir = File("$buildDir/hermes")
val hermesCOutputBinary = File("$buildDir/hermes/bin/hermesc")
val hermescReleaseBuildDir = File("$buildDir/hermesc-release/")

// This filetree represents the file of the Hermes build that we want as input/output
// of the buildHermesC task. Gradle will compute the hash of files in the file tree
Expand Down Expand Up @@ -156,6 +157,57 @@ val prepareHeadersForPrefab by
into(prefabHeadersDir)
}

/**
NOTE(Flewp): Taken from https://github.com/facebook/hermes/blob/9f8603b9886c957e0ccead61fe4380616188bbb4/.circleci/config.yml#L115-L123
The idea here is to replicate building the hermesc binary historically provided by the hermes-engine-cli package.
Config Step
cmake -S hermes -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive" \
-DHERMES_ENABLE_DEBUGGER=False
Build Step
cmake --build build --target check-hermes hermes hvm hbcdump hermesc
*/
val configureBuildForHermescReleaseBinary by
tasks.registering(Exec::class) {
dependsOn(unzipHermes)
commandLine(
windowsAwareCommandLine(
findCmakePath(cmakeVersion),
"-S",
".",
"-B",
hermescReleaseBuildDir.toString(),
"-DHERMES_STATIC_LINK=ON",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True",
"-DCMAKE_CXX_FLAGS=-s",
"-DCMAKE_C_FLAGS=-s",
"-DHERMES_ENABLE_DEBUGGER=False",
"-DJSI_DIR=" + jsiDir.absolutePath,
"-DICU_FOUND=1"
)
)
}

val buildHermescReleaseBinary by
tasks.registering(Exec::class) {
dependsOn(configureBuildForHermescReleaseBinary)
commandLine(
windowsAwareCommandLine(
findCmakePath(cmakeVersion),
"--build",
hermescReleaseBuildDir.toString(),
"--target",
"hermesc",
"-j",
ndkBuildJobs
)
)
}

fun windowsAwareCommandLine(vararg commands: String): List<String> {
val result =
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
Expand Down

0 comments on commit 82b7e0f

Please sign in to comment.