forked from WiVRn/WiVRn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
247 lines (205 loc) · 7.66 KB
/
build.gradle
File metadata and controls
247 lines (205 loc) · 7.66 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
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
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.13.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: 'com.android.application'
import javax.inject.Inject
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.*
import org.gradle.api.file.DirectoryProperty
import org.gradle.process.ExecOperations
abstract class GeneratePngsTask extends DefaultTask {
@Inject
abstract ExecOperations getExecOps()
@InputFile
abstract RegularFileProperty getSvg()
@InputFile
@Optional
abstract RegularFileProperty getCss()
@OutputDirectory
abstract DirectoryProperty getOutputDir()
@TaskAction
void generate() {
def outDir = getOutputDir().get().asFile
outDir.mkdirs()
// Map of density → size
def dpiConfigs = [
"mipmap-mdpi" : 48,
"mipmap-hdpi" : 72,
"mipmap-xhdpi" : 96,
"mipmap-xxhdpi" : 144,
"mipmap-xxxhdpi": 192
]
def cssFile = getCss().isPresent() ? getCss().get().asFile : null
dpiConfigs.each { dpi, size ->
def dpiDir = new File(outDir, dpi)
dpiDir.mkdirs()
def outputFile = new File(dpiDir, "ic_wivrn_launcher.png")
def argsList = [
getSvg().get().asFile.absolutePath,
"-w", size.toString(),
"-h", size.toString(),
"-o", outputFile.absolutePath
]
if (cssFile != null) {
argsList.add("--stylesheet=${cssFile.absolutePath}")
}
execOps.exec {
executable = "rsvg-convert"
args = argsList
}
}
}
}
tasks.register("generatePngs", GeneratePngsTask) {
group = "Custom"
// configure defaults
svg.set(layout.projectDirectory.file("images/wivrn.svg"))
outputDir.set(layout.buildDirectory.dir("generated_resources"))
if (project.hasProperty("wivrn_css")) {
css.set(layout.projectDirectory.file(project.wivrn_css))
} else {
css.set(layout.projectDirectory.file("images/wivrn-local.css"))
}
}
android {
namespace = "org.meumeu.wivrn"
ndkVersion = "28.2.13676358"
lint {
disable += "ExpiredTargetSdkVersion"
}
defaultConfig {
applicationId "org.meumeu.wivrn"
// for Vulkan, need at least 24
// for AImage_getHardwareBuffer, API 26
minSdkVersion 29
compileSdkVersion 34
targetSdkVersion 32 // for Oculus Store
versionName = project.hasProperty('wivrn_version') ? wivrn_version : "1.0"
versionCode = project.hasProperty('wivrn_versionCode') ? wivrn_versionCode.toInteger() : 1
def showImguiDemo = project.hasProperty('wivrn_show_imgui_demo') ? wivrn_show_imgui_demo : 'OFF'
def showDebugMenu = project.hasProperty('wivrn_show_debug_menu') ? wivrn_show_debug_menu : 'OFF'
def compressGlb = project.hasProperty('wivrn_compress_glb') ? wivrn_compress_glb : 'OFF'
def fetchcontentBaseDir = project.hasProperty('fetchcontent_base_dir') ? ['-DFETCHCONTENT_BASE_DIR=' + fetchcontent_base_dir] : []
externalNativeBuild {
def css = project.hasProperty('wivrn_css') ? project.wivrn_css: "images/wivrn-local.css"
cmake {
arguments = ['-DANDROID_TOOLCHAIN=clang',
'-DANDROID_STL=c++_static',
'-DCMAKE_ANDROID_NDK_VERSION=' + ndkVersion,
'-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
'-DCMAKE_ANDROID_ASSETS_DIRECTORIES=' + layout.buildDirectory.dir("assets").get().asFile,
'-DWIVRN_USE_SYSTEM_BOOST=OFF',
'-DWIVRN_USE_SYSTEM_FREETYPE=OFF',
'-DWIVRN_USE_ANDROID_BIN_LIBKTX=ON',
'-DWIVRN_BUILD_CLIENT=ON',
'-DWIVRN_BUILD_SERVER=OFF',
'-DWIVRN_BUILD_SERVER_LIBRARY=OFF',
'-DWIVRN_BUILD_WIVRNCTL=OFF',
'-DWIVRN_BUILD_DASHBOARD=OFF',
'-DWIVRN_WERROR=ON',
'-DWIVRN_SHOW_IMGUI_DEMO_WINDOW=' + showImguiDemo,
'-DWIVRN_CLIENT_DEBUG_MENU=' + showDebugMenu,
'-DWIVRN_CSS=' + css,
'-DWIVRN_COMPRESS_GLB=' + compressGlb] +
fetchcontentBaseDir
resValue "string", "app_name", project.hasProperty('wivrn_app_name') ? project.wivrn_app_name : "WiVRn Local"
abiFilters 'arm64-v8a'//, 'x86_64'
}
}
}
signingConfigs {
if (project.hasProperty("signingKeyPassword")) {
release {
storeFile file("ks.keystore")
keyAlias "default_key"
storePassword signingKeyPassword // Set in gradle.properties
keyPassword signingKeyPassword
enableV2Signing = true
}
}
}
buildTypes {
if (project.hasProperty("signingKeyPassword")) {
release {
signingConfig = signingConfigs.release
}
}
release {
manifestPlaceholders.ComOculusSupportedDevices = "all"
applicationIdSuffix = project.hasProperty('suffix') ? suffix: ".local"
}
releaseDebuggable {
initWith release
debuggable true
// Uncomment to have debug symbols
// packagingOptions {
// doNotStrip "*/arm64-v8a/*.so"
// doNotStrip "*/armeabi-v7a/*.so"
// doNotStrip "*/x86/*.so"
// doNotStrip "*/x86_64/*.so"
// }
}
oculus
{
initWith release
applicationIdSuffix = project.hasProperty('suffix') ? suffix: ""
manifestPlaceholders.ComOculusSupportedDevices = "quest2|quest3|questpro"
}
debug {
applicationIdSuffix = project.hasProperty('suffix') ? suffix: ".local"
manifestPlaceholders.ComOculusSupportedDevices = "all"
}
debugWithValidationLayer {
initWith debug
externalNativeBuild {
cmake {
arguments '-DWIVRN_USE_ANDROID_VALIDATION_LAYER=ON'
}
}
}
}
buildTypes.all { variant ->
sourceSets {
"${variant.name}" {
jniLibs.srcDirs layout.buildDirectory.dir("libs${variant.name.capitalize()}")
}
}
externalNativeBuild{
cmake {
arguments '-DANDROID_LIB_DIRECTORIES=' + layout.buildDirectory.dir("libs${variant.name.capitalize()}").get().asFile
}
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['client/java']
res.srcDirs = [ 'resources', layout.buildDirectory.dir('generated_resources') ]
assets.srcDirs = ['assets', layout.buildDirectory.dir("assets")]
}
}
externalNativeBuild {
cmake {
version = '3.31.5'
path 'CMakeLists.txt'
}
}
tasks["preBuild"].dependsOn "generatePngs"
applicationVariants.all { variant ->
// It probably works with merge${variant.name.capitalize()}Assets too
tasks["generate${variant.name.capitalize()}Assets"].dependsOn "externalNativeBuild${variant.name.capitalize()}"
}
}