Create a Gradle task to setup the Hermes Ninja build

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
This commit is contained in:
Nicola Corti
2022-03-04 07:27:13 -08:00
committed by Facebook GitHub Bot
parent 191fc0f7cc
commit d96cd6d285
+23
View File
@@ -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")
}
@@ -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}")
@@ -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
}