From e0e628ac7e24f9b5bc1ef9afb5cd6e7a313c2d91 Mon Sep 17 00:00:00 2001 From: chrisbednarski Date: Sat, 18 Mar 2023 09:45:56 +1100 Subject: [PATCH] fix(build): fix build with openssl 3.1.0 on vs2022 (#3969) * fix log verbosity in windows powershell build script * stop paths being added multiple times to environment variables * pass useenv property to msbuild * linking issue: include crypto.h prior to config.h so POCO_EXTERNAL_OPENSSL is initialised * resolve poco_base path in powershell script * build against any available windows sdk --- NetSSL_OpenSSL/include/Poco/Net/NetSSL.h | 2 +- buildwin.cmd | 4 ++-- buildwin.ps1 | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/NetSSL_OpenSSL/include/Poco/Net/NetSSL.h b/NetSSL_OpenSSL/include/Poco/Net/NetSSL.h index 444ab4b8c..2352f07e6 100644 --- a/NetSSL_OpenSSL/include/Poco/Net/NetSSL.h +++ b/NetSSL_OpenSSL/include/Poco/Net/NetSSL.h @@ -20,8 +20,8 @@ #define NetSSL_NetSSL_INCLUDED -#include "Poco/Net/Net.h" #include "Poco/Crypto/Crypto.h" +#include "Poco/Net/Net.h" // diff --git a/buildwin.cmd b/buildwin.cmd index c8cbcbb86..6964275fc 100644 --- a/buildwin.cmd +++ b/buildwin.cmd @@ -135,12 +135,12 @@ if not defined VCINSTALLDIR ( ) else ( if %VS_VERSION%==vs170 ( if %PLATFORM%==x64 ( - call "%VS170COMNTOOLS%%VS_VARSALL%" x86_amd64 8.1 + call "%VS170COMNTOOLS%%VS_VARSALL%" x86_amd64 ) else ( if %PLATFORM%==arm64 ( call "%VS170COMNTOOLS%%VS_VARSALL%" x86_arm64 ) else ( - call "%VS170COMNTOOLS%%VS_VARSALL%" x86 8.1 + call "%VS170COMNTOOLS%%VS_VARSALL%" x86 ) ) ) diff --git a/buildwin.ps1 b/buildwin.ps1 index 2942daf15..93fac1f08 100644 --- a/buildwin.ps1 +++ b/buildwin.ps1 @@ -14,7 +14,7 @@ # [-omit "Lib1X,LibY,LibZ,..."] # [-tool msbuild | devenv] # [-useenv env | noenv] -# [-verbosity m[inimal] | q[uiet] | n[ormal] | d[etailed] | diag[nostic]] +# [-verbosity minimal | quiet | normal | detailed | diagnostic] # [-openssl_base dir] # [-mysql_base dir] @@ -57,7 +57,7 @@ Param [string] $useenv = 'env', [Parameter()] - [ValidateSet('quiet', 'm[inimal]', 'n[ormal]', 'd[etailed]', 'diag[nostic]')] + [ValidateSet('quiet', 'minimal', 'normal', 'detailed', 'diagnostic')] [string] $verbosity = 'minimal', [Parameter()] @@ -116,12 +116,13 @@ function Add-VSCOMNTOOLS([int] $vsver) function Add-Env-Var([string] $lib, [string] $var) { - if ((${Env:$var} -eq $null) -or (-not ${Env:$var}.Contains(${Env:$lib_$var"}))) + $envvar = if (Test-Path "Env:$var") { Get-Content "Env:$var" } Else { "" } + + $libvar = Get-Content "Env:${lib}_$var" + if (-not $envvar.Contains($libvar)) { - $libvar = "$lib" + "_" + "$var" - $envvar = [Environment]::GetEnvironmentVariable($var, "Process") - $envvar = $envvar + ';' + [Environment]::GetEnvironmentVariable($libvar, "Process") - [Environment]::SetEnvironmentVariable($var, $envvar, "Process") + $envvar = $envvar + ";$libvar" + Set-Content "Env:${var}" $envvar } } @@ -141,7 +142,7 @@ function Set-Environment if ($openssl_base -eq '') { - $script:openssl_base = '$poco_base\openssl' + $script:openssl_base = "$poco_base\openssl" } $Env:OPENSSL_DIR = "$openssl_base" @@ -270,7 +271,7 @@ function Exec-MSBuild([string] $vsProject, [string] $projectConfig) return } - $cmd = "&`"$script:msbuild_exe`" $vsProject /nologo /m /t:$action /p:Configuration=$projectConfig /p:BuildProjectReferences=false /p:Platform=$platform /p:useenv=$useenv /v:$verbosity" + $cmd = "&`"$script:msbuild_exe`" $vsProject /nologo /m /t:$action /p:Configuration=$projectConfig /p:BuildProjectReferences=false /p:Platform=$platform /p:useenv=$($useenv -eq 'env') /v:$verbosity" Write-Host $cmd Invoke-Expression $cmd if ($LastExitCode -ne 0) { Exit $LastExitCode }