Updated to use a Gradle 1.11 nightly

This commit is contained in:
Adam Murdoch
2013-12-06 18:42:13 +11:00
parent 09bbd0f3ed
commit dfc7fa2f53
6 changed files with 187 additions and 196 deletions

View File

@@ -64,143 +64,84 @@ task nativeHeaders {
}
}
cpp {
sourceSets {
main {
source.exclude 'curses.cpp'
model {
platforms {
create("osx_i386") {
architecture "i386"
operatingSystem "osx"
}
curses {
source.srcDirs = ['src/main/cpp']
source.include 'curses.cpp'
source.include 'generic.cpp'
source.include 'generic_posix.cpp'
create("osx_amd64") {
architecture "amd64"
operatingSystem "osx"
}
create("linux_i386") {
architecture "i386"
operatingSystem "linux"
}
create("linux_amd64") {
architecture "amd64"
operatingSystem "linux"
}
create("windows_i386") {
architecture "i386"
operatingSystem "windows"
}
create("windows_amd64") {
architecture "amd64"
operatingSystem "windows"
}
}
}
def variants = [:]
libraries {
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
all {
spec {
includes(files('/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/'))
args("-arch", "x86_64", "-arch", "i386")
}
}
universal {
sourceSets << cpp.sourceSets.main
spec {
baseName = 'native-platform-osx-universal'
args("-o", outputFile)
}
}
cursesUniversal {
sourceSets << cpp.sourceSets.curses
spec {
baseName = 'native-platform-curses-osx-universal'
args("-lcurses")
args("-o", outputFile)
}
}
variants['osx-universal'] = [universal, cursesUniversal]
} else if (org.gradle.internal.os.OperatingSystem.current().windows) {
all {
spec {
includes(files("${org.gradle.internal.jvm.Jvm.current().javaHome}/include"))
includes(files("${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"))
args("/DWIN32")
}
}
def out = new ByteArrayOutputStream()
exec {
commandLine "cl.exe", "/?"
errorOutput = out
standardOutput = new ByteArrayOutputStream()
}
def header = out.toString().readLines().head()
if (header.endsWith("for 80x86") || header.endsWith("for x86")) {
i386 {
sourceSets << cpp.sourceSets.main
spec {
baseName = 'native-platform-windows-i386'
}
}
variants['windows-i386'] = [i386]
} else if (header.endsWith("for x64")) {
amd64 {
sourceSets << cpp.sourceSets.main
spec {
baseName = 'native-platform-windows-amd64'
}
}
variants['windows-amd64'] = [amd64]
} else {
throw new RuntimeException("Cannot determine compiler's target architecture")
}
} else if (org.gradle.internal.os.OperatingSystem.current().linux) {
all {
spec {
includes(files("${org.gradle.internal.jvm.Jvm.current().javaHome}/include"))
includes(files("${org.gradle.internal.jvm.Jvm.current().javaHome}/include/linux"))
}
}
if (System.getProperty('os.arch') == 'i386' || project.hasProperty('multiarch')) {
i386 {
sourceSets << cpp.sourceSets.main
spec {
baseName = 'native-platform-linux-i386'
args("-m32")
}
}
cursesI386 {
sourceSets << cpp.sourceSets.curses
spec {
baseName = 'native-platform-curses-linux-i386'
args("-m32", "-lcurses")
}
}
variants['linux-i386'] = [i386, cursesI386]
}
if (System.getProperty('os.arch') == 'amd64' || project.hasProperty('multiarch')) {
amd64 {
sourceSets << cpp.sourceSets.main
spec {
baseName = 'native-platform-linux-amd64'
args("-m64")
}
}
cursesAmd64 {
sourceSets << cpp.sourceSets.curses
spec {
baseName = 'native-platform-curses-linux-amd64'
args("-m64", "-lcurses")
}
}
variants['linux-amd64'] = [amd64, cursesAmd64]
}
} else {
baseName = "native-platform-solaris"
main {
sourceSets << cpp.sourceSets.main
sourceSets << cpp.sourceSets.curses
spec {
includes(files("${org.gradle.internal.jvm.Jvm.current().javaHome}/include"))
includes(files("${org.gradle.internal.jvm.Jvm.current().javaHome}/include/solaris"))
args("-DSOLARIS", "-lcurses")
}
}
variants['solaris'] = [main]
nativePlatform {
baseName 'native-platform'
}
all {
spec {
includes(files(nativeHeadersDir, 'src/main/headers'))
nativePlatformCurses {
baseName 'native-platform-curses'
targetPlatforms "osx_i386", "osx_amd64", "linux_i386", "linux_amd64"
binaries.all {
linker.args "-lcurses"
}
}
all {
binaries.all {
if (targetPlatform.operatingSystem.name == "osx") {
cppCompiler.args '-I', "${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
cppCompiler.args '-I', "${org.gradle.internal.jvm.Jvm.current().javaHome}/include/darwin"
} else if (targetPlatform.operatingSystem.name == "linux") {
cppCompiler.args '-I', "${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
cppCompiler.args '-I', "${org.gradle.internal.jvm.Jvm.current().javaHome}/include/linux"
} else if (targetPlatform.operatingSystem.name == "windows") {
cppCompiler.args '-I', "${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
cppCompiler.args '-I', "${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"
cppCompiler.define("WIN32")
}
cppCompiler.args '-I', nativeHeadersDir.absolutePath
tasks.withType(CppCompile) { task ->
task.dependsOn nativeHeaders
}
}
}
}
sources {
nativePlatform {
cpp {
source.srcDirs = ['src/main/cpp']
exportedHeaders.srcDirs = ['src/main/headers']
source.exclude 'curses.cpp'
}
}
nativePlatformCurses {
cpp {
source.srcDirs = ['src/main/cpp']
exportedHeaders.srcDirs = ['src/main/headers']
source.include 'curses.cpp'
source.include 'generic.cpp'
source.include 'generic_posix.cpp'
}
def task = tasks["compile${spec.binary.name.capitalize()}"]
task.dependsOn nativeHeaders
test.dependsOn spec
}
}
@@ -210,23 +151,34 @@ configurations {
def deployer = uploadJni.repositories.mavenDeployer
variants.each { variant, libs ->
def variantName = GUtil.toCamelCase(variant)
def nativeJar = task("nativeJar${variantName}", type: Jar) {
from libs.collect { tasks["compile${it.name.capitalize()}"] }
baseName = "native-platform-$variant"
binaries.withType(SharedLibraryBinary) { binary ->
if (!buildable) {
return
}
artifacts {
jni nativeJar
runtime nativeJar
def variantName = "${targetPlatform.operatingSystem.name}-${targetPlatform.architecture.name}"
def taskName = "jar-${variantName}"
def nativeJar = project.tasks.findByName(taskName)
if (nativeJar == null) {
nativeJar = project.task(taskName, type: Jar) {
baseName = "native-platform-$variantName"
}
artifacts {
jni nativeJar
runtime nativeJar
}
def jniPom = deployer.addFilter(variantName) { artifact, file ->
return file == nativeJar.archivePath
}
jniPom.groupId = project.group
jniPom.artifactId = nativeJar.baseName
jniPom.version = project.version
jniPom.scopeMappings.mappings.clear()
}
def jniPom = deployer.addFilter(variant) { artifact, file ->
return file == nativeJar.archivePath
}
jniPom.groupId = project.group
jniPom.artifactId = nativeJar.baseName
jniPom.version = project.version
jniPom.scopeMappings.mappings.clear()
def builderTask = binary.tasks.builder
nativeJar.into("net/rubygrapefruit/platform/$variantName") { from builderTask.outputFile }
nativeJar.dependsOn builderTask
}
javadoc {
@@ -258,14 +210,10 @@ mainPom.scopeMappings.mappings.clear()
mainPom.withXml { provider ->
def node = provider.asNode()
def deps = node.appendNode('dependencies')
['osx-universal', 'linux-amd64', 'linux-i386', 'windows-amd64', 'windows-i386'].each { platform ->
['osx-i386', 'osx-amd64', 'linux-amd64', 'linux-i386', 'windows-amd64', 'windows-i386'].each { platform ->
def dep = deps.appendNode('dependency')
dep.appendNode('groupId', project.group)
dep.appendNode('artifactId', "native-platform-${platform}")
dep.appendNode('version', project.version)
}
}
task wrapper(type: Wrapper) {
gradleVersion = "1.3-20120907220018+0000"
}