Permalink
Browse files

Added support for building MiniClient jar in Linux/Window/Mac

  • Loading branch information...
1 parent 9f3b20b commit 15a6712f8fb7471572b0f0180278a71fde020e25 @stuckless stuckless committed Aug 16, 2015
Showing with 216 additions and 15 deletions.
  1. +1 −0 .gitignore
  2. +19 −5 BUILDING.md
  3. +196 −10 build.gradle
View
@@ -31,3 +31,4 @@ config*.log
/.gradle/
/.settings/
+/buildoutput/
View
@@ -1,6 +1,6 @@
# Gradle Builds #
-The gradle.build build file can be used to recreate the Sage.jar on Windows, Linux or Mac.
+The gradle.build build file can be used to recreate the Sage.jar and/or the MiniClient.jar on Windows, Linux or Mac.
After cloning the repository, you can re-create the Sage.jar by running the **sageJar** task
@@ -18,6 +18,21 @@ gradlew.bat sageJar
Keep in mind the first time you run **gradlew** it will take some time has it has to download some dependencies.
+To rebuild the MiniClient.jar
+
+Linux Users
+
+```
+./gradlew miniclientJar
+```
+
+Windows Users
+
+```
+gradlew.bat miniclientJar
+```
+
+
## Settings up Eclipse ##
After cloning the repository, you can create the Eclipse Project Files by running the commands **cleanEclipse eclipse**
@@ -26,12 +41,11 @@ After cloning the repository, you can create the Eclipse Project Files by runnin
./gradlew cleanEclipse eclipse
```
-You can open the project in eclipse and it will be fully configured as a Java Project.
+You can open the project in eclipse and it will be fully configured as a Java Project. To open the project, you would create an eclipse workspace, and then use the **File -> Import -> Existing Projects** and navigate to the git source directory and it should see a **SageTV** project.
You cannot recreate the Sage.jar from within eclipse, but it will compile files, etc. When you need to rebuild the Sage.jar simple use the **sageJar** task.
### Gradle Plugin for Eclipse ###
You can find information on how to install the Gradle Plugin here
-http://www.vogella.com/tutorials/EclipseGradle/article.html
-
-YMMV since I find the Gradle Plugin to be of little value so far.
+https://github.com/spring-projects/eclipse-integration-gradle/
+https://github.com/groovy/groovy-eclipse/wiki
View
@@ -7,16 +7,37 @@ 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
@@ -28,6 +49,7 @@ compileJava {
}
sourceSets {
+ // main configuration for the Sage.jar
main {
java {
srcDirs = [
@@ -40,24 +62,53 @@ sourceSets {
'third_party/RSSLIB4J/java',
'third_party/SingularSys/java'
]
- // these don't compile?? (need to be on a mac, i think)
excludes = [
+ // mac files, need to be on a Mac to build these
'sage/QuartzSageRenderer.java',
- 'sage/miniclient/OpenGLGFXCMD.java',
- 'sage/miniclient/OpenGLVideoRenderer.java',
- 'sage/miniclient/QuartzGFXCMD.java',
- 'sage/JOGLSageRenderer.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/Windows/gluegen-rt.jar',
- 'third_party/JOGL/Windows/jogl.jar',
'third_party/JOGL/Linux/gluegen-rt.jar',
'third_party/JOGL/Linux/nativewindow.all.jar',
'third_party/JOGL/Linux/jogl.all.jar',
@@ -67,17 +118,48 @@ dependencies {
'third_party/JCIFS/jcifs-1.1.6.jar',
)
- // compile 'org.jogamp.jogl:jogl-all:2.3.1'
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
+ 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) {
@@ -99,16 +181,119 @@ task sageJar(type: Jar) {
}
doLast {
- println 'Sage jar created in ' + sageJarDestinationDir +'/'+sageJarName
+ 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
@@ -119,6 +304,7 @@ import org.gradle.internal.os.OperatingSystem;
task detect {
doLast {
+ println(OperatingSystem.current().isWindows())
println(OperatingSystem.current().isMacOsX())
println(OperatingSystem.current().isLinux())
}

0 comments on commit 15a6712

Please sign in to comment.