-
Notifications
You must be signed in to change notification settings - Fork 215
/
build.gradle
382 lines (333 loc) · 11.6 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
apply plugin: 'com.android.application'
apply from: "$project.rootDir/tools/gradle/versionCode.gradle"
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
def getCrashRestartDisabled = { ->
if (gradle.hasProperty("disableCrashRestart")) {
return gradle.disableCrashRestart
}
return "false"
}
def getDevApplicationIdSufix = { ->
if (gradle.hasProperty("simultaneousDevProduction")) {
return gradle.simultaneousDevProduction == "true" ? ".dev" : ""
}
return ""
}
def getUseDebugSigningOnRelease = { ->
if (gradle.hasProperty("useDebugSigningOnRelease")) {
return gradle.useDebugSigningOnRelease == "true"
}
return false
}
android {
compileSdkVersion build_versions.target_sdk
defaultConfig {
applicationId "org.mozilla.vrbrowser"
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.1.4"
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
buildConfigField "Boolean", "DISABLE_CRASH_RESTART", getCrashRestartDisabled()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-std=c++14 -fexceptions -frtti -Werror" +
" -I" + file("src/main/cpp").absolutePath +
" -I" + file("src/main/cpp/vrb/include").absolutePath
arguments "-DANDROID_STL=c++_shared"
}
}
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
if (gradle.hasProperty('taskclusterBuild')) {
project.archivesBaseName = "FirefoxReality-$defaultConfig.versionName-$generatedVersionCode"
defaultConfig.versionCode = generatedVersionCode
} else {
project.archivesBaseName = "FirefoxReality"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig getUseDebugSigningOnRelease() ? debug.signingConfig : release.signingConfig
}
debug {
applicationIdSuffix getDevApplicationIdSufix()
pseudoLocalesEnabled true
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
dataBinding {
enabled = true
}
lintOptions {
disable "LogUsage", "ExtraTranslation"
}
packagingOptions {
pickFirst '/lib/*/libgvr.so'
}
flavorDimensions "platform", "abi"
productFlavors {
// Supported platforms
googlevr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/gvr-android-sdk/libraries/headers").absolutePath +
" -DVRBROWSER_GOOGLEVR"
arguments "-DVR_SDK_LIB=googlevr-lib", "-DGOOGLEVR=ON"
}
}
}
oculusvr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/third_party/ovr_mobile/VrApi/Include").absolutePath +
" -I" + file("${project.rootDir}/app/src/oculusvr/cpp").absolutePath +
" -DOCULUSVR"
arguments "-DVR_SDK_LIB=oculusvr-lib", "-DOCULUSVR=ON"
}
}
}
svr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/third_party/svr/public").absolutePath +
" -I" + file("${project.rootDir}/app/src/svr/cpp").absolutePath +
" -DSNAPDRAGONVR"
arguments "-DVR_SDK_LIB=svr-lib", "-DSNAPDRAGONVR=ON"
}
}
}
wavevr {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -I" + file("${project.rootDir}/third_party/wavesdk/build/wvr_client/include").absolutePath
arguments "-DVR_SDK_LIB=wavevr-lib", "-DWAVEVR=ON"
}
}
}
noapi {
dimension "platform"
externalNativeBuild {
cmake {
cppFlags " -DVRBROWSER_NO_VR_API"
arguments "-DNOAPI=ON"
}
}
}
// Supported ABIs
arm {
dimension "abi"
ndk {
abiFilters "armeabi-v7a"
}
}
arm64 {
dimension "abi"
ndk {
abiFilters "arm64-v8a"
}
}
x86 {
dimension "abi"
ndk {
abiFilters "x86"
}
}
}
variantFilter { variant ->
def needed = variant.name in [
'googlevrArmDebug',
'googlevrArmRelease',
'googlevrArm64Debug',
'googlevrArm64Release',
'oculusvrArmDebug',
'oculusvrArmRelease',
'oculusvrArm64Debug',
'oculusvrArm64Release',
'svrArmDebug',
'svrArmRelease',
'svrArm64Debug',
'svrArm64Release',
'wavevrArmDebug',
'wavevrArmRelease',
'noapiArmDebug',
'noapiArmRelease',
'noapiArm64Debug',
'noapiArm64Release',
'noapiX86Debug',
'noapiX86Release'
]
variant.setIgnore(!needed)
}
sourceSets {
main {
java.srcDirs = [
'app',
'src/common/shared',
'src/main/cpp/vrb/android/java'
]
}
release {
manifest.srcFile getUseDebugSigningOnRelease() ? "src/debug/AndroidManifest.xml"
: manifest.srcFile
}
googlevr {
java.srcDirs = [
'src/googlevr/java'
]
}
oculusvr {
java.srcDirs = [
'src/oculusvr/java'
]
}
oculusvrArmRelease {
manifest.srcFile getUseDebugSigningOnRelease() ? "src/oculusvrArmDebug/AndroidManifest.xml"
: manifest.srcFile
}
oculusvrArm64Debug {
manifest.srcFile "src/oculusvrArmDebug/AndroidManifest.xml"
}
oculusvrArm64Release {
manifest.srcFile getUseDebugSigningOnRelease() ? "src/oculusvrArmDebug/AndroidManifest.xml"
: "src/oculusvrArmRelease/AndroidManifest.xml"
}
svr {
java.srcDirs = [
'src/svr/java'
]
jniLibs.srcDirs = ["${project.rootDir}/third_party/svr/libs"]
}
wavevr {
java.srcDirs = [
'src/wavevr/java'
]
res.srcDirs = [
'src/wavevr/res'
]
jniLibs.srcDirs = ["${project.rootDir}/third_party/wavesdk/build/wvr_client/jni"]
}
noapi {
java.srcDirs = [
'src/noapi/java'
]
}
}
}
configurations {
armImplementation
x86Implementation
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// Common
// implementation deps.google_vr.sdk_audio
implementation deps.room.runtime
annotationProcessor deps.room.compiler
implementation deps.lifecycle.runtime
implementation deps.lifecycle.extensions
implementation deps.support.cardview
implementation deps.support.app_compat
implementation deps.support.annotations
implementation deps.constraint_layout
// Android Components
implementation deps.mozilla_speech
implementation deps.android_components.telemetry
implementation deps.android_components.browser_errorpages
implementation deps.android_components.browser_search
implementation deps.android_components.browser_domains
implementation deps.android_components.ui_autocomplete
// SQLite helper to handle DBs from assets
implementation deps.sqlite.sqlite
// Testing
testImplementation deps.junit
androidTestImplementation deps.atsl.runner
androidTestImplementation deps.espresso.core
testImplementation deps.room.testing
// Daydream
googlevrImplementation deps.google_vr.sdk_base
// ODG
svrImplementation fileTree(dir: "${project.rootDir}/third_party/svr/", include: ['*.jar'])
}
if (findProject(':servo')) {
dependencies {
oculusvrImplementation project(':servo')
googlevrImplementation project(':servo')
}
}
if (findProject(':wavesdk')) {
dependencies {
wavevrImplementation project(':wavesdk')
}
}
if (findProject(':geckoview-local')) {
dependencies {
implementation project(':geckoview-local')
implementation deps.snakeyaml
}
} else {
dependencies {
// To see what the latest geckoview-nightly version is go here:
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/geckoview-nightly-armeabi-v7a/
armImplementation deps.gecko_view.nightly_armv7a
arm64Implementation deps.gecko_view.nightly_arm64
x86Implementation deps.gecko_view.nightly_x86
}
}
// -------------------------------------------------------------------------------------------------
// Dynamically set versionCode (See tools/build/versionCode.gradle
// -------------------------------------------------------------------------------------------------
android.applicationVariants.all { variant ->
def buildType = variant.buildType.name
if (gradle.hasProperty('taskclusterBuild')) {
def versionCode = generatedVersionCode
// The Google Play Store does not allow multiple APKs for the same app that all have the
// same version code. Therefore we need to have different version codes for our ARM and x86
// builds.
// Our generated version code has a length of 8 (See tools/gradle/versionCode.gradle).
// We will prefix our ARM builds with 1 and our x86 builds with 2. Our x86 builds need a
// higher version code to avoid installing ARM builds on an x86 device with ARM
// compatibility mode.
def multiplier = 100000000
// Currently only support arm7
if (variant.flavorName.contains("X86")) {
versionCode = versionCode + (3 * multiplier)
} else if (variant.flavorName.contains("Aarch64")) {
versionCode = versionCode + (2 * multiplier)
} else if (variant.flavorName.contains("Arm")) {
versionCode = versionCode + (1 * multiplier)
}
variant.outputs.each { output ->
output.versionCodeOverride = versionCode
}
}
println("----------------------------------------------")
println("Build type: " + buildType)
println("Flavor: " + variant.flavorName)
println("Version code: " + variant.mergedFlavor.versionCode)
}