* build shared and static libraries * produce library artifacts * produce general (empty) artifact that enforces dependencies * update naming of library in artifact
143 lines
4.0 KiB
Groovy
143 lines
4.0 KiB
Groovy
apply plugin: 'java'
|
|
apply plugin: 'c'
|
|
apply plugin: 'maven'
|
|
apply plugin: 'eclipse'
|
|
|
|
group = 'com.github.boukefalos'
|
|
project.archivesBaseName = 'libwiiuse'
|
|
version = '0.14'
|
|
|
|
task wrapper(type: Wrapper) {
|
|
gradleVersion = '1.12'
|
|
}
|
|
|
|
model {
|
|
platforms {
|
|
windows_i386 {
|
|
architecture 'i386'
|
|
operatingSystem 'windows'
|
|
}
|
|
windows_amd64 {
|
|
architecture 'amd64'
|
|
operatingSystem 'windows'
|
|
}
|
|
}
|
|
toolChains {
|
|
gcc(Gcc) {
|
|
addPlatformConfiguration(new TargetPlatformConfiguration() {
|
|
boolean supportsPlatform(Platform platform) {
|
|
platform.operatingSystem.current && platform.operatingSystem.name == 'windows' &&
|
|
platform.architecture.name == 'amd64'
|
|
}
|
|
List<String> getCppCompilerArgs() { ['-m64', '-fpermissive'] }
|
|
List<String> getCCompilerArgs() { ['-m64'] }
|
|
List<String> getObjectiveCCompilerArgs() { ['-m64'] }
|
|
List<String> getObjectiveCppCompilerArgs() { ['-m64'] }
|
|
List<String> getAssemblerArgs() { ['--64'] }
|
|
List<String> getLinkerArgs() { ['-m64'] }
|
|
List<String> getStaticLibraryArchiverArgs() { [] }
|
|
})
|
|
}
|
|
}
|
|
repositories {
|
|
libs(PrebuiltLibraries) {
|
|
hid { lib ->
|
|
binaries.withType(StaticLibraryBinary) {
|
|
staticLibraryFile = file("lib/${targetPlatform.name}/${lib.name}.lib")
|
|
}
|
|
}
|
|
SetupAPI { lib ->
|
|
binaries.withType(StaticLibraryBinary) {
|
|
staticLibraryFile = file("lib/${targetPlatform.name}/${lib.name}.lib")
|
|
}
|
|
}
|
|
WS2_32 { lib ->
|
|
binaries.withType(StaticLibraryBinary) {
|
|
staticLibraryFile = file("lib/${targetPlatform.name}/${lib.name}.lib")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
libraries {
|
|
main {
|
|
baseName project.archivesBaseName
|
|
}
|
|
all {
|
|
binaries.all {
|
|
cCompiler.define 'WIIUSE_COMPILE_LIB'
|
|
cCompiler.args '-I' + jniHeadersDir
|
|
cCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
|
|
cCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"
|
|
linker.args '-Wl,--kill-at', '-static-libgcc', '-static-libstdc++'
|
|
lib library: 'hid', linkage: 'static'
|
|
lib library: 'SetupAPI', linkage: 'static'
|
|
lib library: 'WS2_32', linkage: 'static'
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.withType(Upload) {
|
|
repositories {
|
|
mavenDeployer {
|
|
repository(url: uri('.maven'))
|
|
}
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
jni
|
|
}
|
|
|
|
def deployer = uploadJni.repositories.mavenDeployer
|
|
|
|
binaries.withType(SharedLibraryBinary) { binary ->
|
|
if (!buildable) {
|
|
return
|
|
}
|
|
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 = "${project.archivesBaseName}-$variantName"
|
|
}
|
|
artifacts {
|
|
jni 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 builderTask = binary.tasks.builder
|
|
def libraryDirectory = project.group.replace('.', '/') + "/${project.archivesBaseName}/${variantName}"
|
|
nativeJar.into(libraryDirectory) { from builderTask.outputFile }
|
|
nativeJar.dependsOn builderTask
|
|
def importLibPath = binary.sharedLibraryLinkFile.absolutePath.replace('.dll', '.lib')
|
|
linker.args "-Wl,--out-implib,${importLibPath}"
|
|
}
|
|
|
|
def mainPom = uploadArchives.repositories.mavenDeployer.pom
|
|
mainPom.groupId = project.group
|
|
mainPom.artifactId = jar.baseName
|
|
mainPom.version = project.version
|
|
mainPom.scopeMappings.mappings.clear()
|
|
mainPom.withXml { provider ->
|
|
def node = provider.asNode()
|
|
def deps = node.appendNode('dependencies')
|
|
['windows-amd64', 'windows-i386'].each { platform ->
|
|
def dep = deps.appendNode('dependency')
|
|
dep.appendNode('groupId', project.group)
|
|
dep.appendNode('artifactId', "${project.archivesBaseName}-${platform}")
|
|
dep.appendNode('version', project.version)
|
|
}
|
|
def dep = deps.appendNode('dependency')
|
|
dep.appendNode('groupId', 'com.github.boukefalos')
|
|
dep.appendNode('artifactId', 'jlibloader')
|
|
dep.appendNode('version', '0.2')
|
|
} |