plasticbox / grpc-windows

Build gRPC on Windows x64
119 stars 50 forks source link

Feature request: compile with VS2017? #5

Open OlafHaag opened 7 years ago

OlafHaag commented 7 years ago

Hey there! Thanks a lot for those scripts! At least the cloning works like a charm. I've got Visual Studio Community 2017 with v140 Built Tools installed (as I couldn't find a download source for 2015 on the Micrsosoft website), and unfortunately the build of the grpc protoc plugin fails, because it couldn't find v100 (visual studio 2010) build tools. I'm usually a Python user and compiling anything in C++ with visual studio is a pain. Would you, fine sir, by any chance know how to compile grpc with visual studio 2017 Community?

Background: I want to use it in a Plugin (DLL) for a Software (MotionBuilder) which itself is compiled in Visual Studio 2012. Do I have to compile grpc using the VS2012 Toolset? I get a lot of errors trying to do just that... :(

plasticbox commented 7 years ago

hello~

I'm try to compile on VS2017. but not have enough time... ;(

VS2017 removed the VS150COMNTOOLS registry key.

https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/ https://stackoverflow.com/questions/42713238/reliable-way-to-find-the-location-devenv-exe-of-visual-studio-2017

Scripts are using VS140COMNTOOLS environment variable. So need to check VS140COMMONTOOLS environment variables are exists and VS2017 cmd can read that key.

fire commented 6 years ago
diff --git a/grpc_build.bat b/grpc_build.bat
index f3cddb6..3e851c0 100644
--- a/grpc_build.bat
+++ b/grpc_build.bat
@@ -1,11 +1,14 @@
 @echo off
 @setlocal

+"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath > tmp
+SET /P VSCOMNTOOLS= < tmp
+del tmp
 @REM EDIT THIS SECTION ACCORDING TO YOUR ENV
-call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" amd64
+call "%VSCOMNTOOLS%\VC\Auxiliary\Build\vcvarsall.bat" amd64
 set path=%path%;C:\Program Files\cmake-3.8.1-win64-x64\bin
-set path=%path%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
-set path=%path%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
+set path=%path%;%VSCOMNTOOLS%\Common7\IDE
+set path=%path%;%VSCOMNTOOLS%\VC\bin
 @REM EOF

 pushd "%~dp0"
@@ -38,7 +41,7 @@ pushd "%~dp0"
 cd grpc\third_party\protobuf\cmake
 mkdir build & cd build
 mkdir solution & cd solution
-cmake -G "Visual Studio 14 2015 Win64" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=ON ../..
+cmake -G "Visual Studio 15 2017 Win64" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=ON ../..
 "%devenv%" protobuf.sln /build "Debug|x64" /project ALL_BUILD
 if not %ERRORLEVEL% == 0 goto Finish
 robocopy /mir .\Debug ..\..\..\..\..\bin\protobuf\debug
diff --git a/grpc_clone.bat b/grpc_clone.bat
index fd933c4..6769cee 100644
--- a/grpc_clone.bat
+++ b/grpc_clone.bat
@@ -4,7 +4,7 @@ pushd "%~dp0"
 echo #### grpc clone start!

 echo #### git clone
-call git clone -b v1.3.x https://github.com/grpc/grpc
+call git clone -b v1.7.x https://github.com/grpc/grpc
 cd grpc
 call git submodule update --init
 cd ..

Trying this fails at grpc_protoc_plugins.sln. Hope this helps.

fire commented 6 years ago

cd grpc

mkdir debug & cd debug
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../bin/debug ..
nmake & nmake install

cd ..
mkdir release & cd release
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../bin/release ..
nmake & nmake install

echo #### grpc build done!

Removed the fancy code and it is compiling...

abishekh commented 6 years ago

Hi, I'm new to the Visual studio environment. What would I need to to do in the IDE (2017) to try out get this working ?