-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathbuild.gradle
More file actions
159 lines (140 loc) · 5.73 KB
/
build.gradle
File metadata and controls
159 lines (140 loc) · 5.73 KB
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
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
android {
compileSdkVersion 33
namespace "com.viro.viroreact"
buildFeatures {
buildConfig = true
prefab true // required to consume native headers + libopenxr_loader.so from the AAR
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
defaultConfig {
minSdkVersion 24
targetSdkVersion 33
ndkVersion = "25.2.9519653"
ndk {
// React Native does not support arm64-v8a yet, so don't bother including
// it here.
// Tracking issue for RN: https://github.com/facebook/react-native/issues/2814
abiFilters "arm64-v8a", "armeabi-v7a"
}
// c++_shared STL: pre-built Bullet/GVR libs require libc++_shared.so.
// When used with React Native, RN provides libc++_shared.so. For standalone
// apps (openxrtest), the NDK packages it automatically with c++_shared.
externalNativeBuild {
cmake {
targets "viro_renderer"
cppFlags "-std=c++14 -frtti -fexceptions"
arguments "-DANDROID_STL=c++_shared"
}
}
// Used to differentiate virocore from viroreact in code
buildConfigField "String", "VIRO_PLATFORM", "\"VIRO_REACT\""
}
sourceSets {
main {
// Use the /sharedCode directory for the source, resources, and assets
java.srcDirs = ['../sharedCode/src/main/java']
res.srcDirs = ['../sharedCode/src/main/res']
assets.srcDirs = ['../sharedCode/src/main/assets']
// Package both the /sharedCode jniLibs viroar's build/natives libs into the AAR
jniLibs.srcDirs = ['../sharedCode/src/main/jniLibs', '../viroar/build/natives/jni']
manifest.srcFile '../sharedCode/src/main/AndroidManifest.xml'
}
}
externalNativeBuild {
cmake {
path "../sharedCode/CMakeLists.txt"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
packagingOptions {
// The NDK ABI filters above prevent us from building arm64-v8a and x86 architectures for
// viro_renderer and viro_arcore, but we also have to stop gradle from copying all of our
// arm64-v8a and x86 dependencies. We do that through these packaging options.
exclude '**/x86/**'
pickFirst 'lib/armeabi-v7a/libBulletDynamics.so'
pickFirst 'lib/armeabi-v7a/libgvr.so'
pickFirst 'lib/armeabi-v7a/libgvr_audio.so'
pickFirst 'lib/armeabi-v7a/libfreetyped.so'
pickFirst 'lib/armeabi-v7a/libBulletCollision.so'
pickFirst 'lib/armeabi-v7a/libLinearMath.so'
pickFirst 'lib/armeabi-v7a/libvrapi.so'
pickFirst 'lib/armeabi-v7a/libBulletSoftBody.so'
pickFirst 'lib/arm64-v8a/libBulletDynamics.so'
pickFirst 'lib/arm64-v8a/libgvr.so'
pickFirst 'lib/arm64-v8a/libgvr_audio.so'
pickFirst 'lib/arm64-v8a/libfreetyped.so'
pickFirst 'lib/arm64-v8a/libBulletCollision.so'
pickFirst 'lib/arm64-v8a/libLinearMath.so'
pickFirst 'lib/arm64-v8a/libvrapi.so'
pickFirst 'lib/arm64-v8a/libBulletSoftBody.so'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.0.0"
implementation 'androidx.media3:media3-exoplayer:1.1.1'
implementation 'androidx.media3:media3-exoplayer-dash:1.1.1'
implementation 'androidx.media3:media3-exoplayer-hls:1.1.1'
implementation 'androidx.media3:media3-exoplayer-smoothstreaming:1.1.1'
implementation project(':libs:gvr')
implementation 'com.google.ar:core:1.54.0'
implementation 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7'
// OpenXR loader — from local Maven repo (openxr_sdk/maven), sourced from Khronos GitHub releases.
// Provides libopenxr_loader.so (arm64-v8a) + native headers via Prefab.
// Note: artifact ID is openxr_loader_for_android (not openxr_loader_android).
implementation 'org.khronos.openxr:openxr_loader_for_android:1.1.38'
}
task copyReleaseAAR(type: Copy) {
from('build/outputs/aar')
// Change the next line to reflect the path to your viro repo
into('../../../viro/android/viro_renderer/')
include('viroreact-release.aar')
rename('viroreact-release.aar', 'viro_renderer-release.aar')
}
// We have to add dependencies to Android tasks in this deferred way because these tasks
// are dynamically generated.
//
// Before assembling release, implementation :viroar:assembleRelease, which will place its .so
// products in its build/natives folder. The jniLibs source set above will ensure these
// .so files are included in our final AAR.
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease') {
task.dependsOn ':viroar:assembleRelease'
task.finalizedBy 'copyReleaseAAR'
}
}
task copyDebugAAR(type: Copy) {
from('build/outputs/aar')
// Change the next line to reflect the path to your viro repo
into('../../../viro/android/viro_renderer/')
include('viroreact-debug.aar')
rename('viroreact-debug.aar', 'viro_renderer-release.aar')
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleDebug') {
task.dependsOn ':viroar:assembleDebug'
task.finalizedBy 'copyDebugAAR'
}
}
// project.afterEvaluate {
// publishing {
// publications {
// release(MavenPublication) {
// from components.release
// }
// }
// }
// }