Create build.gradle that produces static and shared libraries
This commit is contained in:
123
build.gradle
Normal file
123
build.gradle
Normal file
@@ -0,0 +1,123 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'c'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
group = 'com.github.boukefalos'
|
||||
project.archivesBaseName = 'libwiiuse'
|
||||
version = '0.13'
|
||||
|
||||
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
|
||||
nativeJar.into(project.group.replace('.', '/') + '/' + variantName) { from builderTask.outputFile }
|
||||
nativeJar.dependsOn builderTask
|
||||
def importLibPath = binary.sharedLibraryLinkFile.absolutePath.replace('.dll', '.lib')
|
||||
linker.args "-Wl,--out-implib,${importLibPath}"
|
||||
}
|
||||
Reference in New Issue
Block a user