forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
120 lines (108 loc) · 3.14 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the LICENSE
// file in the root directory of this source tree.
//
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
apply plugin: 'com.android.library'
def facebookBuild = System.getenv("FACEBOOK") ?: "0"
def abis = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
def hermes_ws = System.getenv("HERMES_WS_DIR")
// This must be consistent with the release_version in npm/package.json
// and the HERMES_RELEASE_VERSION in CMakeLists.txt
def release_version = "0.1.0"
// For Facebook internal use:
def fbsource = System.getenv("FBSOURCE_DIR") ?:
System.getenv("HOME") + "/fbsource"
if (hermes_ws == null || hermes_ws == "") {
throw new InvalidUserDataException("HERMES_WS_DIR is not set")
}
buildDir = "${hermes_ws}/build_android"
buildDir.mkdirs()
android {
compileSdkVersion = 28
defaultConfig {
externalNativeBuild {
cmake {
arguments "-DHERMES_IS_ANDROID=True"
arguments "-DHERMES_FACEBOOK_BUILD=${facebookBuild}"
arguments "-DANDROID_STL=c++_shared"
arguments "-DANDROID_PIE=True"
arguments "-DLLVM_BUILD_BASE=${hermes_ws}/llvm"
arguments "-DLLVM_SRC_DIR=${hermes_ws}/llvm"
arguments "-DFBSOURCE_DIR=${fbsource}"
targets "libhermes"
}
}
ndk {
abiFilters (*abis)
}
}
externalNativeBuild {
cmake {
version "3.6.0"
path "../CMakeLists.txt"
buildStagingDirectory = "${hermes_ws}/staging"
buildStagingDirectory.mkdirs()
}
}
buildTypes {
debug {
externalNativeBuild {
cmake {
arguments "-DHERMES_ENABLE_DEBUGGER=True"
}
}
}
}
}
allprojects {
repositories {
google()
jcenter()
}
afterEvaluate {
// Gradle 4/5.0 outputs android-debug.aar and android-release.aar
// Gradle 5.1 outputs android.aar for both
// Unify the two by renaming the files afterwards.
// Neither appear to care whether the original filename actually exists.
def aarDir = "$buildDir/outputs/aar/"
tasks.named("assembleDebug").configure {
doLast {
file("$aarDir/android-debug.aar").renameTo("$aarDir/hermes-debug.aar")
file("$aarDir/android.aar").renameTo("$aarDir/hermes-debug.aar")
}
}
tasks.named("assembleRelease").configure {
doLast {
file("$aarDir/android-release.aar").renameTo("$aarDir/hermes-release.aar")
file("$aarDir/android.aar").renameTo("$aarDir/hermes-release.aar")
}
}
}
}
task copyApiHeaders(type: Copy) {
from "$projectDir/../API/hermes"
include '**/*.h'
into "$buildDir/outputs/aar/include/hermes"
}
task copyPublicHeaders(type: Copy) {
from "$projectDir/../public/hermes/Public"
include '**/*.h'
into "$buildDir/outputs/aar/include/hermes/Public"
}
task githubRelease(dependsOn: ['build', 'copyApiHeaders', 'copyPublicHeaders'], type: Tar) {
baseName = "hermes-runtime-android"
version = "v" + release_version
extension = "tar.gz"
compression = Compression.GZIP
from "$buildDir/outputs/aar"
}