apply plugin: "cpp" apply plugin: "com.google.protobuf" apply plugin: "checkstyle" apply plugin: "java" apply plugin: "maven" apply plugin: "idea" apply plugin: "signing" apply plugin: "jacoco" apply plugin: "com.google.osdetector" apply plugin: "ru.vyarus.animalsniffer" description = 'The protoc plugin for tars Java' buildscript { repositories { mavenCentral() mavenLocal() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0' classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0' classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.11' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.1' } } def artifactStagingPath = "$buildDir/artifacts" as File def addEnvArgs = { env, argList -> def value = System.getenv(env) if (value != null) { value.split(' +').each() { it -> argList.add(it) } } } def addLibraryIfNotLinked = { libName, argList -> def ldflags = System.env.LDFLAGS if (ldflags == null || !ldflags.contains('lib' + libName + '.a')) { argList.add('-l' + libName) } } def String arch = rootProject.hasProperty('targetArch') ? rootProject.targetArch : osdetector.arch def boolean vcDisable = rootProject.hasProperty('vcDisable') ? rootProject.vcDisable : false def protocVersion = '3.3.0' def protocPluginBaseName = 'protoc-gen-tars-java' model { toolChains { // If you have both VC and Gcc installed, VC will be selected, unless you // set 'vcDisable=true' if (!vcDisable) { visualCpp(VisualCpp) { } } gcc(Gcc) { target("ppcle_64") } clang(Clang) { } } platforms { x86_32 { architecture "x86" } x86_64 { architecture "x86_64" } ppcle_64 { architecture "ppcle_64" } } components { java_plugin(NativeExecutableSpec) { if (arch in ['x86_32', 'x86_64', 'ppcle_64']) { targetPlatform arch } baseName "$protocPluginBaseName" } } binaries { all { if (toolChain in Gcc || toolChain in Clang) { cppCompiler.args "--std=c++0x" addEnvArgs("CXXFLAGS", cppCompiler.args) addEnvArgs("CPPFLAGS", cppCompiler.args) if (osdetector.os == "osx") { cppCompiler.args "-mmacosx-version-min=10.7", "-stdlib=libc++" addLibraryIfNotLinked('protoc', linker.args) addLibraryIfNotLinked('protobuf', linker.args) } else if (osdetector.os == "windows") { linker.args "-static", "-lprotoc", "-lprotobuf", "-static-libgcc", "-static-libstdc++", "-s" } else { linker.args "-Wl,-Bstatic", "-lprotoc", "-lprotobuf", "-static-libgcc", "-static-libstdc++", "-Wl,-Bdynamic", "-lpthread", "-s" } addEnvArgs("LDFLAGS", linker.args) } else if (toolChain in VisualCpp) { cppCompiler.args "/EHsc", "/MT" if (rootProject.hasProperty('vcProtobufInclude')) { cppCompiler.args "/I${rootProject.vcProtobufInclude}" } linker.args "libprotobuf.lib", "libprotoc.lib" if (rootProject.hasProperty('vcProtobufLibs')) { linker.args "/LIBPATH:${rootProject.vcProtobufLibs}" } } } } }