-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathbuild.gradle
261 lines (235 loc) · 8.88 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
import com.android.build.gradle.internal.dsl.PackagingOptions
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply from: '../versioning.gradle'
apply plugin: "com.diffplug.spotless"
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
def defaultALVRFlavour = "--release"
android {
signingConfigs {
releaseconfig {
if( System.getenv('GITHUB_EVENT_NAME') == 'pull_request' || System.getenv("Store") == null || System.getenv("Key") == null ) {
// If its a PR Supply a dummy KeySigningConfig
// Or in Local env if Store and Keys are not present in ENV Vars do the same
storeFile file("PhoneVRKeyStorePR.jks")
storePassword "test1234"
keyAlias "PhoneVRKeyPR"
keyPassword "test1234"
println "[PVR] Configuring releaseconfigs for testing a PR..."
}
else {
storeFile file(keystoreProperties['storeFile'])
storePassword System.getenv("Store")
keyAlias keystoreProperties['keyAlias']
keyPassword System.getenv("Key")
println "[PVR] Configuring releaseconfigs for release (push) (not a PR)"
}
}
}
compileSdkVersion 34
namespace 'viritualisres.phonevr'
ndkVersion '25.2.9519653' // r25c
defaultConfig {
applicationId "viritualisres.phonevr"
minSdkVersion 24
targetSdkVersion 33
versionCode buildVersionCode()
versionName buildVersionName()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments useTestStorageService: 'true'
externalNativeBuild {
cmake {
cppFlags "-std=c++17 -fexceptions -frtti" //-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON"
}
}
defaultPublishConfig 'release'
publishNonDefault true
archivesBaseName = "PhoneVR-v$versionName"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
signingConfig signingConfigs.releaseconfig
}
debug {
debuggable true
jniDebuggable true
renderscriptDebuggable true
minifyEnabled false
externalNativeBuild {
cmake {
cppFlags += "-D_DEBUG=1"
}
}
defaultALVRFlavour = ""
}
}
buildFeatures {
buildConfig = true // TODO: Remove BuildConfig, Gradle suggests this usage is inefficient > v8 disabled by default
viewBinding true
}
flavorDimensions "gvr"
productFlavors {
gvr {
dimension "gvr"
externalNativeBuild {
cmake {
arguments "-D HAVEGVR=true"
}
}
}
noGvr {
dimension "gvr"
versionNameSuffix "-nogvr"
}
}
sourceSets {
main {
jniLibs.srcDirs = ["libraries/jni", "../ALVR/build/alvr_client_core"]
}
gvr {
jniLibs.srcDirs = ["libraries/jni", "libraries_gvr/jni", "../ALVR/build/alvr_client_core"]
}
}
externalNativeBuild {
cmake {
// version "3.6.4"
path "CMakeLists.txt"
}
}
project.gradle.taskGraph.whenReady {
android.productFlavors.all { flavor ->
// Capitalize (as Gralde is case-sensitive).
def flavorName = flavor.name.substring(0, 1).toUpperCase() + flavor.name.substring(1)
// At last, configure.
"connected${flavorName}DebugAndroidTest" {
ignoreFailures = true
}
}
}
// CompileOptions required for ARCA
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
jniLibs.useLegacyPackaging = true
gradle.startParameter.getTaskNames().each { task ->
println("[PVR] task is " + task)
if (task.contains('debug') || task.contains('Debug')) {
def android = project.extensions.findByName("android")
if(android != null) {
PackagingOptions packagingOptions = android["packagingOptions"]
if (packagingOptions != null) {
packagingOptions.doNotStrip = [ "**/*.so" ]
}
}
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.6.1'
implementation "androidx.tracing:tracing:1.1.0"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.test.ext:junit-ktx:$extJUnitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.3.0'
androidTestImplementation "androidx.test:rules:$androidXTestVersion"
androidTestUtil "androidx.test.services:test-services:$servicesVersion"
gvrImplementation 'com.google.vr:sdk-base:1.200.0@aar'
implementation 'com.google.cardboard.sdk:cardboard-sdk:1.17.0@aar'
implementation 'io.github.zxing-cpp:android:2.3.0-SNAPSHOT'
implementation 'com.google.protobuf:protobuf-javalite:3.19.4'
implementation 'androidx.camera:camera-core:1.3.4'
implementation 'androidx.camera:camera-view:1.3.4'
implementation 'androidx.camera:camera-lifecycle:1.3.4'
implementation 'androidx.camera:camera-camera2:1.3.4'
def acraVersion = '5.7.0'
implementation "ch.acra:acra-mail:$acraVersion"
implementation "ch.acra:acra-dialog:$acraVersion"
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
}
// The dependencies for NDK builds live inside the .aar files so they need to
// be extracted before NDK targets can link against.
task extractNdk(type: Copy) {
copy {
from zipTree("../cardboard/cardboard-sdk.aar")
into "libraries/"
include "jni/**/libGfxPluginCardboard.so"
}
if (file("../gvr-android-sdk-1.200/libraries/sdk-base-1.200.0.aar").exists()) {
copy {
from zipTree("../gvr-android-sdk-1.200/libraries/sdk-base-1.200.0.aar")
into "libraries_gvr/"
include "headers/vr/gvr/capi/**/*h"
include "jni/**/libgvr_audio.so"
include "jni/**/libgvr.so"
}
}
}
task deleteNdk(type: Delete) {
delete "libraries/"
delete "../ALVR/build/"
delete "../ALVR/target/"
}
task deleteGradleJniCache(type: Delete)
{
// delete merged_jni_libs
delete "build/intermediates/merged_jni_libs"
}
task buildClientLib {
dependsOn deleteGradleJniCache
doLast {
exec {
workingDir '../ALVR'
if(defaultALVRFlavour.length() > 0)
commandLine 'cargo', 'xtask', 'build-client-lib', '--all-targets', '--no-stdcpp', defaultALVRFlavour
else
commandLine 'cargo', 'xtask', 'build-client-lib', '--all-targets', '--no-stdcpp'
}
}
}
// run /src/androidTest/java/viritualisres/phonevr/utils/pvr-adb-telnet.sh before starting connectedAndroidTest
// TODO: Automate with gradle tasks
//connectedAndroidTest.dependsOn(runPVRADBTelnetServer)
spotless {
java {
// don't need to set target, it is inferred from java
// fix formatting of type annotations
target '**/*.java'
formatAnnotations()
removeUnusedImports()
// apply a specific flavor of google-java-format
googleJavaFormat().aosp().reflowLongStrings()
// make sure every file has the following copyright header.
// optionally, Spotless can set copyright years by digging
// through git history (see "license" section below)
licenseHeader '/* (C)$YEAR */'
}
kotlin {
// by default the target is every '.kt' and '.kts` file in the java sourcesets
target '**/*.kt'
ktfmt().dropboxStyle() // has its own section below
licenseHeader '/* (C)$YEAR */' // or licenseHeaderFile
}
}
preBuild.dependsOn(buildClientLib)
preBuild.dependsOn("spotlessCheck")
build.dependsOn(extractNdk)
build.dependsOn(buildClientLib)
clean.dependsOn(deleteNdk)