Support building on Windows
Protoc should be in PATH and the project properties protobuf.include and
protobuf.libs should be set. For example:
gradlew build -Pprotobuf.include=C:\path\to\protobuf-3.0.0-alpha-2\src ^
-Pprotobuf.libs=C:\path\to\protobuf-3.0.0-alpha-2\vsprojects\Release
When running more than once, it is probably more convenient to create
%HOMEDRIVE%%HOMEPATH%\.gradle\gradle.properties with contents like:
protobuf.include=C:\\path\\to\\protobuf-3.0.0-alpha-2\\src
protobuf.libs=C:\\path\\to\\protobuf-3.0.0-alpha-2\\vsprojects\\Release
diff --git a/compiler/build.gradle b/compiler/build.gradle
index 91bb666..47bcad4 100644
--- a/compiler/build.gradle
+++ b/compiler/build.gradle
@@ -1,6 +1,8 @@
apply plugin: "cpp"
apply plugin: "protobuf"
+import org.apache.tools.ant.taskdefs.condition.Os
+
description = 'The protoc plugin for gRPC Java'
buildscript {
@@ -34,17 +36,36 @@
if (System.env.LDFLAGS) {
linker.args System.env.LDFLAGS
}
+ } else if (toolChain in VisualCpp) {
+ cppCompiler.args "/EHsc", "/MD"
+ if (rootProject.hasProperty('protobuf.include')) {
+ cppCompiler.args "/I" + rootProject.properties['protobuf.include']
+ }
+ linker.args "libprotobuf.lib", "libprotoc.lib"
+ if (rootProject.hasProperty('protobuf.libs')) {
+ linker.args "/LIBPATH:" + rootProject.properties['protobuf.libs']
+ }
}
}
-protobufCodeGenPlugins = ["java_plugin:$buildDir/binaries/java_pluginExecutable/java_plugin"]
+protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"]
generateTestProto.dependsOn 'java_pluginExecutable'
-test.dependsOn('testGolden','testNanoGolden')
+// Ignore test for the moment on Windows. It will be easier to run once the
+// gradle protobuf plugin can support nano.
+if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
+ test.dependsOn('testGolden','testNanoGolden')
+}
task testGolden(type: Exec, dependsOn: 'generateTestProto') {
- executable "diff"
- args "$buildDir/generated-sources/test/io/grpc/testing/integration/TestServiceGrpc.java",
+ if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
+ executable "diff"
+ } else {
+ executable "fc"
+ }
+ // File isn't found on Windows if last slash is forward-slash
+ def slash = System.getProperty("file.separator")
+ args "$buildDir/generated-sources/test/io/grpc/testing/integration" + slash + "TestServiceGrpc.java",
"$projectDir/src/test/golden/TestService.java.txt"
}