-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbuild.gradle
249 lines (214 loc) · 7.7 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: 'config.gradle'
repositories {
google()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/"}
}
dependencies {
classpath "com.android.tools.build:gradle:$versions.gradlePluginVersion"
classpath "io.github.gradle-nexus:publish-plugin:$versions.nexusPublishVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion"
}
}
plugins {
id 'io.github.gradle-nexus.publish-plugin'
}
apply from: 'config.gradle'
apply from: 'scripts/publish-root.gradle'
group = ossrhGroupId
version = getReleaseVersion()
task clean(type: Delete) {
delete rootProject.buildDir
dependsOn 'cleanAddon'
dependsOn 'cleanBuildFromSamples'
dependsOn 'cleanZippedSamples'
dependsOn 'cleanScons'
dependsOn ':plugin:clean'
}
/**
* Clean the artifacts for the 'godotopenxrvendors' addon
*/
task cleanAddon(type: Delete) {
// Delete the bin directory for the addon
delete("demo/addons/godotopenxrvendors/.bin")
}
/**
* Build the 'godotopenxrvendors' plugin
*/
task buildPlugin {
// Generate the editor gdextension binaries
dependsOn ':buildSconsArtifacts'
dependsOn ":plugin:build"
finalizedBy "copyBuildToSamples"
}
/*
* Find scons executable path
*/
def getSconsExecutableFile() {
File sconsExecutableFile = null
def sconsName = "scons"
def sconsExts = (org.gradle.internal.os.OperatingSystem.current().isWindows()
? [".bat", ".cmd", ".ps1", ".exe"]
: [""])
logger.debug("Looking for $sconsName executable path")
for (ext in sconsExts) {
String sconsNameExt = sconsName + ext
logger.debug("Checking $sconsNameExt")
sconsExecutableFile = org.gradle.internal.os.OperatingSystem.current().findInPath(sconsNameExt)
if (sconsExecutableFile != null) {
// We're done!
break
}
// Check all the options in path
List<File> allOptions = org.gradle.internal.os.OperatingSystem.current().findAllInPath(sconsNameExt)
if (!allOptions.isEmpty()) {
// Pick the first option and we're done!
sconsExecutableFile = allOptions.get(0)
break
}
}
return sconsExecutableFile
}
def createSconsTasks(File sconsExecutableFile, boolean clean) {
def defaultArgs = [
"--directory=.",
"custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json",
"build_profile=thirdparty/godot_cpp_build_profile/build_profile.json",
]
if (clean) {
defaultArgs << "-c"
}
def taskPrefix = (clean ? "clean" : "build")
// Android.
tasks.create(name: "${taskPrefix}GodotOpenXRVendorsAndroidArm64Debug", type: Exec) {
executable sconsExecutableFile.absolutePath
args defaultArgs + ["platform=android", "target=template_debug", "arch=arm64"]
}
tasks.create(name: "${taskPrefix}GodotOpenXRVendorsAndroidArm64Release", type: Exec) {
executable sconsExecutableFile.absolutePath
args defaultArgs + ["platform=android", "target=template_release", "arch=arm64"]
}
tasks.create(name: "${taskPrefix}GodotOpenXRVendorsAndroidX86_64Debug", type: Exec) {
executable sconsExecutableFile.absolutePath
args defaultArgs + ["platform=android", "target=template_debug", "arch=x86_64"]
}
tasks.create(name: "${taskPrefix}GodotOpenXRVendorsAndroidX86_64Release", type: Exec) {
executable sconsExecutableFile.absolutePath
args defaultArgs + ["platform=android", "target=template_release", "arch=x86_64"]
}
// Desktop.
tasks.create(name: "${taskPrefix}GodotOpenXRVendorsDesktopDebug", type: Exec) {
executable sconsExecutableFile.absolutePath
args defaultArgs + ["target=template_debug"]
}
tasks.create(name: "${taskPrefix}GodotOpenXRVendorsDesktopRelease", type: Exec) {
executable sconsExecutableFile.absolutePath
args defaultArgs + ["target=template_release"]
}
}
/**
* Build the scons artifacts for the project
*/
task buildSconsArtifacts {
File sconsExecutableFile = getSconsExecutableFile()
// Using `doFirst` so the exception doesn't happen until this task actually runs.
doFirst {
if (sconsExecutableFile == null) {
throw new GradleException("Unable to find executable path for the 'scons' command.")
} else {
logger.debug("Found executable path for scons: ${sconsExecutableFile.absolutePath}")
}
}
if (sconsExecutableFile != null) {
createSconsTasks(sconsExecutableFile, false)
// Android.
dependsOn 'buildGodotOpenXRVendorsAndroidArm64Debug'
dependsOn 'buildGodotOpenXRVendorsAndroidArm64Release'
dependsOn 'buildGodotOpenXRVendorsAndroidX86_64Debug'
dependsOn 'buildGodotOpenXRVendorsAndroidX86_64Release'
// Desktop.
dependsOn 'buildGodotOpenXRVendorsDesktopDebug'
dependsOn 'buildGodotOpenXRVendorsDesktopRelease'
}
}
/**
* Scons clean for the project
*/
task cleanScons {
File sconsExecutableFile = getSconsExecutableFile()
// Using `doFirst` so the exception doesn't happen until this task actually runs.
doFirst {
if (sconsExecutableFile == null) {
throw new GradleException("Unable to find executable path for the 'scons' command.")
} else {
logger.debug("Found executable path for scons: ${sconsExecutableFile.absolutePath}")
}
}
if (sconsExecutableFile != null) {
createSconsTasks(sconsExecutableFile, true)
// Android.
dependsOn 'cleanGodotOpenXRVendorsAndroidArm64Debug'
dependsOn 'cleanGodotOpenXRVendorsAndroidArm64Release'
dependsOn 'cleanGodotOpenXRVendorsAndroidX86_64Debug'
dependsOn 'cleanGodotOpenXRVendorsAndroidX86_64Release'
// Desktop.
dependsOn 'cleanGodotOpenXRVendorsDesktopDebug'
dependsOn 'cleanGodotOpenXRVendorsDesktopRelease'
}
}
task copyBuildToSamples {
def sourceDir = file 'demo/addons/godotopenxrvendors'
def samplesDir = file 'samples'
doLast{
samplesDir.eachDir { targetSubdir ->
if (targetSubdir.name != 'builds') {
copy {
from sourceDir
into "${targetSubdir}/addons/godotopenxrvendors"
}
}
}
}
}
task cleanBuildFromSamples {
def samplesDir = file 'samples'
doLast{
samplesDir.eachDir { targetSubdir ->
if (targetSubdir.name != 'builds') {
delete {
delete "${targetSubdir}/addons/godotopenxrvendors"
}
}
}
}
}
task zipSamples {
def samplesDir = file 'samples'
def directoriesToZip = samplesDir.listFiles().findAll { it.isDirectory() && it.name != 'builds' }
def destinationDir = file 'zippedSamples'
destinationDir.mkdirs()
directoriesToZip.each { dir ->
def godotFolder = new File(dir, '.godot')
if (godotFolder.exists()) {
godotFolder.deleteDir()
}
def androidFolder = new File(dir, 'android')
if (androidFolder.exists()) {
androidFolder.deleteDir()
}
def zipTask = tasks.create(name: "zip${dir.name.capitalize()}", type: Zip) {
from(dir.parentFile) {
include "${dir.name}/**"
}
archiveFileName = "${dir.name}.zip"
destinationDirectory = destinationDir
}
dependsOn zipTask
}
}
task cleanZippedSamples {
delete 'zippedSamples'
}