Add provisioning of gRPC on Windows machines

Enable native_grpc feature on msvc developer-builds.

Fixes: QTBUG-109072
Pick-to: 6.6
Change-Id: I64914d4bf0f26b907a98508f88587cbc8cb947b3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
This commit is contained in:
Konrad Kujawa 2023-08-10 14:59:03 +02:00
parent 65101a61e6
commit 9707535fc1
7 changed files with 28 additions and 66 deletions

View File

@ -71,7 +71,6 @@ Configurations:
'LLVM_INSTALL_DIR={{.Env.LLVM_INSTALL_DIR_msvc}}',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MSVC}} -DFEATURE_native_grpc=OFF',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_msvc}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_msvc}}',
]
-
Id: 'windows-11_22h2-msvc2019'
@ -84,7 +83,6 @@ Configurations:
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MSVC}} -DFEATURE_native_grpc=OFF',
'LLVM_INSTALL_DIR={{.Env.LLVM_INSTALL_DIR_msvc}}',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_msvc}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_msvc}}',
]
-
Id: 'windows-10_22h2-msvc2022'
@ -94,10 +92,9 @@ Configurations:
Configure arguments: '-debug-and-release -force-debug-info -headersclean -nomake examples -qt-zlib'
Environment variables: [
'CMAKE_ARGS=-DFEATURE_msvc_obj_debug_info=ON -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_INCLUDE_x64}}\.. -DPostgreSQL_ROOT={{.Env.POSTGRESQL_LIB_x64}}\.. -DMySQL_ROOT={{.Env.ENV_MySQL_ROOT}} -DMySQL_LIBRARY_DIR={{.Env.ENV_MySQL_LIBRARY_DIR}}',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MSVC}}',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MSVC}} -DFEATURE_native_grpc=OFF',
'LLVM_INSTALL_DIR={{.Env.LLVM_INSTALL_DIR_msvc}}',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_msvc}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_msvc}}',
]
-
Id: 'windows-11_22h2-msvc2022'
@ -107,10 +104,9 @@ Configurations:
Configure arguments: '-debug-and-release -force-debug-info -headersclean -nomake examples -qt-zlib'
Environment variables: [
'CMAKE_ARGS=-DFEATURE_msvc_obj_debug_info=ON -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_INCLUDE_x64}}\.. -DPostgreSQL_ROOT={{.Env.POSTGRESQL_LIB_x64}}\..',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MSVC}}',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MSVC}} -DFEATURE_native_grpc=OFF',
'LLVM_INSTALL_DIR={{.Env.LLVM_INSTALL_DIR_msvc}}',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_msvc}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_msvc}}',
]
-
Id: 'windows-10_22h2-msvc2019-developer-build'
@ -139,7 +135,6 @@ Configurations:
'OPENSSL_INCLUDE_x64={{.Env.OPENSSL_INCLUDE_x64_arm64}}',
'OPENSSL_LIB_x64={{.Env.OPENSSL_LIB_x64_arm64}}',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_msvc}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_msvc}}',
]
-
Id: 'windows-11_22h2-msvc2019-developer-build'
@ -165,7 +160,6 @@ Configurations:
'TARGET_CMAKE_ARGS=-DFEATURE_msvc_obj_debug_info=ON',
'NON_QTBASE_TARGET_CMAKE_ARGS=-DFEATURE_native_grpc=OFF',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_msvc}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_msvc}}',
]
-
Id: 'rhel-8.8'
@ -222,7 +216,6 @@ Configurations:
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MINGW}} -DFEATURE_native_grpc=OFF -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c',
'LLVM_INSTALL_DIR={{.Env.LLVM_INSTALL_DIR_mingw}}',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_mingw}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_mingw}}',
]
-
Id: 'windows-10_22h2-llvm'
@ -236,7 +229,6 @@ Configurations:
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_LLVM_MINGW}} -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c',
'LLVM_INSTALL_DIR=C:\llvm-mingw',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_llvm_mingw}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_llvm_mingw}}',
]
-
Id: 'windows-11_22h2-llvm'
@ -250,7 +242,6 @@ Configurations:
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_LLVM_MINGW}} -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c',
'LLVM_INSTALL_DIR=C:\llvm-mingw',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_llvm_mingw}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_llvm_mingw}}',
]
-
Id: 'windows-10_22h2-mingw11-developer-build'
@ -261,10 +252,9 @@ Configurations:
Environment variables: [
'Path={{.Env.MINGW1120}}\bin;{{.Env.Path}}',
'CMAKE_ARGS=-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_INCLUDE_x64}}\.. -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MINGW}} -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MINGW}} -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c -DFEATURE_native_grpc=OFF',
'LLVM_INSTALL_DIR={{.Env.LLVM_INSTALL_DIR_mingw}}',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_mingw}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_mingw}}',
]
-
Id: 'windows-11_22h2-mingw11-developer-build'
@ -275,10 +265,9 @@ Configurations:
Environment variables: [
'Path={{.Env.MINGW1120}}\bin;{{.Env.Path}}',
'CMAKE_ARGS=-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_INCLUDE_x64}}\.. -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MINGW}} -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_MINGW}} -DCMAKE_IGNORE_PREFIX_PATH=C:/strawberry/c -DFEATURE_native_grpc=OFF',
'LLVM_INSTALL_DIR={{.Env.LLVM_INSTALL_DIR_mingw}}',
'Protobuf_ROOT={{.Env.Protobuf_ROOT_mingw}}',
'gRPC_ROOT={{.Env.gRPC_ROOT_mingw}}',
]
-
Id: 'focal-arm64-debian-pkg-packaging'

