diff options
author | Konrad Kujawa <konrad.kujawa@qt.io> | 2023-08-10 14:59:03 +0200 |
---|---|---|
committer | Konrad Kujawa <konrad.kujawa@qt.io> | 2023-11-22 20:06:49 +0200 |
commit | 9707535fc1c7394aead73d21653548bce69161e5 (patch) | |
tree | f32dd63be6472ce2c7de29a27c9d0ddf462933e5 /coin/provisioning/common | |
parent | 65101a61e695d3abb2c1ec55ee7ec0440bd3585d (diff) |
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>
Diffstat (limited to 'coin/provisioning/common')
-rw-r--r-- | coin/provisioning/common/windows/grpc.ps1 | 59 | ||||
-rw-r--r-- | coin/provisioning/common/windows/protobuf.ps1 | 12 |
2 files changed, 20 insertions, 51 deletions
diff --git a/coin/provisioning/common/windows/grpc.ps1 b/coin/provisioning/common/windows/grpc.ps1 index 2cbcba28..7acbe896 100644 --- a/coin/provisioning/common/windows/grpc.ps1 +++ b/coin/provisioning/common/windows/grpc.ps1 @@ -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 - -# 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 +Push-Location $targetDir -### 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 diff --git a/coin/provisioning/common/windows/protobuf.ps1 b/coin/provisioning/common/windows/protobuf.ps1 index dacd1f02..2fc07443 100644 --- a/coin/provisioning/common/windows/protobuf.ps1 +++ b/coin/provisioning/common/windows/protobuf.ps1 @@ -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 |