zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 1 | apply plugin: "cpp" |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 2 | apply plugin: "protobuf" |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 3 | |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 4 | import org.apache.tools.ant.taskdefs.condition.Os |
| 5 | |
zhangkun83 | 5e60785 | 2015-01-22 12:31:56 -0800 | [diff] [blame] | 6 | description = 'The protoc plugin for gRPC Java' |
| 7 | |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 8 | buildscript { |
| 9 | repositories { |
| 10 | mavenCentral() |
| 11 | } |
| 12 | dependencies { |
| 13 | classpath libraries.protobuf_plugin |
| 14 | } |
| 15 | } |
| 16 | |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 17 | executables { |
| 18 | java_plugin {} |
| 19 | } |
| 20 | |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 21 | dependencies { |
| 22 | compile project(':grpc-stub'), |
| 23 | libraries.protobuf |
| 24 | } |
| 25 | |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 26 | binaries.all { |
nmittler | f129960 | 2015-01-30 14:55:38 -0800 | [diff] [blame] | 27 | if (toolChain in Gcc || toolChain in Clang) { |
Eric Anderson | a0acb9b | 2015-03-20 10:26:00 -0700 | [diff] [blame^] | 28 | // Support Gcc 4.6 by using c++0x instead of c++11 |
Louis Ryan | c42c8c4 | 2015-03-18 16:31:38 -0700 | [diff] [blame] | 29 | cppCompiler.args "--std=c++0x" |
Eric Anderson | 2049e0d | 2015-01-29 12:41:51 -0800 | [diff] [blame] | 30 | if (System.env.CXXFLAGS) { |
| 31 | cppCompiler.args System.env.CXXFLAGS |
| 32 | } |
| 33 | if (System.env.CPPFLAGS) { |
| 34 | cppCompiler.args System.env.CPPFLAGS |
| 35 | } |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 36 | linker.args "-lprotoc", "-lprotobuf" |
Eric Anderson | 2049e0d | 2015-01-29 12:41:51 -0800 | [diff] [blame] | 37 | if (System.env.LDFLAGS) { |
| 38 | linker.args System.env.LDFLAGS |
| 39 | } |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 40 | } else if (toolChain in VisualCpp) { |
| 41 | cppCompiler.args "/EHsc", "/MD" |
| 42 | if (rootProject.hasProperty('protobuf.include')) { |
| 43 | cppCompiler.args "/I" + rootProject.properties['protobuf.include'] |
| 44 | } |
| 45 | linker.args "libprotobuf.lib", "libprotoc.lib" |
| 46 | if (rootProject.hasProperty('protobuf.libs')) { |
| 47 | linker.args "/LIBPATH:" + rootProject.properties['protobuf.libs'] |
| 48 | } |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 52 | protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"] |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 53 | |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 54 | generateTestProto.dependsOn 'java_pluginExecutable' |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 55 | // Ignore test for the moment on Windows. It will be easier to run once the |
| 56 | // gradle protobuf plugin can support nano. |
| 57 | if (!Os.isFamily(Os.FAMILY_WINDOWS)) { |
| 58 | test.dependsOn('testGolden','testNanoGolden') |
| 59 | } |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 60 | |
| 61 | task testGolden(type: Exec, dependsOn: 'generateTestProto') { |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 62 | if (!Os.isFamily(Os.FAMILY_WINDOWS)) { |
| 63 | executable "diff" |
| 64 | } else { |
| 65 | executable "fc" |
| 66 | } |
| 67 | // File isn't found on Windows if last slash is forward-slash |
| 68 | def slash = System.getProperty("file.separator") |
| 69 | args "$buildDir/generated-sources/test/io/grpc/testing/integration" + slash + "TestServiceGrpc.java", |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 70 | "$projectDir/src/test/golden/TestService.java.txt" |
zhangkun83 | 5e60785 | 2015-01-22 12:31:56 -0800 | [diff] [blame] | 71 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 72 | |
zsurocking | 5902c6a | 2015-02-25 20:54:53 -0800 | [diff] [blame] | 73 | task testNanoGolden(type: Exec, dependsOn: 'java_pluginExecutable') { |
Jakob Buchgraber | df321fe | 2015-02-25 19:47:05 -0800 | [diff] [blame] | 74 | doFirst { |
| 75 | temporaryDir.createNewFile(); |
| 76 | } |
| 77 | |
zsurocking | 5902c6a | 2015-02-25 20:54:53 -0800 | [diff] [blame] | 78 | environment 'TEST_TMP_DIR', temporaryDir |
| 79 | commandLine './src/test/run_nano_test.sh' |
| 80 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 81 | |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 82 | [ |
| 83 | install.repositories.mavenInstaller, |
| 84 | uploadArchives.repositories.mavenDeployer, |
| 85 | ]*.addFilter('none') { artifact, file -> false } |