-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
341 lines (302 loc) · 14.2 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
import glm.installer.pkgzip.PkgZipInstallerPackage
import static PrebuiltLibraryUtils.*
plugins {
// https://github.com/dorongold/gradle-task-tree
id "com.dorongold.task-tree" version "1.5"
id 'usage'
id 'glm.installation-manifest-base'
id 'glm.prebuilt-library-management-base'
id 'glm.prebuilt-repositories'
}
ext {
// Code signing info
codeSignCert = file("MySPC.pfx")
codeSignPassword = "passwordx"
isWindows = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
.currentOperatingSystem.isWindows()
// TODO:CLEANUP
//codeSignCert = "${rootDir}/MySPC.pfx"
//codeSignPassword = "passwordx"
//
// TopProjDir = "${projectDir}/"
//
// // Names for our task groups
// debugGroup = "Legacy Native Migration Example Debug"
// releaseGroup = "Legacy Native Migration Example Release"
// releaseString = "1.1.00"
// versionTextInputFilename = 'VERSION.txt.in'
// versionTextInputPath = "${rootDir}/${versionTextInputFilename}"
}
// These tasks collect all the various installers into a known location.
def collectDebugInstallers = tasks.register('collectDebugInstallers', Sync).configure {
destinationDir = file(rootProject.projectDir.path + '/installers/debug')
doLast {
println "Debug installers collected to ${destinationDir}."
}
}
def collectReleaseInstallers = tasks.register('collectReleaseInstallers', Sync).configure {
destinationDir = file(rootProject.projectDir.path + '/installers/release')
doLast {
println "Release installers collected to ${destinationDir}."
}
}
// TODO:GLM
// TODO:Confluence
// Create an 'all' task that builds everything, debug and release, including building and collecting the installers.
def allTask = tasks.register('all').configure{ allT ->
subprojects.each { sp ->
def tsk
tsk = sp.tasks.findByName('debug')
if(tsk) { allT.dependsOn(tsk) }
tsk = sp.tasks.findByName('debugInstaller')
if(tsk) {
allT.dependsOn(tsk)
rootProject.collectDebugInstallers.from(sp.installers.debug.packages*.installerFile)
}
tsk = sp.tasks.findByName('release')
if(tsk) { allT.dependsOn(tsk) }
tsk = sp.tasks.findByName('releaseInstaller')
if(tsk) {
allT.dependsOn(tsk)
rootProject.collectReleaseInstallers.from(sp.installers.release.packages*.installerFile)
}
}
dependsOn(rootProject.collectDebugInstallers)
dependsOn(rootProject.collectReleaseInstallers)
}
// Create allDebug and allRelease tasks that do everything for that variant.
def allDebugTask = tasks.register('allDebug').configure{
subprojects.each { sp ->
def tsk
tsk = sp.tasks.findByName('debug')
if(tsk) { it.dependsOn(tsk) }
tsk = sp.tasks.findByName('debugInstaller')
if(tsk) {
it.dependsOn(tsk)
rootProject.collectDebugInstallers.from(sp.installers.debug.packages*.installerFile)
}
}
dependsOn(rootProject.collectDebugInstallers)
}
def allReleaseTask = tasks.register('allRelease').configure{
subprojects.each { sp ->
def tsk
tsk = sp.tasks.findByName('release')
if(tsk) { it.dependsOn(tsk) }
tsk = sp.tasks.findByName('releaseInstaller')
if(tsk) {
it.dependsOn(tsk)
rootProject.collectReleaseInstallers.from(sp.installers.release.packages*.installerFile)
}
}
dependsOn(rootProject.collectReleaseInstallers)
}
allprojects {
apply plugin: 'glm.debug-lifecycle'
apply plugin: 'glm.release-lifecycle'
apply plugin: 'default-import'
apply plugin: 'dev.nokee.visual-studio-ide'
apply plugin: 'glm.isolated-file-tree'
// Make sure that we know where to find unzipsfx.exe
project.pluginManager.withPlugin('glm.installer-base') {
installers.all {
packages.withType(PkgZipInstallerPackage).all {
// TODO: This doesn't seem to work properly, I get this error message:
// * What went wrong:
// Could not determine the dependencies of task ':zsfx_inst:zsfx_one:createPkgZipDebugInstaller'.
// > Failed to query the value of task ':zsfx_inst:zsfx_one:createPkgZipDebugInstaller' property 'ZSFX'.
// > Failed to query the value of property 'ZSFX'.
// > Cannot obtain value from provider of environment variable 'UNZIPSFX_LOCATION' at configuration time.
// Use a provider returned by 'forUseAtConfigurationTime()' instead.
// ZSFX = providers.environmentVariable('UNZIPSFX_LOCATION').map { new File(it) }
// .orElse(provider {
// throw new GradleException(
// "Please download unzipsfx from <https://sourceforge.net/projects/infozip/files/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.zip/download>, unzip it, and set the environment variable 'UNZIPSFX_LOCATION'"
// ) } )
// I changed the line to the one below, but then it always throws the exception saying that the env var needs to be set.
// ZSFX = providers.environmentVariable('UNZIPSFX_LOCATION').forUseAtConfigurationTime().map { new File(it) }
ZSFX.fileProvider providers.environmentVariable('UNZIPSFX_LOCATION').forUseAtConfigurationTime().map { new File(it) }.orElse(provider {
throw new GradleException(
"Please download unzipsfx with the command 'curl -o unzip.zip <https://managedway.dl.sourceforge.net/project/infozip/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.zip>', unzip it into a directory, and set the environment variable 'UNZIPSFX_LOCATION' to that location."
)
})
}
}
}
// KHickel 02-10-2021 Change the build directory for each project to be underneath
// rootProject.directory/build.
// "ofs" means "Out oF Source" (e.g. not in the source tree).
// The prj.name is the subproject name, which makes it easier to find something like
// an outputs.txt/options.txt for a subproject when you want to.
// And the md5 sum is added to make sure that the directories are unique to a subproject.
// This avoids a problem when Gradle decides to include all the source directories in the include path.
// If the build directory is below the source directory, then you start to get spurious rebuilds of
// projects, this change avoids that.
layout.buildDirectory.set(rootProject.file("build/ofs" + it.path.replaceAll(/:/, '-') + "-" + it.path.md5()))
}
if(isWindows) {
project(':zsfx_inst') {
subprojects {
ext.versionTextInputFilename = 'VERSION.txt.in'
ext.releaseString = '1.1.00'
}
}
} else {
println "NOTE: Not building the zsfx_inst projects, they are not yet ported to Linux"
}
installationManifests {
base {
from('LICENSE')
from('README.md')
from('VERSION.txt.in')
}
}
////////////////////////////////////////////////////////////////
// Utility function to take a string, add the .exe on the end for windows, and return the string.
def exe(String fname) {
if(isWindows) {
return fname + '.exe'
} else {
return fname
}
}
////////////////////////////////////////////////////////////////
// Utility function to take a string, add the .lib on the end for windows, .a for linux, and return the string.
def lib(String fname) {
if(isWindows) {
return fname + '.lib'
} else {
return fname + '.a'
}
}
////////////////////////////////////////////////////////////////
// Find the files needed to build with Open SSL, I couldn't figure out how to do
// this with just providers without running into the 'no matching signature' error.
def OpenSslRootPath = System.getenv('GLM_OPENSSL_ROOT')
if(!OpenSslRootPath) {
if(!isWindows) {
println "The environment variable GLM_OPENSSL_ROOT is not defined, attempting to use system files from /usr."
OpenSslRootPath = '/usr'
}
}
if(!OpenSslRootPath) {
throw new GradleException('The environment variable GLM_OPENSSL_ROOT is not define, please set it and try again.')
}
def libOpenSSLIncludePath = new File(OpenSslRootPath, 'include')
def libOpenSSLLibPathRelease = new File(OpenSslRootPath, 'lib')
def libOpenSSLLibPathDebug = new File(OpenSslRootPath, 'debug/lib')
def libOpenSSLLibNameDebug = lib('libssl')
def libOpenSSLLibNameRelease = lib('libssl')
def libCryptoLibNameDebug = lib('libcrypto')
def libCryptoLibNameRelease = lib('libcrypto')
if(!libOpenSSLLibPathDebug.exists()) {
// Use the non-debug version
libOpenSSLLibPathDebug = libOpenSSLLibPathRelease
}
def libOpenSSLLibCryptoReleaseFile = new File(libOpenSSLLibPathRelease, libCryptoLibNameRelease)
if(!isWindows) {
if(!libOpenSSLLibCryptoReleaseFile.exists()) {
// Try the linux x64 specific location
libOpenSSLLibCryptoReleaseFile = new File(new File(libOpenSSLLibPathRelease, '/x86_64-linux-gnu/'), libCryptoLibNameRelease)
}
}
if(!libOpenSSLLibCryptoReleaseFile.exists()) {
throw new GradleException("The environment variable GLM_OPENSSL_ROOT does not seem to specify a valid location, " +
"the file ${libOpenSSLLibCryptoReleaseFile} does not exist." )
}
def libOpenSSLLibCryptoDebugFile = new File(libOpenSSLLibPathDebug, libCryptoLibNameDebug)
if(!isWindows) {
if(!libOpenSSLLibCryptoDebugFile.exists()) {
// Try the linux x64 specific location
libOpenSSLLibCryptoDebugFile = new File(new File(libOpenSSLLibPathRelease, '/x86_64-linux-gnu/'), libCryptoLibNameDebug)
}
}
if(!libOpenSSLLibCryptoDebugFile.exists()) {
throw new GradleException("The environment variable GLM_OPENSSL_ROOT does not seem to specify a valid location, " +
"the file ${libOpenSSLLibCryptoDebugFile} does not exist." )
}
def libOpenSSLReleaseFile = new File(libOpenSSLLibPathRelease, libOpenSSLLibNameRelease)
if(!isWindows) {
if(!libOpenSSLReleaseFile.exists()) {
// Try the linux x64 specific location
libOpenSSLReleaseFile = new File(new File(libOpenSSLLibPathRelease, '/x86_64-linux-gnu/'), libOpenSSLLibNameRelease)
}
}
if(!libOpenSSLReleaseFile.exists()) {
throw new GradleException("The environment variable GLM_OPENSSL_ROOT does not seem to specify a valid location, " +
"the file ${libOpenSSLReleaseFile} does not exist." )
}
def libOpenSSLDebugFile = new File(libOpenSSLLibPathDebug, libOpenSSLLibNameDebug)
if(!isWindows) {
if(!libOpenSSLDebugFile.exists()) {
// Try the linux x64 specific location
libOpenSSLDebugFile = new File(new File(libOpenSSLLibPathRelease, '/x86_64-linux-gnu/'), libOpenSSLLibNameDebug)
}
}
if(!libOpenSSLDebugFile.exists()) {
throw new GradleException("The environment variable GLM_OPENSSL_ROOT does not seem to specify a valid location, " +
"the file ${libOpenSSLDebugFile} does not exist." )
}
prebuiltLibraryManagement {
libraries {
'libcrypto' {
groupId = 'system.Crypto'
artifactId = 'libcrypto'
version = 'current'
variants {
x86DebugStatic(StaticLibraryVariant) {
// includeRoot = openSslRootDir.dir('include').map(assertDirectoryExists())
// libraryFile = openSslRootDir.file('debug/lib/libcrypto.lib').map(assertFileExists())
includeRoot = libOpenSSLIncludePath;
libraryFile = libOpenSSLLibCryptoDebugFile;
attributes.put(Attribute.of('dev.nokee.linkage', String), 'static')
attributes.put(Attribute.of('dev.nokee.buildType', String), 'debug')
}
x86ReleaseStatic(StaticLibraryVariant) {
// includeRoot = openSslRootDir.dir('include').map(assertDirectoryExists())
// libraryFile = openSslRootDir.file('lib/libcrypto.lib').map(assertFileExists())
includeRoot = libOpenSSLIncludePath;
libraryFile = libOpenSSLLibCryptoReleaseFile;
attributes.put(Attribute.of('dev.nokee.linkage', String), 'static')
attributes.put(Attribute.of('dev.nokee.buildType', String), 'release')
}
}
}
'libssl' {
groupId = 'system.OpenSSL'
artifactId = 'libssl'
version = 'current'
variants {
x86DebugStatic(StaticLibraryVariant) {
// includeRoot = openSslRootDir.dir('include').map(assertDirectoryExists())
// libraryFile = openSslRootDir.file('debug/lib/libssl.lib').map(assertFileExists())
includeRoot = libOpenSSLIncludePath
libraryFile = libOpenSSLDebugFile
attributes.put(Attribute.of('dev.nokee.linkage', String), 'static')
attributes.put(Attribute.of('dev.nokee.buildType', String), 'debug')
}
x86ReleaseStatic(StaticLibraryVariant) {
// includeRoot = openSslRootDir.dir('include').map(assertDirectoryExists())
// libraryFile = openSslRootDir.file('lib/libssl.lib').map(assertFileExists())
includeRoot = libOpenSSLIncludePath
libraryFile = libOpenSSLReleaseFile
attributes.put(Attribute.of('dev.nokee.linkage', String), 'static')
attributes.put(Attribute.of('dev.nokee.buildType', String), 'release')
}
}
}
}
}
allprojects {
pluginManager.withPlugin('glm.code-signing') {
codeSigning.signtool.fileValue(org.gradle.internal.os.OperatingSystem.current().findInPath(exe('signtool')))
codeSigning.signingCertificate = rootProject.file('MySPC.pfx')
codeSigning.signingCertificatePassword = 'passwordx'
}
pluginManager.withPlugin('glm.publishing') {
publishing.repositories.flatDir name: 'installers', dirs: "$rootDir/build/installers"
repositories {
mavenCentral() // because commons-codec for hashing
}
}
}