xref: /aosp_15_r20/external/grpc-grpc-java/buildscripts/make_dependencies.bat (revision e07d83d3ffcef9ecfc9f7f475418ec639ff0e5fe)
1set PROTOBUF_VER=21.7
2set CMAKE_NAME=cmake-3.3.2-win32-x86
3
4if not exist "protobuf-%PROTOBUF_VER%\build\Release\" (
5  call :installProto || exit /b 1
6)
7
8echo Compile gRPC-Java with something like:
9echo -PtargetArch=x86_32 -PvcProtobufLibs=%cd%\protobuf-%PROTOBUF_VER%\build\Release -PvcProtobufInclude=%cd%\protobuf-%PROTOBUF_VER%\build\include
10goto :eof
11
12
13:installProto
14
15where /q cmake
16if not ERRORLEVEL 1 goto :hasCmake
17if not exist "%CMAKE_NAME%" (
18  call :installCmake || exit /b 1
19)
20set PATH=%PATH%;%cd%\%CMAKE_NAME%\bin
21:hasCmake
22@rem GitHub requires TLSv1.2, and for whatever reason our powershell doesn't have it enabled
23powershell -command "$ErrorActionPreference = 'stop'; & { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; iwr https://github.com/google/protobuf/archive/v%PROTOBUF_VER%.zip -OutFile protobuf.zip }" || exit /b 1
24powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('protobuf.zip', '.') }" || exit /b 1
25del protobuf.zip
26mkdir protobuf-%PROTOBUF_VER%\build
27pushd protobuf-%PROTOBUF_VER%\build
28
29@rem Workaround https://github.com/protocolbuffers/protobuf/issues/10174
30powershell -command "(Get-Content ..\cmake\extract_includes.bat.in) -replace '\.\.\\', '' | Out-File -encoding ascii ..\cmake\extract_includes.bat.in"
31@rem cmake does not detect x86_64 from the vcvars64.bat variables.
32@rem If vcvars64.bat has set PLATFORM to X64, then inform cmake to use the Win64 version of VS
33if "%PLATFORM%" == "X64" (
34  @rem Note the space
35  SET CMAKE_VSARCH= Win64
36) else (
37  SET CMAKE_VSARCH=
38)
39cmake -Dprotobuf_BUILD_TESTS=OFF -G "Visual Studio %VisualStudioVersion:~0,2%%CMAKE_VSARCH%" .. || exit /b 1
40msbuild /maxcpucount /p:Configuration=Release /verbosity:minimal libprotoc.vcxproj || exit /b 1
41call extract_includes.bat || exit /b 1
42popd
43goto :eof
44
45
46:installCmake
47
48powershell -command "$ErrorActionPreference = 'stop'; & { iwr https://cmake.org/files/v3.3/%CMAKE_NAME%.zip -OutFile cmake.zip }" || exit /b 1
49powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('cmake.zip', '.') }" || exit /b 1
50del cmake.zip
51goto :eof
52