Skip to content

Commit d04994f

Browse files
committed
Update Windows building instructions for proto3b1
1 parent ea4eed5 commit d04994f

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

COMPILING.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ environment variables will be used when building grpc-java.
4848

4949
Protobuf installs to ``/usr/local`` by default.
5050

51-
For Visual C++, please refer to the [Protobuf README](https://github.com/google/protobuf/blob/master/vsprojects/readme.txt)
52-
for how to compile Protobuf.
51+
For Visual C++, please refer to the [Protobuf README](https://github.com/google/protobuf/blob/master/cmake/README.md)
52+
for how to compile Protobuf. gRPC-java assumes a Release build.
5353

5454
#### Linux and MinGW
5555
If ``/usr/local/lib`` is not in your library search path, you can add it by running:
@@ -73,19 +73,22 @@ Gradle to find protobuf:
7373
```
7474
.\gradlew install ^
7575
-PvcProtobufInclude=C:\path\to\protobuf-3.0.0-beta-1\src ^
76-
-PvcProtobufLibs=C:\path\to\protobuf-3.0.0-beta-1\vsprojects\Release
76+
-PvcProtobufLibs=C:\path\to\protobuf-3.0.0-beta-1\vsprojects\Release ^
77+
-PtargetArch=x86_32
7778
```
7879

7980
Since specifying those properties every build is bothersome, you can instead
8081
create ``<project-root>\gradle.properties`` with contents like:
8182
```
8283
vcProtobufInclude=C:\\path\\to\\protobuf-3.0.0-beta-1\\src
8384
vcProtobufLibs=C:\\path\\to\\protobuf-3.0.0-beta-1\\vsprojects\\Release
85+
targetArch=x86_32
8486
```
8587

86-
The build script will build the codegen for the same architecture as the Java
87-
runtime installed on your system. If you are using 64-bit JVM, the codegen will
88-
be compiled for 64-bit, that means you must have compiled Protobuf in 64-bit.
88+
By default, the build script will build the codegen for the same architecture as
89+
the Java runtime installed on your system. If you are using 64-bit JVM, the
90+
codegen will be compiled for 64-bit. Since Protobuf is only built for 32-bit by
91+
default, the `targetArch=x86_32` is necessary.
8992

9093
### Notes for MinGW on Windows
9194
If you have both MinGW and VC++ installed on Windows, VC++ will be used by

buildscripts/make_dependencies.bat

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
REM installer http://www.7-zip.org/a/7z1507-x64.exe
2+
REM 7za is in http://www.7-zip.org/a/7z1507-extra.7z
3+
4+
REM Prerequisite: 7za.exe in current directory or PATH
5+
6+
set PROTOBUF_VER=3.0.0-beta-1
7+
set CMAKE_NAME=cmake-3.3.2-win32-x86
8+
9+
if not exist "protobuf-%PROTOBUF_VER%\cmake\Release\" (
10+
call :installProto
11+
)
12+
set PROTOCDIR=%cd%\protobuf-%PROTOBUF_VER%\cmake\Release\
13+
goto :eof
14+
15+
16+
:installProto
17+
18+
if not exist "%CMAKE_NAME%" (
19+
call :installCmake
20+
)
21+
set PATH=%PATH%;%cd%\%CMAKE_NAME%\bin
22+
powershell -command "& { iwr https://github.com/google/protobuf/archive/v%PROTOBUF_VER%.zip -OutFile protobuf.zip }"
23+
7za X protobuf.zip
24+
del protobuf.zip
25+
pushd protobuf-3.0.0-beta-1\cmake
26+
mkdir build
27+
cd build
28+
cmake -DBUILD_TESTING=OFF ..
29+
msbuild /maxcpucount /p:Configuration=Release libprotoc.vcxproj
30+
call extract_includes.bat
31+
popd
32+
goto :eof
33+
34+
35+
:installCmake
36+
37+
powershell -command "& { iwr https://cmake.org/files/v3.3/%CMAKE_NAME%.zip -OutFile cmake.zip }"
38+
7za X cmake.zip
39+
del cmake.zip
40+
goto :eof
41+
42+
REM Compile gRPC-Java with something like:
43+
REM -PtargetArch=x86_32 -PvcProtobufLibs=%cd%\protobuf-3.0.0-beta-1\cmake\build\Release -PvcProtobufInclude=%cd%\protobuf-3.0.0-beta-1\cmake\build\include

compiler/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ binaries.all {
153153
}
154154
addEnvArgs("LDFLAGS", linker.args)
155155
} else if (toolChain in VisualCpp) {
156-
cppCompiler.args "/EHsc", "/MD"
156+
cppCompiler.args "/EHsc", "/MT"
157157
if (rootProject.hasProperty('vcProtobufInclude')) {
158158
cppCompiler.args "/I${rootProject.vcProtobufInclude}"
159159
}

0 commit comments

Comments
 (0)