forked from google/sagetv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
312 lines (260 loc) · 8.17 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
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
// Sage Version -- Not used for now
version = '9.0'
// Globals
ext {
sageBuildDir = 'buildoutput'
stageBuildDir = 'build'
appName = 'SageTV'
sageJarName = 'Sage.jar'
sageJarDestinationDir = 'build/release/'
miniJarName = 'MiniClient.jar'
miniJarDestinationDir = 'build/minirelease/'
jogampVer = '2.0.2'
arch=Integer.parseInt(System.getProperty('sun.arch.data.model')); // 32 or 64
}
// set gradle's buildDir to something other than the default 'build', or
// we'll end up deleting EVERYTHING in 'build' when we ./gradlew clean
buildDir = new File(rootProject.projectDir, sageBuildDir);
repositories {
mavenCentral()
jcenter()
}
configurations {
miniclient.extendsFrom compile
miniclientRuntime
miniclientRuntimeLinux32
miniclientRuntimeLinux64
miniclientArch
}
// Maybe someday we'll target >1.5 (hopefully)
targetCompatibility = 1.5
sourceCompatibility = 1.5
compileJava {
options.warnings = false
//options.incremental = true
//options.debugOptions.debugLevel = "source,lines,vars"
}
sourceSets {
// main configuration for the Sage.jar
main {
java {
srcDirs = [
'java',
'third_party/Javolution/java',
'third_party/jcraft/java',
'third_party/jtux/java',
'third_party/MetadataExtractor/java',
'third_party/Ogle/java',
'third_party/RSSLIB4J/java',
'third_party/SingularSys/java'
]
excludes = [
// mac files, need to be on a Mac to build these
'sage/QuartzSageRenderer.java',
'sage/miniclient/QuartzGFXCMD.java',
// does not appear to compile, maybe an older file??
'sage/JOGLSageRenderer.java'
]
}
}
// Miniclient configuration only specifies the Minimal files and
// javac will find and compile all the dependencies based on the
// main configuration being the sourcepath reference
miniclient {
java {
srcDirs = [
'java',
]
includes = [
'sage/miniclient/MiniClient.java',
'sage/PowerManagement.java',
'sage/UIUtils.java',
'sage/miniclient/OpenGLGFXCMD.java'
]
}
}
}
/**
* this is sort of a hack... normally we'd never set the -sourcepath on a java compile
* but, sagetv usues this hack to selectively compile and include files into each jar
* so we'll mimic the behaviour here until we need to do something different
*/
tasks.withType(JavaCompile) {
//options.fork=true
options.compilerArgs << "-sourcepath" << sourceSets.main.java.srcDirs.join(":")
}
task miniclient(type:JavaCompile){
description = "Build miniclient classes"
println('MiniClient Build')
}
dependencies {
compile files(
'third_party/UPnPLib/sbbi-upnplib-1.0.3.jar',
'third_party/JOGL/Linux/gluegen-rt.jar',
'third_party/JOGL/Linux/nativewindow.all.jar',
'third_party/JOGL/Linux/jogl.all.jar',
'third_party/Oracle/vecmath.jar',
'third_party/Lucene/lucene-core-3.6.0.jar',
'third_party/JCIFS/jcifs-1.1.6.jar',
)
compile 'com.apple:AppleJavaExtensions:1.4'
// Miniclient dependendencies for compiling
miniclientCompile files(
'third_party/UPnPLib/sbbi-upnplib-1.0.3.jar',
'third_party/JOGL/Linux/gluegen-rt.jar',
'third_party/JOGL/Linux/nativewindow.all.jar',
'third_party/JOGL/Linux/jogl.all.jar',
'third_party/Oracle/vecmath.jar',
'third_party/Lucene/lucene-core-3.6.0.jar',
'third_party/JCIFS/jcifs-1.1.6.jar',
)
miniclientCompile 'com.apple:AppleJavaExtensions:1.4'
// setup the miniclient dependencies for 32/64 bit linux
// looks like miniclient is only linux
// eventually if we upgrade the JOGL this is how we can do it, dynamically
// miniclientRuntime "org.jogamp.jogl:jogl-all:$jogampVer"
// miniclientRuntime ("org.jogamp.gluegen:gluegen:$jogampVer") {
// transitive false
// }
// miniclientRuntime ("org.jogamp.gluegen:gluegen-rt-main:$jogampVer") {
// transitive false
// }
// miniclientRuntimeLinux32 "org.jogamp.jogl:jogl-all:$jogampVer:natives-linux-i586"
// miniclientRuntimeLinux32 "org.jogamp.gluegen:gluegen-rt:$jogampVer:natives-linux-i586"
// miniclientRuntimeLinux64 "org.jogamp.jogl:jogl-all:$jogampVer:natives-linux-amd64"
// miniclientRuntimeLinux64 "org.jogamp.gluegen:gluegen-rt:$jogampVer:natives-linux-amd64"
}
// remove the Sage.jar before updating it
task cleanSageJar(type: Delete) {
delete sageJarDestinationDir+'/'+sageJarName
}
// build the Sage.jar
task sageJar(type: Jar) {
description = 'Build the Sage.jar'
archiveName = sageJarName
destinationDir = file(sageJarDestinationDir)
from files(sourceSets.main.output.classesDir) {
// exclude the Mac stuff for now
excludes = [
'sage/miniclient/**',
'sage/MacAboutBox*',
'sage/MacApplicationListener.class',
'sage/QuartzRendererView.class'
]
}
from files(sourceSets.main.output.resourcesDir)
// Add in images and localization files
from 'images/SageTV/'
from ('i18n') {
include '*.properties'
}
doLast {
println "$sageJarName created in $sageJarDestinationDir"
}
}
// clean miniclient jar
task cleanMiniJar(type: Delete) {
delete miniJarDestinationDir+'/'+miniJarName
}
// build miniclient jar
task miniclientJar(type: Jar) {
archiveName = miniJarName
destinationDir = file(miniJarDestinationDir)
from files(sourceSets.miniclient.output.classesDir) {
}
// Add in images and localization files
from 'images/MiniClient/'
doLast {
println "$miniJarName created in $miniJarDestinationDir"
}
}
// LinuxOnly: calls a unix script and ensures that JDK_HOME is set
def linuxScript(String script) {
String jdk="$System.env.JDK_HOME"
if (jdk==null || jdk==""||jdk=='null') throw new GradleException('JDK_HOME must be set to the JDK installation directory');
File jdkInclude = new File(new File(jdk),"include");
if (!jdkInclude) throw new GradleException('JDK_HOME does not point to a valid JDK home: ' + jdk);
exec {
workingDir = 'build'
executable script
environment JDK_HOME: jdk
}
}
// currently Linux Only -- Need to look at supporting Windows
task (linuxMiniclientRelease) << {
if (!OperatingSystem.current().isLinux()) {
throw new GradleException('This target is not supported on Windows, yet.');
}
if (!(new File('build/so/libSage.so')).exists()) {
linuxScript('./buildso.sh');
}
if (!(new File('build/elf/mplayer')).exists()) {
linuxScript('./build3rdparty.sh');
}
delete 'build/clientrelease'
copy {
from('build/minirelease/MiniClient.jar') {
}
from ('build/clientfiles/')
from 'third_party/swscale/libswscale.so'
from ('build/so/libSageX11.so') {
rename 'libSageX11.so', 'libSage.so'
}
from ('build/so/libjtux.so')
from ('build/so/libImageLoader.so')
from ('build/elf/mplayer')
//from (configurations.miniclientRuntime)
if (arch==32) {
from ('third_party/JOGL/Linux/') {
include "*"
}
} else {
// no 64 bit JOGL support, yet
}
into('build/clientrelease')
}
}
// build RAW javadoc
task sageJavadoc(type: Javadoc) {
source = sourceSets.main.allJava
}
// task dependencies
sageJar.dependsOn classes, cleanSageJar
miniclientJar.dependsOn miniclientClasses, cleanMiniJar
linuxMiniclientRelease.dependsOn miniclientJar
eclipse {
project {
name = appName
}
classpath {
file {
// java appears twice in the classpath because it is configured for sage and miniclient,
// need to remove the miniclient one, or else it will cause eclipse to complain
whenMerged { classpath ->
def item=null;
classpath.entries.each {
if (it.path == 'java' && it.includes.size()>0) {
item=it
}
}
if (item!=null) {
classpath.entries.remove(item)
}
}
}
}
}
// This get run when you call ./gradlew without any targets
defaultTasks 'sageJar'
// not currently used, but I'm keeping it here because shows how to detect Linux/Windows/Mac
import org.gradle.internal.os.OperatingSystem;
task detect {
doLast {
println(OperatingSystem.current().isWindows())
println(OperatingSystem.current().isMacOsX())
println(OperatingSystem.current().isLinux())
}
}