View File

@ -20,23 +20,20 @@ function build-install-grpc {
)
$installPrefix = "C:\Utils\grpc"
$installPath = "${installPrefix}-$Postfix"
$envVariableName = "Protobuf_ROOT_$Postfix"
$protobufRoot = (Get-Item -Path "Env:$envVariableName").Value
Write-Output "Configuring and building gRPC for $CXX"
$oldCC = $env:CC
$oldCXX = $env:CXX
$env:CC = $CC
$env:CXX = $CXX
$Protobuf_ROOT="C:\Utils\protobuf-$Postfix"
if (!(Test-Path $Protobuf_ROOT -ErrorAction SilentlyContinue)) {
throw "Protobuf is missing, expected at `"$Protobuf_ROOT`"."
}
$OPENSSL_ROOT_DIR="C:\openssl"
if (!(Test-Path $OPENSSL_ROOT_DIR -ErrorAction SilentlyContinue)) {
throw "OpenSSL is missing, expected at `"$OPENSSL_ROOT_DIR`"."
}
Remove build-grpc
mkdir build-grpc
Push-Location build-grpc
$configureOptions = @(
# add postfix for multi-config
"-DCMAKE_DEBUG_POSTFIX=d"
"-DCMAKE_RELWITHDEBINFO_POSTFIX=rd"
# plugins
"-DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF"
"-DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF"
@ -48,12 +45,11 @@ function build-install-grpc {
"-DgRPC_BUILD_CSHARP_EXT=OFF"
# general
"-DgRPC_BUILD_TESTS=OFF"
"-DgRPC_PROTOBUF_PROVIDER=`"package`""
"-DgRPC_SSL_PROVIDER=`"package`""
"-DOPENSSL_ROOT_DIR=`"$OPENSSL_ROOT_DIR`""
"-DgRPC_PROTOBUF_PROVIDER=package"
"-DgRPC_SSL_PROVIDER=package"
# protobuf
"-DProtobuf_USE_STATIC_LIBS=ON"
"-DProtobuf_ROOT=`"$Protobuf_ROOT`""
"-DCMAKE_PREFIX_PATH=$protobufRoot"
)
cmake .. -G"Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES="$BuildType" -DCMAKE_INSTALL_PREFIX="$installPath" $extraCMakeArgs $configureOptions
$result = $LASTEXITCODE
@ -66,7 +62,7 @@ function build-install-grpc {
}
$env:CC = $oldCC
$env:CXX = $oldCXX
Set-EnvironmentVariable "gRPC_ROOT_$Postfix" "$InstallPath"
Set-EnvironmentVariable "gRPC_ROOT_$Postfix" "$installPath"
Pop-Location
Remove build-grpc
if ($result -ne 0) {
@ -111,44 +107,15 @@ Verify-Checksum $targetFile $sha1
Extract-7Zip $targetFile $basedir
Remove $targetFile
Push-Location $basedir
Push-Location $targetDir
# Create a new top-level CMakeLists.txt file so we can set a modern policy
# for find_package calls
Write-Output "cmake_minimum_required(VERSION 3.5.1)`nproject(grpc LANGUAGES C CXX)`ncmake_policy(SET CMP0074 NEW)`nadd_subdirectory(grpc-$version)" | Out-File CMakeLists.txt -Encoding utf8
### MinGW
# Check if mingw is where we expect it to be and add it to path:
$mingwPath = "C:\MINGW1120\mingw64\bin"
if (!(Test-Path $mingwPath)) {
throw "Cannot find mingw in $mingwPath, something is configured wrong"
}
$oldPath = $env:Path
$env:Path = "$mingwPath;$env:Path"
build-install-grpc -CC "gcc" -CXX "g++" -BuildType "Release" -Postfix "mingw"
$env:Path = $oldPath
### LLVM MinGW
# $llvmMingwPath = "C:\llvm-mingw"
# if (!(Test-Path $llvmMingwPath)) {
# throw "Cannot find llvm-mingw in $llvmMingwPath, something is configured wrong"
# }
$oldPath = $env:Path
$env:Path = "$llvmMingwPath\bin;$env:Path"
# build-install-grpc -CC "clang" -CXX "clang++" -BuildType "Release" -Postfix "llvm_mingw"
$env:Path = $oldPath
### MSVC
### gRPC supports only MSVC compiler
EnterVSDevShell
build-install-grpc -CC "cl" -CXX "cl" -BuildType "Release" -Postfix "msvc"
# We pass along an extra argument to stop gRPC linking with the static runtime to match Protobuf config
build-install-grpc -CC "cl" -CXX "cl" -BuildType "Release;RelWithDebInfo;Debug" -Postfix "msvc" -ExtraArguments @("-DgRPC_MSVC_STATIC_RUNTIME=OFF")
$env:Path = $oldPath
Pop-Location
Remove $basedir

View File

@ -28,14 +28,16 @@ function build-install-protobuf {
$env:CXX = $CXX
mkdir build
Push-Location build
cmake .. -G"Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES="$BuildType" -DCMAKE_INSTALL_PREFIX="$installPath" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=OFF $ExtraArguments
cmake .. -G"Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES="$BuildType" -DCMAKE_INSTALL_PREFIX="$installPath" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB=OFF -DCMAKE_DEBUG_POSTFIX="d" -DCMAKE_RELWITHDEBINFO_POSTFIX="rd" $ExtraArguments
# ninja install:all # This is broken and does not work
foreach ($config in $BuildType.split(";")) {
ninja -f "build-$config.ninja" install
}
$env:CC = $oldCC
$env:CXX = $oldCXX
Set-EnvironmentVariable "Protobuf_ROOT_$Postfix" "$InstallPath"
Set-EnvironmentVariable "Protobuf_ROOT_$Postfix" "$installPath"
# Set environment variable without "Machine" scope to be used by grpc.ps1 script
[Environment]::SetEnvironmentVariable("Protobuf_ROOT_$Postfix", "$installPath")
Pop-Location
Remove build
}
@ -87,7 +89,7 @@ if (!(Test-Path $mingwPath)) {
$oldPath = $env:Path
$env:Path = "$mingwPath;$env:Path"
build-install-protobuf -CC "gcc" -CXX "g++" -BuildType "Release" -Postfix "mingw"
build-install-protobuf -CC "gcc" -CXX "g++" -BuildType "Release;RelWithDebInfo;Debug" -Postfix "mingw"
$env:Path = $oldPath
### LLVM MinGW
@ -99,7 +101,7 @@ if (!(Test-Path $llvmMingwPath)) {
$oldPath = $env:Path
$env:Path = "$llvmMingwPath\bin;$env:Path"
build-install-protobuf -CC "clang" -CXX "clang++" -BuildType "Release" -Postfix "llvm_mingw"
build-install-protobuf -CC "clang" -CXX "clang++" -BuildType "Release;RelWithDebInfo;Debug" -Postfix "llvm_mingw"
$env:Path = $oldPath
### MSVC
@ -107,7 +109,7 @@ $env:Path = $oldPath
EnterVSDevShell
# We pass along an extra argument to stop protobuf linking with the static runtime
build-install-protobuf -CC "cl" -CXX "cl" -BuildType "Release" -Postfix "msvc" -ExtraArguments @("-Dprotobuf_MSVC_STATIC_RUNTIME=OFF")
build-install-protobuf -CC "cl" -CXX "cl" -BuildType "Release;RelWithDebInfo;Debug" -Postfix "msvc" -ExtraArguments @("-Dprotobuf_MSVC_STATIC_RUNTIME=OFF")
$env:Path = $oldPath
Pop-Location

View File

@ -0,0 +1 @@
. "$PSScriptRoot\..\common\windows\grpc.ps1"

View File

@ -0,0 +1 @@
. "$PSScriptRoot\..\common\windows\grpc.ps1"

View File

@ -0,0 +1 @@
. "$PSScriptRoot\..\common\windows\grpc.ps1"

View File

@ -0,0 +1 @@
. "$PSScriptRoot\..\common\windows\grpc.ps1"