Skip to content

Protobuf 22.5 cpp #11961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 48 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6d68cb5
Upgrade Protobuf C++ to 22.5
ejona86 Mar 12, 2025
284234c
Re-add downloading of absl
ejona86 Mar 13, 2025
b76908f
Set LIBRARY_PATH to /tmp/protobuf/lib
kannanjgithub Mar 13, 2025
76a613a
Remove LD_LIBRARY_PATH to try fix "found unexpected dependencies" in …
kannanjgithub Mar 13, 2025
707a50a
Add librt.so.1 to needed dependencies.
kannanjgithub Mar 17, 2025
9485113
Add libm.so.6 as an expected dependency for linux.
kannanjgithub Mar 17, 2025
5a3e3cc
Replace parallel compilation option -j with env variable for the purp…
kannanjgithub Mar 17, 2025
8d8e03c
On multiarch arch64, it requires cmake 3.13 to allow using abseil mod…
kannanjgithub Mar 17, 2025
a5ec1ae
Fix mistake in current directory used.
kannanjgithub Mar 17, 2025
54c962a
Fix missing software deps
kannanjgithub Mar 19, 2025
097c01a
Windows changes.
kannanjgithub Apr 30, 2025
df959ea
missed this file in the commit
kannanjgithub Apr 30, 2025
6ea8908
Use openjdk 21
kannanjgithub Apr 30, 2025
17a479b
Hardcode the location of vcvars64.bat because vswhere doesn't show th…
kannanjgithub May 2, 2025
4177f3e
use VC 2022 install path directly in windows32.bat since vswhere does…
kannanjgithub May 2, 2025
612ba86
Changing it back to using VS170COMNTOOLS
kannanjgithub May 2, 2025
c19d0a5
Add powershell command = 'SilentlyContinue' because apparently proto…
kannanjgithub May 2, 2025
731a8ed
Add powershell command = 'SilentlyContinue' because apparently proto…
kannanjgithub May 2, 2025
a8da589
Add ABSL_INTERNAL_AT_LEAST_CXX17=0 for the 64 bit archs too
kannanjgithub May 2, 2025
767c072
Re-do lines deleted by mistake (introduced in commit 8d8e03c291f97965…
kannanjgithub May 2, 2025
17a811c
Revert last commit, fails to build cmake with OPENSSL errors, with 3.…
kannanjgithub May 2, 2025
e6f445b
Use openjdk 11.
kannanjgithub May 5, 2025
3b97cc8
Remove Ctrl M characters, use gcc option to specify c++ 14
kannanjgithub May 5, 2025
a2fd8dc
Fix open jdk version to 11.0 as 11.0.27 is not available.
kannanjgithub May 5, 2025
5b96e1e
Fix jdk version
kannanjgithub May 5, 2025
8c35eed
Remove accidental commenting out.
kannanjgithub May 5, 2025
f91dbc7
Missed libs
kannanjgithub May 5, 2025
19d0917
Remove leading whitespace in libraries list
kannanjgithub May 5, 2025
4d3f252
Fix libs leading space
kannanjgithub May 5, 2025
02788d8
Don't put spaces in between libs since it breaks the env variable va…
kannanjgithub May 6, 2025
f6fa6f0
Download cmake for android
kannanjgithub May 6, 2025
c3bdce7
Change from /var/local to /usr/local to download cmake as the path is…
kannanjgithub May 6, 2025
927fca6
Fix forgotten % instead of ! for local scope variable.
kannanjgithub May 6, 2025
8d5afa1
Can't write to /usr/local either, use /tmp to install cmake for android.
kannanjgithub May 6, 2025
bc57b03
Install pkg-config for android
kannanjgithub May 6, 2025
75c2a7d
Fix x32 VS generator
kannanjgithub May 6, 2025
1369473
apt-get update before install pkg-config.
kannanjgithub May 6, 2025
260fccf
Fix mistake in order of statements reg. pkg-config
kannanjgithub May 6, 2025
4ef7fd1
Fix mistaken use of x32 instead of x86
kannanjgithub May 6, 2025
088b489
Fix typo
kannanjgithub May 6, 2025
f4aeb67
Skip codegen when rebuilding HEAD.
kannanjgithub May 7, 2025
09535d8
Remove syntax error in assignment
kannanjgithub May 7, 2025
2435780
Remove syntax error in assignment
kannanjgithub May 7, 2025
88999f8
Windows geneator flag for x86
kannanjgithub May 7, 2025
8e16a15
Install pkg-config on mac
kannanjgithub May 7, 2025
4f7c9bb
Change apt-get to brew for mac os for installing pkg-config
kannanjgithub May 7, 2025
3c8bc90
Remove installing pkg-config, its alreay there.
kannanjgithub May 7, 2025
415e913
Try LD_LIBRARY_PATH as well, for mac since I'm getting linker errors …
kannanjgithub May 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions COMPILING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ This section is only necessary if you are making changes to the code
generation. Most users only need to use `skipCodegen=true` as discussed above.

### Build Protobuf
The codegen plugin is C++ code and requires protobuf 21.7 or later.
The codegen plugin is C++ code and requires protobuf 22.5 or later.

For Linux, Mac and MinGW:
```
$ PROTOBUF_VERSION=21.7
$ PROTOBUF_VERSION=22.5
$ curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-all-$PROTOBUF_VERSION.tar.gz
$ tar xzf protobuf-all-$PROTOBUF_VERSION.tar.gz
$ cd protobuf-$PROTOBUF_VERSION
Expand Down
5 changes: 4 additions & 1 deletion buildscripts/grpc-java-artifacts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ RUN mkdir -p "$ANDROID_HOME/cmdline-tools" && \
mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest" && \
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses

RUN curl -Ls https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.tar.gz | \
tar xz -C /var/local

# Install Maven
RUN curl -Ls https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz | \
tar xz -C /var/local
ENV PATH /var/local/apache-maven-3.8.8/bin:$PATH
ENV PATH /var/local/cmake-3.26.3-linux-x86_64/bin:/var/local/apache-maven-3.8.8/bin:$PATH
10 changes: 10 additions & 0 deletions buildscripts/grpc-java-artifacts/Dockerfile.multiarch.base
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,15 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
g++-aarch64-linux-gnu \
g++-powerpc64le-linux-gnu \
openjdk-8-jdk \
pkg-config \
&& \
rm -rf /var/lib/apt/lists/*

RUN curl -Ls https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.tar.gz | \
tar xz -C /var/local

# Install Maven
RUN curl -Ls https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz | \
tar xz -C /var/local
ENV PATH /var/local/cmake-3.26.3-linux-x86_64/bin:/var/local/apache-maven-3.8.8/bin:$PATH

9 changes: 9 additions & 0 deletions buildscripts/grpc-java-artifacts/Dockerfile.ubuntu2004.base
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
curl \
g++-s390x-linux-gnu \
openjdk-8-jdk \
pkg-config \
&& \
rm -rf /var/lib/apt/lists/*

RUN curl -Ls https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.tar.gz | \
tar xz -C /var/local

# Install Maven
RUN curl -Ls https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz | \
tar xz -C /var/local
ENV PATH /var/local/cmake-3.26.3-linux-x86_64/bin:/var/local/apache-maven-3.8.8/bin:$PATH
4 changes: 2 additions & 2 deletions buildscripts/kokoro/android-interop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ set -exu -o pipefail

cd github/grpc-java

export LDFLAGS=-L/tmp/protobuf/lib
export CXXFLAGS=-I/tmp/protobuf/include
export LDFLAGS="$(PKG_CONFIG_PATH=/tmp/protobuf/lib/pkgconfig pkg-config --libs protobuf)"
export CXXFLAGS="$(PKG_CONFIG_PATH=/tmp/protobuf/lib/pkgconfig pkg-config --cflags protobuf)"
export LD_LIBRARY_PATH=/tmp/protobuf/lib
export OS_NAME=$(uname)

Expand Down
14 changes: 10 additions & 4 deletions buildscripts/kokoro/android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ BASE_DIR="$(pwd)"

cd "$BASE_DIR/github/grpc-java"

export LDFLAGS=-L/tmp/protobuf/lib
export CXXFLAGS=-I/tmp/protobuf/include
export LD_LIBRARY_PATH=/tmp/protobuf/lib
export OS_NAME=$(uname)

cat <<EOF >> gradle.properties
Expand All @@ -30,10 +27,18 @@ unzip -qd "${ANDROID_HOME}/cmdline-tools" cmdline.zip
rm cmdline.zip
mv "${ANDROID_HOME}/cmdline-tools/cmdline-tools" "${ANDROID_HOME}/cmdline-tools/latest"
(yes || true) | "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --licenses

curl -Ls https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.tar.gz | \
tar xz -C /tmp
export PATH=/tmp/cmake-3.26.3-linux-x86_64/bin:$PATH

# Proto deps
buildscripts/make_dependencies.sh

sudo apt-get update && sudo apt-get install pkg-config
export LDFLAGS="$(PKG_CONFIG_PATH=/tmp/protobuf/lib/pkgconfig pkg-config --libs protobuf)"
export CXXFLAGS="$(PKG_CONFIG_PATH=/tmp/protobuf/lib/pkgconfig pkg-config --cflags protobuf)"
export LD_LIBRARY_PATH=/tmp/protobuf/lib

# Build Android with Java 11, this adds it to the PATH
sudo update-java-alternatives --set java-1.11.0-openjdk-amd64
# Unset any existing JAVA_HOME env var to stop Gradle from using it
Expand Down Expand Up @@ -98,6 +103,7 @@ cd $BASE_DIR/github/grpc-java
./gradlew clean
git checkout HEAD^
./gradlew --stop # use a new daemon to build the previous commit
GRADLE_FLAGS="${GRADLE_FLAGS} -PskipCodegen=true"
./gradlew publishToMavenLocal $GRADLE_FLAGS
cd examples/android/helloworld/
../../gradlew build $GRADLE_FLAGS
Expand Down
6 changes: 3 additions & 3 deletions buildscripts/kokoro/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ fi
export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'"

# Make protobuf discoverable by :grpc-compiler
export LD_LIBRARY_PATH=/tmp/protobuf/lib
export LDFLAGS=-L/tmp/protobuf/lib
export CXXFLAGS="-I/tmp/protobuf/include"
export LDFLAGS="$(PKG_CONFIG_PATH=/tmp/protobuf/lib/pkgconfig pkg-config --libs protobuf)"
export CXXFLAGS="$(PKG_CONFIG_PATH=/tmp/protobuf/lib/pkgconfig pkg-config --cflags protobuf)"
export LIBRARY_PATH=/tmp/protobuf/lib

./gradlew grpc-compiler:clean $GRADLE_FLAGS

Expand Down
41 changes: 36 additions & 5 deletions buildscripts/kokoro/windows32.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ set ESCWORKSPACE=%WORKSPACE:\=\\%

@rem Clear JAVA_HOME to prevent a different Java version from being used
set JAVA_HOME=
set PATH=C:\Program Files\OpenJDK\openjdk-11.0.12_7\bin;%PATH%

mkdir grpc-java-helper32
cd grpc-java-helper32
call "%VS140COMNTOOLS%\vsvars32.bat" || exit /b 1
call "%VS170COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvars32.bat" || exit /b 1
call "%WORKSPACE%\buildscripts\make_dependencies.bat" || exit /b 1

cd "%WORKSPACE%"

SET TARGET_ARCH=x86_32
SET FAIL_ON_WARNINGS=true
SET VC_PROTOBUF_LIBS=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\Release
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\include
SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% -PskipAndroid=true
SET PROTOBUF_VER=22.5
SET PKG_CONFIG_PATH=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib\\pkgconfig
SET VC_PROTOBUF_LIB_PATHS=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper32\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\include
call :Get_Libs
SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibPaths=%VC_PROTOBUF_LIB_PATHS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% -PskipAndroid=true
SET GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'"

cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% build"
Expand All @@ -50,3 +52,32 @@ IF NOT %GRADLEEXIT% == 0 (
cmd.exe /C "%WORKSPACE%\gradlew.bat --stop"

cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% -Dorg.gradle.parallel=false -PrepositoryDir=%WORKSPACE%\artifacts clean grpc-compiler:build grpc-compiler:publish" || exit /b 1

goto :eof
:Get_Libs
SetLocal EnableDelayedExpansion
set "libs_list="
for /f "tokens=*" %%a in ('pkg-config --libs protobuf') do (
for %%b in (%%a) do (
set lib=%%b
set libfirst2char=!lib:~0,2!
if !libfirst2char!==-l (
@rem remove the leading -l
set lib=!lib:~2!
@rem remove spaces
set lib=!lib: =!
@rem Because protobuf is specified as libprotobuf and elsewhere
if !lib! NEQ protobuf (
set lib=!lib!.lib
if "!libs_list!"=="" (
set libs_list=!lib!
) else (
set libs_list=!libs_list!,!lib!
)
)
)
)
)
EndLocal & set "VC_PROTOBUF_LIBS=%libs_list%"
exit /b 0

103 changes: 67 additions & 36 deletions buildscripts/kokoro/windows64.bat
Original file line number Diff line number Diff line change
@@ -1,36 +1,67 @@
@rem ##########################################################################
@rem
@rem Builds artifacts for x86_64 into %WORKSPACE%\artifacts\
@rem
@rem ##########################################################################

type c:\VERSION

@rem Enter repo root
cd /d %~dp0\..\..

set WORKSPACE=T:\src\github\grpc-java
set ESCWORKSPACE=%WORKSPACE:\=\\%

@rem Clear JAVA_HOME to prevent a different Java version from being used
set JAVA_HOME=
set PATH=C:\Program Files\OpenJDK\openjdk-11.0.12_7\bin;%PATH%

mkdir grpc-java-helper64
cd grpc-java-helper64
call "%VS140COMNTOOLS%\..\..\VC\bin\amd64\vcvars64.bat" || exit /b 1
call "%WORKSPACE%\buildscripts\make_dependencies.bat" || exit /b 1

cd "%WORKSPACE%"

SET TARGET_ARCH=x86_64
SET FAIL_ON_WARNINGS=true
SET VC_PROTOBUF_LIBS=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\Release
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\include
SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% -PskipAndroid=true
SET GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'"

@rem make sure no daemons have any files open
cmd.exe /C "%WORKSPACE%\gradlew.bat --stop"

cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% -Dorg.gradle.parallel=false -PrepositoryDir=%WORKSPACE%\artifacts grpc-compiler:clean grpc-compiler:build grpc-compiler:publish" || exit /b 1
@rem ##########################################################################
@rem
@rem Builds artifacts for x86_64 into %WORKSPACE%\artifacts\
@rem
@rem ##########################################################################

type c:\VERSION

@rem Enter repo root
cd /d %~dp0\..\..

set WORKSPACE=T:\src\github\grpc-java
set ESCWORKSPACE=%WORKSPACE:\=\\%

@rem Clear JAVA_HOME to prevent a different Java version from being used
set JAVA_HOME=

mkdir grpc-java-helper64
cd grpc-java-helper64
call "%VS170COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvars64.bat" || exit /b 1
call "%WORKSPACE%\buildscripts\make_dependencies.bat" || exit /b 1

cd "%WORKSPACE%"

SET TARGET_ARCH=x86_64
SET FAIL_ON_WARNINGS=true
SET PROTOBUF_VER=22.5
SET PKG_CONFIG_PATH=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib\\pkgconfig
SET VC_PROTOBUF_LIB_PATHS=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\lib
SET VC_PROTOBUF_INCLUDE=%ESCWORKSPACE%\\grpc-java-helper64\\protobuf-%PROTOBUF_VER%\\build\\protobuf-%PROTOBUF_VER%\\include
call :Get_Libs
SET GRADLE_FLAGS=-PtargetArch=%TARGET_ARCH% -PfailOnWarnings=%FAIL_ON_WARNINGS% -PvcProtobufLibPaths=%VC_PROTOBUF_LIB_PATHS% -PvcProtobufLibs=%VC_PROTOBUF_LIBS% -PvcProtobufInclude=%VC_PROTOBUF_INCLUDE% -PskipAndroid=true
SET GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'"

@rem make sure no daemons have any files open
cmd.exe /C "%WORKSPACE%\gradlew.bat --stop"

cmd.exe /C "%WORKSPACE%\gradlew.bat %GRADLE_FLAGS% -Dorg.gradle.parallel=false -PrepositoryDir=%WORKSPACE%\artifacts grpc-compiler:clean grpc-compiler:build grpc-compiler:publish" || exit /b 1

goto :eof
:Get_Libs
SetLocal EnableDelayedExpansion
set "libs_list="
for /f "tokens=*" %%a in ('pkg-config --libs protobuf') do (
for %%b in (%%a) do (
set lib=%%b
set libfirst2char=!lib:~0,2!
if !libfirst2char!==-l (
@rem remove the leading -l
set lib=!lib:~2!
@rem remove spaces
set lib=!lib: =!
@rem Because protobuf is specified as libprotobuf and elsewhere
if !lib! NEQ protobuf (
set lib=!lib!.lib
if "!libs_list!"=="" (
set libs_list=!lib!
) else (
set libs_list=!libs_list!,!lib!
)
)
)
)
)
EndLocal & set "VC_PROTOBUF_LIBS=%libs_list%"
exit /b 0

44 changes: 31 additions & 13 deletions buildscripts/make_dependencies.bat
Original file line number Diff line number Diff line change
@@ -1,44 +1,61 @@
set PROTOBUF_VER=21.7
set CMAKE_NAME=cmake-3.3.2-win32-x86
echo on
@rem set PROTOBUF_VER=21.7
choco install -y gradle git curl pkgconfiglite
choco install -y openjdk --version=17.0
set JAVA_HOME="c:\Program Files\OpenJDK\jdk-17"
set PATH=%PATH%;"c:\Program Files\OpenJDK\jdk-17\bin"
set PROTOBUF_VER=22.5
set ABSL_VERSION=20230125.4

if not exist "protobuf-%PROTOBUF_VER%\build\Release\" (
call :installProto || exit /b 1
)

echo Compile gRPC-Java with something like:
echo -PtargetArch=x86_32 -PvcProtobufLibs=%cd%\protobuf-%PROTOBUF_VER%\build\Release -PvcProtobufInclude=%cd%\protobuf-%PROTOBUF_VER%\build\include
echo -PtargetArch=x86_32 -PvcProtobufLibPath=%cd%\protobuf-%PROTOBUF_VER%\build\protobuf-%PROTOBUF_VER%\lib -PvcProtobufInclude=%cd%\protobuf-%PROTOBUF_VER%\build\protobuf-%PROTOBUF_VER%\include -PvcProtobufLibs=insert-list-of-libs-from-pkg-config-output-here
goto :eof


:installProto

where /q cmake
if not ERRORLEVEL 1 goto :hasCmake
set CMAKE_NAME=cmake-3.26.3-windows-x86_64
if not exist "%CMAKE_NAME%" (
call :installCmake || exit /b 1
)
set PATH=%PATH%;%cd%\%CMAKE_NAME%\bin
:hasCmake
@rem GitHub requires TLSv1.2, and for whatever reason our powershell doesn't have it enabled
powershell -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
powershell -command "$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'stop'; & { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; iwr https://github.com/google/protobuf/releases/download/v%PROTOBUF_VER%/protobuf-%PROTOBUF_VER%.zip -OutFile protobuf.zip }" || exit /b 1
powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('protobuf.zip', '.') }" || exit /b 1
del protobuf.zip
powershell -command "$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'stop'; & { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; iwr https://github.com/abseil/abseil-cpp/archive/refs/tags/%ABSL_VERSION%.zip -OutFile absl.zip }" || exit /b 1
powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('absl.zip', '.') }" || exit /b 1
del absl.zip
rmdir protobuf-%PROTOBUF_VER%\third_party\abseil-cpp
move abseil-cpp-%ABSL_VERSION% protobuf-%PROTOBUF_VER%\third_party\abseil-cpp
mkdir protobuf-%PROTOBUF_VER%\build
pushd protobuf-%PROTOBUF_VER%\build

@rem Workaround https://github.com/protocolbuffers/protobuf/issues/10174
powershell -command "(Get-Content ..\cmake\extract_includes.bat.in) -replace '\.\.\\', '' | Out-File -encoding ascii ..\cmake\extract_includes.bat.in"
@rem cmake does not detect x86_64 from the vcvars64.bat variables.
@rem If vcvars64.bat has set PLATFORM to X64, then inform cmake to use the Win64 version of VS
if "%PLATFORM%" == "X64" (
@rem Note the space
SET CMAKE_VSARCH= Win64
@rem If vcvars64.bat has set PLATFORM to X64, then inform cmake to use the Win64 version of VS, likewise for x32
if "%PLATFORM%" == "x64" (
SET CMAKE_VSARCH=-A x64
) else if "%PLATFORM%" == "x86" (
@rem -A x86 doesn't work: https://github.com/microsoft/vcpkg/issues/15465
SET CMAKE_VSARCH=-DCMAKE_GENERATOR_PLATFORM=WIN32
) else (
SET CMAKE_VSARCH=
)
cmake -Dprotobuf_BUILD_TESTS=OFF -G "Visual Studio %VisualStudioVersion:~0,2%%CMAKE_VSARCH%" .. || exit /b 1
msbuild /maxcpucount /p:Configuration=Release /verbosity:minimal libprotoc.vcxproj || exit /b 1
call extract_includes.bat || exit /b 1
for /f "tokens=4 delims=\" %%a in ("%VCINSTALLDIR%") do (
SET VC_YEAR=%%a
)
for /f "tokens=1 delims=." %%a in ("%VisualStudioVersion%") do (
SET visual_studio_major_version=%%a
)
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=%cd%\protobuf-%PROTOBUF_VER% -DCMAKE_PREFIX_PATH=%cd%\protobuf-%PROTOBUF_VER% -G "Visual Studio %visual_studio_major_version% %VC_YEAR%" %CMAKE_VSARCH% ..
cmake --build . --config Release --target install
popd
goto :eof

Expand All @@ -49,3 +66,4 @@ powershell -command "$ErrorActionPreference = 'stop'; & { iwr https://cmake.org/
powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('cmake.zip', '.') }" || exit /b 1
del cmake.zip
goto :eof

Loading
Loading