diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..9f3f1ff --- /dev/null +++ b/build.gradle @@ -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 getCppCompilerArgs() { ['-m64', '-fpermissive'] } + List getCCompilerArgs() { ['-m64'] } + List getObjectiveCCompilerArgs() { ['-m64'] } + List getObjectiveCppCompilerArgs() { ['-m64'] } + List getAssemblerArgs() { ['--64'] } + List getLinkerArgs() { ['-m64'] } + List 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}" +} \ No newline at end of file