diff --git a/.github/workflows/build.ps1 b/.github/workflows/build.ps1 index 45767b5..74c333c 100644 --- a/.github/workflows/build.ps1 +++ b/.github/workflows/build.ps1 @@ -2,12 +2,50 @@ $ErrorActionPreference = "Stop" $env:PATH = "C:\php\devel;C:\php\bin;C:\php\deps\bin;$env:PATH" +# Toolset +# $installerDir = Join-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio" 'Installer' +# $vswherePath = Join-Path $installerDir 'vswhere.exe' +# if (-not (Test-Path $vswherePath)) { +# if (-not (Test-Path $installerDir)) { +# New-Item -Path $installerDir -ItemType Directory -Force | Out-Null +# } +# $vsWhereUrl = 'https://github.com/microsoft/vswhere/releases/latest/download/vswhere.exe' +# Invoke-WebRequest -Uri $vsWhereUrl -OutFile $vswherePath -UseBasicParsing +# } +# if($null -eq (Get-Command vswhere -ErrorAction SilentlyContinue)) { +# throw "vswhere is not available" +# } +$MSVCDirectory = vswhere -latest -products * -find "VC\Tools\MSVC" +$selectedToolset = $null +$minor = $null +foreach ($toolset in (Get-ChildItem $MSVCDirectory)) { + $toolsetMajorVersion, $toolsetMinorVersion = $toolset.Name.split(".")[0,1] + $major = 14 + switch ($env:VS) { + 'vs17' { $minorMin = 30; $minorMax = $null; break } + 'vs16' { $minorMin = 20; $minorMax = 29; break } + Default { throw "VS version is not available" } + } + $majorVersionCheck = [int]$major -eq [int]$toolsetMajorVersion + $minorLowerBoundCheck = [int]$toolsetMinorVersion -ge [int]$minorMin + $minorUpperBoundCheck = ($null -eq $minorMax) -or ([int]$toolsetMinorVersion -le [int]$minorMax) + if ($majorVersionCheck -and $minorLowerBoundCheck -and $minorUpperBoundCheck) { + if($null -eq $minor -or [int]$toolsetMinorVersion -gt [int]$minor) { + $selectedToolset = $toolset.Name.Trim() + $minor = $toolsetMinorVersion + } + } +} +if (-not $selectedToolset) { + throw "toolset not available" +} + $task = New-Item 'task.bat' -Force Add-Content $task 'call phpize 2>&1' Add-Content $task "call configure --with-php-build=C:\php\deps --enable-$env:PHP_EXT --enable-debug-pack 2>&1" Add-Content $task 'nmake /nologo 2>&1' Add-Content $task 'exit %errorlevel%' -& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-$env:VS-$env:ARCH.bat" -t $task +& "C:\php\php-sdk-$env:BIN_SDK_VER\phpsdk-starter.bat" -c $env:VS -a $env:ARCH -s $selectedToolset -t $task if (-not $?) { throw "building failed with errorlevel $LastExitCode" } diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index a913087..3c425cb 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -41,7 +41,7 @@ jobs: - php: '8.1' vs: vs17 - runs-on: ${{ matrix.vs == 'vs17' && 'windows-2022' || 'windows-2019' }} + runs-on: windows-latest env: PHP_VER: ${{ matrix.php }} diff --git a/lz4.c b/lz4.c index 96d1a66..5e2b887 100644 --- a/lz4.c +++ b/lz4.c @@ -97,7 +97,8 @@ static PHP_MINIT_FUNCTION(lz4) { REGISTER_LONG_CONSTANT("LZ4_CLEVEL_MIN", PHP_LZ4_CLEVEL_MIN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("LZ4_CLEVEL_MAX", PHP_LZ4_CLEVEL_MAX, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("LZ4_VERSION", LZ4_versionNumber(), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("LZ4_VERSION_NUMBER", LZ4_versionNumber(), CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("LZ4_VERSION_TEXT", (char *)LZ4_versionString(), CONST_CS | CONST_PERSISTENT); #if PHP_MAJOR_VERSION >= 7 && defined(HAVE_APCU_SUPPORT) apc_register_serializer("lz4", @@ -114,27 +115,7 @@ ZEND_MINFO_FUNCTION(lz4) php_info_print_table_start(); php_info_print_table_row(2, "LZ4 support", "enabled"); php_info_print_table_row(2, "Extension Version", LZ4_EXT_VERSION); -#if !defined(HAVE_LIBLZ4) - /* Bundled library */ - php_info_print_table_row(2, "LZ4 Version", LZ4_versionString()); -#elif defined(LZ4_VERSION_MAJOR) - /* Recent system library */ - { - char buffer[128]; - - snprintf(buffer, sizeof(buffer), "%d.%d.%d", - LZ4_VERSION_MAJOR, LZ4_VERSION_MINOR, LZ4_VERSION_RELEASE); - php_info_print_table_row(2, "LZ4 headers Version", buffer); - - /* LZ4_versionString is not usable, see https://github.com/lz4/lz4/issues/301 */ - snprintf(buffer, sizeof(buffer), "%d.%d.%d", - LZ4_versionNumber()/10000, (LZ4_versionNumber()/100)%100, LZ4_versionNumber()%100); - php_info_print_table_row(2, "LZ4 library Version", buffer); - } -#else - /* Old system library */ - php_info_print_table_row(2, "LZ4 Version", "system library"); -#endif + php_info_print_table_row(2, "LZ4 Version", (char *)LZ4_versionString()); #if PHP_MAJOR_VERSION >= 7 && defined(HAVE_APCU_SUPPORT) php_info_print_table_row(2, "LZ4 APCu serializer ABI", APC_SERIALIZER_ABI); #endif diff --git a/lz4.stub.php b/lz4.stub.php index 40a42fc..7e91613 100644 --- a/lz4.stub.php +++ b/lz4.stub.php @@ -2,6 +2,31 @@ namespace { + /** + * @var int + * @cvalue LZ4_CLEVEL_MIN + */ + const LZ4_CLEVEL_MIN = UNKNOWN; + + /** + * @var int + * @cvalue LZ4_CLEVEL_MAX + */ + const LZ4_CLEVEL_MAX = UNKNOWN; + + /** + * @var string + * @cvalue LZ4_VERSION_TEXT + */ + const LZ4_VERSION_TEXT = UNKNOWN; + + /** + * @var int + * @cvalue LZ4_VERSION_NUMBER + */ + const LZ4_VERSION_NUMBER = UNKNOWN; + + function lz4_compress(string $data, int $level = 0, string $extra = NULL): string|false {} diff --git a/php_verdep.h b/php_verdep.h index 209d001..a6cfb0d 100644 --- a/php_verdep.h +++ b/php_verdep.h @@ -1,7 +1,7 @@ #ifndef PHP_VERDEP_H #define PHP_VERDEP_H -#ifndef ZED_FE_END +#ifndef ZEND_FE_END #define ZEND_FE_END { NULL, NULL, NULL, 0, 0 } #endif