forked from LWJGL/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
424 lines (391 loc) · 14.1 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
apply plugin: "maven"
apply plugin: "signing"
project.defaultTasks = ["uploadArchives"]
project.buildDir = 'bin/MAVEN'
project.group = "org.lwjgl"
project.version = lwjglVersion
// Set build variables based on build type (release, continuous integration, development)
enum BuildType {
LOCAL,
SNAPSHOT,
RELEASE
}
class Deployment {
BuildType type
String repo
String user
String password
}
Deployment deployment
if ( hasProperty("release") ) {
deployment = new Deployment(
type: BuildType.RELEASE,
repo: "https://oss.sonatype.org/service/local/staging/deploy/maven2/",
user: sonatypeUsername,
password: sonatypePassword
)
} else if ( hasProperty("snapshot") ) {
project.version += "-SNAPSHOT"
deployment = new Deployment(
type: BuildType.SNAPSHOT,
repo: "https://oss.sonatype.org/content/repositories/snapshots/",
user: sonatypeUsername,
password: sonatypePassword
)
} else {
deployment = new Deployment(
type: BuildType.LOCAL,
repo: repositories.mavenLocal().url
)
}
println "${deployment.type.name()} BUILD"
enum Platforms {
LINUX("linux"),
MACOS("macos"),
WINDOWS("windows")
static final Platforms[] JAVA_ONLY = []
static final Platforms[] ALL = values()
final String name
Platforms(String name) {
this.name = name
}
}
enum Artifacts {
CORE("lwjgl", "LWJGL", "The LWJGL core library.", Platforms.ALL),
ASSIMP(
"lwjgl-assimp", "LWJGL - Assimp bindings",
"A portable Open Source library to import various well-known 3D model formats in a uniform manner.",
Platforms.ALL
),
BGFX(
"lwjgl-bgfx", "LWJGL - bgfx bindings",
"A cross-platform, graphics API agnostic rendering library. It provides a high performance, low level abstraction for common platform graphics APIs like OpenGL, Direct3D and Apple Metal.",
Platforms.ALL
),
EGL(
"lwjgl-egl", "LWJGL - EGL bindings",
"An interface between Khronos rendering APIs such as OpenGL ES or OpenVG and the underlying native platform window system.",
Platforms.JAVA_ONLY
),
GLFW(
"lwjgl-glfw", "LWJGL - GLFW bindings",
"An multi-platform library for OpenGL, OpenGL ES and Vulkan development on the desktop. It provides a simple API for creating windows, contexts and surfaces, receiving input and events.",
Platforms.ALL
),
JAWT(
"lwjgl-jawt", "LWJGL - JAWT bindings",
"The AWT native interface.",
Platforms.JAVA_ONLY
),
JEMALLOC(
"lwjgl-jemalloc", "LWJGL - jemalloc bindings",
"A general purpose malloc implementation that emphasizes fragmentation avoidance and scalable concurrency support.",
Platforms.ALL
),
LMDB(
"lwjgl-lmdb", "LWJGL - LMDB bindings",
"A compact, fast, powerful, and robust database that implements a simplified variant of the BerkeleyDB (BDB) API.",
Platforms.ALL
),
LZ4(
"lwjgl-lz4", "LWJGL - LZ4 bindings",
"A lossless data compression algorithm that is focused on compression and decompression speed.",
Platforms.ALL
),
NANOVG(
"lwjgl-nanovg", "LWJGL - NanoVG & NanoSVG bindings",
"A small antialiased vector graphics rendering library for OpenGL. Also includes NanoSVG, a simple SVG parser.",
Platforms.ALL
),
NFD(
"lwjgl-nfd", "LWJGL - Native File Dialog bindings",
"A tiny, neat C library that portably invokes native file open and save dialogs.",
Platforms.ALL
),
NUKLEAR(
"lwjgl-nuklear", "LWJGL - Nuklear bindings",
"A minimal state immediate mode graphical user interface toolkit.",
Platforms.ALL
),
ODBC(
"lwjgl-odbc", "LWJGL - ODBC bindings",
"A C programming language interface that makes it possible for applications to access data from a variety of database management systems (DBMSs).",
Platforms.JAVA_ONLY
),
OPENAL(
"lwjgl-openal", "LWJGL - OpenAL bindings",
"A cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications.",
Platforms.ALL
),
OPENCL(
"lwjgl-opencl", "LWJGL - OpenCL bindings",
"An open, royalty-free standard for cross-platform, parallel programming of diverse processors found in personal computers, servers, mobile devices and embedded platforms.",
Platforms.JAVA_ONLY
),
OPENGL(
"lwjgl-opengl", "LWJGL - OpenGL bindings",
"The most widely adopted 2D and 3D graphics API in the industry, bringing thousands of applications to a wide variety of computer platforms.",
Platforms.ALL
),
OPENGLES(
"lwjgl-opengles", "LWJGL - OpenGL ES bindings",
"A royalty-free, cross-platform API for full-function 2D and 3D graphics on embedded systems - including consoles, phones, appliances and vehicles.",
Platforms.ALL
),
OPENVR(
"lwjgl-openvr", "LWJGL - OpenVR bindings",
"OpenVR is an API and runtime that allows access to VR hardware from multiple vendors without requiring that applications have specific knowledge of the hardware they are targeting.",
Platforms.ALL
),
OVR(
"lwjgl-ovr", "LWJGL - OVR bindings",
"The API of the Oculus SDK.",
Platforms.WINDOWS
),
PAR(
"lwjgl-par", "LWJGL - par_shapes bindings",
"Generate parametric surfaces and other simple shapes.",
Platforms.ALL
),
REMOTERY(
"lwjgl-remotery", "LWJGL - Remotery bindings",
"A realtime CPU/GPU profiler hosted in a single C file with a viewer that runs in a web browser.",
Platforms.ALL
),
RPMALLOC(
"lwjgl-rpmalloc", "LWJGL - rpmalloc bindings",
"A public domain cross platform lock free thread caching 16-byte aligned memory allocator implemented in C.",
Platforms.ALL
),
SSE(
"lwjgl-sse", "LWJGL - SSE bindings",
"Simple SSE intrinsics.",
Platforms.ALL
),
STB(
"lwjgl-stb", "LWJGL - stb bindings",
"Single-file public domain libraries for fonts, images, ogg vorbis files and more.",
Platforms.ALL
),
TINYEXR(
"lwjgl-tinyexr", "LWJGL - Tiny OpenEXR bindings",
"A small library to load and save OpenEXR(.exr) images.",
Platforms.ALL
),
TINYFD(
"lwjgl-tinyfd", "LWJGL - Tiny File Dialogs bindings",
"Provides basic modal dialogs.",
Platforms.ALL
),
TOOTLE(
"lwjgl-tootle", "LWJGL - AMD Tootle bindings",
"A 3D triangle mesh optimization library that improves on existing mesh preprocessing techniques.",
Platforms.ALL
),
VMA(
"lwjgl-vma", "LWJGL - Vulkan Memory Allocator bindings",
"An easy to integrate Vulkan memory allocation library.",
Platforms.ALL
),
VULKAN(
"lwjgl-vulkan", "LWJGL - Vulkan bindings",
"A new generation graphics and compute API that provides high-efficiency, cross-platform access to modern GPUs used in a wide variety of devices from PCs and consoles to mobile phones and embedded platforms.",
Platforms.MACOS
),
XXHASH(
"lwjgl-xxhash", "LWJGL - xxHash bindings",
"An Extremely fast Hash algorithm, running at RAM speed limits.",
Platforms.ALL
),
YOGA(
"lwjgl-yoga", "LWJGL - Yoga bindings",
"An open-source, cross-platform layout library that implements Flexbox.",
Platforms.ALL
),
ZSTD(
"lwjgl-zstd", "LWJGL - Zstandard bindings",
"Zstandard (zstd) is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios.",
Platforms.ALL
)
String artifact
String projectName
String projectDescription
Platforms[] platforms
private Artifacts(
String artifact,
String projectName, String projectDescription,
Platforms... platforms
) {
this.artifact = artifact
this.projectName = projectName
this.projectDescription = projectDescription
this.platforms = platforms
}
private String directory(String buildDir) {
return "$buildDir/$artifact"
}
private String path() {
return "${directory("bin/MAVEN")}/$artifact"
}
boolean active() {
return new File(directory("bin/RELEASE")).exists()
}
Map<String, Object> artifactNotation(String classifier = null) {
if ( classifier == null )
return [file: new File("${path()}.jar"), name: artifact, type: "jar"]
else
return [file: new File("${path()}-${classifier}.jar"), name: artifact, type: "jar", classifier: classifier]
}
}
artifacts {
/*
Ideally, we'd have the following structure:
-------------------------------------------
lwjgl
lwjgl-windows (depends on lwjgl)
glfw (depends on lwjgl)
glfw-windows (depends on glfw & lwjgl-windows)
stb (depends on lwjgl)
stb-windows (depends on stb & lwjgl-windows)
-------------------------------------------
If a user wanted to use GLFW + stb in their project, running on
the Windows platform, they'd only have to define glfw-windows
and stb-windows as dependencies. This would automatically
resolve stb, glfw, lwjgl and lwjgl-windows as transitive
dependencies. Unfortunately, it is not possible to define such
a relationship between Maven artifacts when using classifiers.
A method to make this work is make the natives-<arch> classified
JARs separate artifacts. We do not do it for aesthetic reasons.
Instead, we assume that a tool is available (on the LWJGL website)
that automatically generates POM/Gradle dependency structures for
projects wanting to use LWJGL. The output is going to be verbose;
the above example is going to look like this in Gradle:
-------------------------------------------
compile 'org.lwjgl:lwjgl:$lwjglVersion' // NOTE: this is optional, all binding artifacts have a dependency on lwjgl
runtime 'org.lwjgl:lwjgl:$lwjglVersion:natives-$lwjglArch'
compile 'org.lwjgl:lwjgl-glfw:$lwjglVersion'
runtime 'org.lwjgl:lwjgl-glfw:$lwjglVersion:natives-$lwjglArch'
compile 'org.lwjgl:lwjgl-stb:$lwjglVersion'
runtime 'org.lwjgl:lwjgl-stb:$lwjglVersion:natives-$lwjglArch'
-------------------------------------------
and a whole lot more verbose in Maven. Hopefully, the automation
is going to alleviate the pain.
*/
Artifacts.values().each { module ->
if ( module.active() ) {
archives module.artifactNotation()
archives module.artifactNotation("sources")
archives module.artifactNotation("javadoc")
module.platforms.each {
archives module.artifactNotation("natives-${it.name}")
}
}
}
}
signing {
required = deployment.type == BuildType.RELEASE
sign configurations.archives
}
signArchives.dependsOn "copyArchives"
uploadArchives.dependsOn signArchives
// TODO: Find a way to merge the POM generation closures
def lwjglPOM = { String projectName, String projectDescription ->
return {
project {
name projectName
description projectDescription
packaging "jar"
url 'https://www.lwjgl.org'
scm {
connection 'scm:git:https://github.com/LWJGL/lwjgl3.git'
developerConnection 'scm:git:https://github.com/LWJGL/lwjgl3.git'
url 'https://github.com/LWJGL/lwjgl3.git'
}
licenses {
license {
name 'BSD'
url 'https://www.lwjgl.org/license'
distribution 'repo'
}
}
developers {
developer {
id "spasi"
name "Ioannis Tsakpinis"
email "[email protected]"
url "https://github.com/Spasi"
}
}
}
}
}
def bindingPOM = { String projectName, String projectDescription ->
return {
project {
name projectName
description projectDescription
packaging "jar"
url 'https://www.lwjgl.org'
scm {
connection 'scm:git:https://github.com/LWJGL/lwjgl3.git'
developerConnection 'scm:git:https://github.com/LWJGL/lwjgl3.git'
url 'https://github.com/LWJGL/lwjgl3.git'
}
licenses {
license {
name 'BSD'
url 'https://www.lwjgl.org/license'
distribution 'repo'
}
}
developers {
developer {
id "spasi"
name "Ioannis Tsakpinis"
email "[email protected]"
url "https://github.com/Spasi"
}
}
dependencies {
dependency {
groupId 'org.lwjgl'
artifactId 'lwjgl'
version project.version
scope 'compile'
}
}
}
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: deployment.repo) {
authentication(userName: deployment.user, password: deployment.password)
}
beforeDeployment {
signing.signPom(it)
}
Artifacts.values().each {
addFilter(it.artifact) {
artifact, file -> artifact.name == it.artifact
}
pom(
it.artifact,
it == Artifacts.CORE
? lwjglPOM(it.projectName, it.projectDescription)
: bindingPOM(it.projectName, it.projectDescription)
)
}
}
}
}
task copyArchives(type: Copy) {
from "bin/RELEASE"
include "**"
destinationDir buildDir
}