Skip to content

Commit

Permalink
Create a Gradle task to setup the Hermes Ninja build
Browse files Browse the repository at this point in the history
Summary:
As the title says, we need to invoke:
```
./utils/build/configure.py ./ninja_build
cmake --build ./ninja_build --target hermesc
```
In order to build the Hermes compiler, otherwise the CMake build
will fail with a missing Cmake file.

Changelog:
[Internal] [Changed] - Create a Gradle task to setup the Hermes Ninja build

Reviewed By: hramos

Differential Revision: D34213468

fbshipit-source-id: 83f70bdb068f99ce17a44207b4282fde2d7420ca
  • Loading branch information
cortinico authored and facebook-github-bot committed Mar 4, 2022
1 parent 191fc0f commit d96cd6d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ReactAndroid/hermes-engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import org.apache.tools.ant.taskdefs.condition.Os

plugins {
id("de.undercouch.download")
}
Expand All @@ -17,6 +19,7 @@ def hermesVersionFile = rootProject.file("sdks/.hermesversion")
if (hermesVersionFile.exists()) {
hermesVersion = hermesVersionFile.text
}
def ndkBuildJobs = Runtime.runtime.availableProcessors().toString()

task downloadHermes(type: Download) {
src("https://github.com/facebook/hermes/tarball/${hermesVersion}")
Expand All @@ -42,3 +45,23 @@ task unzipHermes(dependsOn: downloadHermes, type: Copy) {
}
into(hermesDir)
}


task configureNinjaForHermes(dependsOn: unzipHermes, type: org.gradle.api.tasks.Exec) {
workingDir(hermesDir)
commandLine(windowsAwareCommandLine("python3", "utils/build/configure.py", "./ninja_build"))
}

task buildNinjaForHermes(dependsOn: configureNinjaForHermes, type: org.gradle.api.tasks.Exec) {
workingDir(hermesDir)
commandLine(windowsAwareCommandLine("cmake", "--build", "./ninja_build", "--target", "hermesc", "-j", ndkBuildJobs))
}

static def windowsAwareCommandLine(String... commands) {
def newCommands = []
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
newCommands = ['cmd', '/c']
}
newCommands.addAll(commands)
return newCommands
}

0 comments on commit d96cd6d

Please sign in to comment.