forked from GodotVR/godot_openxr_vendors
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
186 lines (163 loc) · 6.33 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
// 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 ':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"
}
/**
* Build the scons artifacts for the project
*/
task buildSconsArtifacts {
// Find scons' executable path
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
}
}
if (sconsExecutableFile == null) {
throw new GradleException("Unable to find executable path for the '$sconsName' command.")
} else {
logger.debug("Found executable path for $sconsName: ${sconsExecutableFile.absolutePath}")
}
// Build the Godot-CPP bindings
tasks.create(name: "buildGodotCPPArm64Debug", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=thirdparty/godot-cpp", "platform=android", "target=template_debug", "arch=arm64", "custom_api_file=../godot_cpp_gdextension_api/extension_api.json"
}
tasks.create(name: "buildGodotCPPArm64Release", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=thirdparty/godot-cpp", "platform=android", "target=template_release", "arch=arm64", "custom_api_file=../godot_cpp_gdextension_api/extension_api.json"
}
tasks.create(name: "buildGodotCPPX86_64Debug", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=thirdparty/godot-cpp", "platform=android", "target=template_debug", "arch=x86_64", "custom_api_file=../godot_cpp_gdextension_api/extension_api.json"
}
tasks.create(name: "buildGodotCPPX86_64Release", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=thirdparty/godot-cpp", "platform=android", "target=template_release", "arch=x86_64", "custom_api_file=../godot_cpp_gdextension_api/extension_api.json"
}
dependsOn 'buildGodotCPPArm64Debug'
dependsOn 'buildGodotCPPArm64Release'
dependsOn 'buildGodotCPPX86_64Debug'
dependsOn 'buildGodotCPPX86_64Release'
// Creating gradle task to generate the editor gdextension binaries
tasks.create(name: "buildGodotOpenXRVendorsDebugGDExtension", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "target=template_debug", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json"
}
tasks.create(name: "buildGodotOpenXRVendorsReleaseGDExtension", type: Exec) {
executable sconsExecutableFile.absolutePath
args "--directory=.", "target=template_release", "custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json"
}
dependsOn 'buildGodotOpenXRVendorsDebugGDExtension'
dependsOn 'buildGodotOpenXRVendorsReleaseGDExtension'
}
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'
}