patches/grpc.ps1
|
$fn = @" ARG_WITH("grpc", "grpc support", "no"); function CreateFolderIfMissing(path) { if (!path) return; if (!FSO.FolderExists(path)) { WScript.Echo("Creating " + path + "..."); FSO.CreateFolder(path); } } "@ (Get-Content config.w32) | ForEach-Object { $_.Replace('base_dir+"\\ext\\grpc', 'base_dir+"') } | Set-Content config.w32 (Get-Content config.w32) | ForEach-Object { $_.Replace('FSO.CreateFolder', 'CreateFolderIfMissing') } | Set-Content config.w32 (Get-Content config.w32) | ForEach-Object { $_ -replace '/D_WIN32_WINNT=0x600', '/D_WIN32_WINNT=0x600 /FS /std:c++17 /Zc:preprocessor' } | Set-Content config.w32 (Get-Content config.w32) | ForEach-Object { $_.Replace('ARG_WITH("grpc", "grpc support", "no");', $fn) } | Set-Content config.w32 $wrapperPath = "src\php\ext\grpc\php7_wrapper.h" if (Test-Path $wrapperPath) { $wrapperContent = (Get-Content $wrapperPath -Raw) -replace "`r`n", "`n" $wrapperContent = $wrapperContent.Replace('#define PHP_GRPC_CALL_FUNCTION(fci, fci_cache) ({ \', '#define PHP_GRPC_CALL_FUNCTION(fci, fci_cache) do { \') $wrapperContent = $wrapperContent.Replace(' int _res = zend_call_function(fci, fci_cache TSRMLS_CC); \', ' zend_call_function(fci, fci_cache TSRMLS_CC); \') $wrapperContent = $wrapperContent.Replace(" _res; \`n})", " } while (0)") Set-Content $wrapperPath $wrapperContent } # Retain the VS2019 14.29 toolset used by PHP 8.0-8.3 for bundled Abseil. $abseilPolicyPath = 'third_party\abseil-cpp\absl\base\policy_checks.h' if (Test-Path $abseilPolicyPath) { $abseilPolicy = Get-Content $abseilPolicyPath -Raw if ($abseilPolicy.Contains('_MSC_VER < 1930')) { $abseilPolicy = $abseilPolicy.Replace('_MSC_VER < 1930', '_MSC_VER < 1929') $abseilPolicy = $abseilPolicy.Replace('Visual Studio 2022 (MSVC++ 17.0)', 'Visual Studio 2019 (MSVC 19.29)') Set-Content $abseilPolicyPath $abseilPolicy -NoNewline } } |