diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index aa7d433f..00000000 --- a/.appveyor.yml +++ /dev/null @@ -1,159 +0,0 @@ -version: 1.3.7-{build} - -environment: - matrix: - - - PHP_VERSION: 7.0 - VC_VERSION: 14 - BUILD_TYPE: "Win32" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - VCVARSALL: "%VS120COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.0 - VC_VERSION: 14 - BUILD_TYPE: "nts-Win32" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - VCVARSALL: "%VS120COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.1 - VC_VERSION: 14 - BUILD_TYPE: "Win32" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - VCVARSALL: "%VS120COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.1 - VC_VERSION: 14 - BUILD_TYPE: "nts-Win32" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - VCVARSALL: "%VS120COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.2 - VC_VERSION: 15 - BUILD_TYPE: "Win32" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.2 - VC_VERSION: 15 - BUILD_TYPE: "nts-Win32" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.3 - VC_VERSION: 15 - BUILD_TYPE: Win32 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.3 - VC_VERSION: 15 - BUILD_TYPE: nts-Win32 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.4 - VC_VERSION: 15 - BUILD_TYPE: Win32 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 7.4 - VC_VERSION: 15 - BUILD_TYPE: nts-Win32 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat" - - - PHP_VERSION: 8.0 - VC_VERSION: 16 - BUILD_TYPE: Win32 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - VCVARSALL: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat" - - - PHP_VERSION: 8.0 - VC_VERSION: 16 - BUILD_TYPE: nts-Win32 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - VCVARSALL: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvarsall.bat" - - PHP_SDK_VERSION: 2.1.9 - PHP_AVM: https://raw.githubusercontent.com/sergeyklay/php-appveyor/master/php-appveyor.psm1 - - TEST_PHP_EXECUTABLE: C:\php\php.exe - NO_INTERACTION: 1 - REPORT_EXIT_STATUS: 1 - -matrix: - fast_finish: true - -cache: - - 'C:\Downloads -> .appveyor.yml' - -clone_depth: 1 -clone_folder: C:\Projects\php-zephir-parser - -platform: - - x86 - - x64 - -branches: - only: - - master - - development - -init: - - ps: $DebugPreference = 'SilentlyContinue' # Continue - -install: - - ps: (new-object Net.WebClient).DownloadString($Env:PHP_AVM) | iex - - - ps: InstallPhpSdk $Env:PHP_SDK_VERSION $Env:VC_VERSION $Env:PLATFORM - - ps: InstallPhp $Env:PHP_VERSION $Env:BUILD_TYPE $Env:VC_VERSION $Env:PLATFORM - - ps: InstallPhpDevPack $Env:PHP_VERSION $Env:BUILD_TYPE $Env:VC_VERSION $Env:PLATFORM - - - ps: Import-Module .\.ci\AppVeyor.psm1 - - ps: AppendSessionPath - - ps: TuneUpPhp - -build_script: - - if NOT "%VCVARSALL%" == "" call "%VCVARSALL%" %PLATFORM% - - ps: InitializeBuildVars - - phpsdk_setvars - - cmd /c .ci\build-win32.bat - - phpize - - cmd: 'configure --with-prefix=C:\php --with-php-build=C:\php-devpack --disable-all --enable-zephir-parser=shared' - - cmd: nmake 2> compile-errors.log 1> compile.log - - ps: InitializeReleaseVars - -test_script: - - ps: >- - EnablePhpExtension ` - -Name zephir_parser ` - -PrintableName "Zephir Parser" ` - -ExtPath $Env:RELEASE_PATH - -after_test: - - ps: >- - PrepareReleasePackage ` - -PhpVersion $Env:PHP_VERSION ` - -BuildType $Env:BUILD_TYPE ` - -Platform $Env:PLATFORM ` - -ConverMdToHtml $true ` - -ReleaseFiles "${Env:RELEASE_PATH}\php_zephir_parser.dll",` - "${Env:APPVEYOR_BUILD_FOLDER}\LICENSE",` - "${Env:APPVEYOR_BUILD_FOLDER}\CREDITS",` - "${Env:APPVEYOR_BUILD_FOLDER}\VERSION",` - "${Env:APPVEYOR_BUILD_FOLDER}\NO_WARRANTY" - -artifacts: - - path: '.\$(RELEASE_ZIPBALL).zip' - type: zip - name: ZephirParser - -on_failure: - - ps: >- - if (Test-Path -Path "${Env:APPVEYOR_BUILD_FOLDER}\compile-errors.log") { - Get-Content -Path "${Env:APPVEYOR_BUILD_FOLDER}\compile-errors.log" - } - if (Test-Path -Path "${Env:APPVEYOR_BUILD_FOLDER}\compile.log") { - Get-Content -Path "${Env:APPVEYOR_BUILD_FOLDER}\compile.log" - } diff --git a/.ci/AppVeyor.psm1 b/.ci/AppVeyor.psm1 deleted file mode 100644 index d4887f7b..00000000 --- a/.ci/AppVeyor.psm1 +++ /dev/null @@ -1,75 +0,0 @@ -# This file is part of the Zephir Parser. -# -# (c) Zephir Team -# -# For the full copyright and license information, please view -# the LICENSE file that was distributed with this source code. - -Function InitializeBuildVars { - If ($Env:PLATFORM -eq 'x64') { - $Env:ARCH = 'x86_amd64' - } Else { - $Env:ARCH = 'x86' - } -} - -Function InitializeReleaseVars { - If ($Env:BUILD_TYPE -Match "nts-Win32") { - $Env:RELEASE_ZIPBALL = "zephir_parser_${Env:PLATFORM}_vc${Env:VC_VERSION}_php${Env:PHP_VERSION}-nts_${Env:APPVEYOR_BUILD_VERSION}" - - If ($Env:PLATFORM -eq 'x86') { - $Env:RELEASE_FOLDER = "Release" - } Else { - $Env:RELEASE_FOLDER = "x64\Release" - } - } Else { - $Env:RELEASE_ZIPBALL = "zephir_parser_${Env:PLATFORM}_vc${Env:VC_VERSION}_php${Env:PHP_VERSION}_${Env:APPVEYOR_BUILD_VERSION}" - - If ($Env:PLATFORM -eq 'x86') { - $Env:RELEASE_FOLDER = "Release_TS" - } Else { - $Env:RELEASE_FOLDER = "x64\Release_TS" - } - } - - $Env:RELEASE_PATH = "${Env:APPVEYOR_BUILD_FOLDER}\${Env:RELEASE_FOLDER}" -} - -Function AppendSessionPath { - [string[]] $PathsCollection = @( - "${Env:VSCOMNTOOLS}\..\..\VC", - "C:\Program Files (x86)\Microsoft Visual Studio ${Env:VC_VERSION}.0\VC", - "C:\Program Files (x86)\Microsoft Visual Studio ${Env:VC_VERSION}.0\VC\bin", - "${Env:VSCOMNTOOLS}", - "C:\php" - "C:\php\bin" - "C:\php-sdk\bin", - "C:\php-devpack" - ) - - $CurrentPath = (Get-Item -Path ".\" -Verbose).FullName - - ForEach ($PathItem In $PathsCollection) { - Set-Location Env: - $AllPaths = (Get-ChildItem Path).value.split(";") | Sort-Object -Unique - $AddToPath = $true - - ForEach ($AddedPath In $AllPaths) { - If (-not "${AddedPath}") { - continue - } - - $AddedPath = $AddedPath -replace '\\$', '' - - If ($PathItem -eq $AddedPath) { - $AddToPath = $false - } - } - - If ($AddToPath) { - $Env:Path += ";$PathItem" - } - } - - Set-Location "${CurrentPath}" -} diff --git a/.ci/build-win32.bat b/.ci/build-win32.bat deleted file mode 100644 index 34bc2110..00000000 --- a/.ci/build-win32.bat +++ /dev/null @@ -1,19 +0,0 @@ -@ECHO off - -REM This file is part of the Zephir Parser. -REM -REM (c) Zephir Team -REM -REM For the full copyright and license information, please view -REM the LICENSE file that was distributed with this source code. - -REM Rewrite this using PowerShell -CD parser - -cl lemon.c -DEL zephir.c zephir.h parser.c scanner.c -re2c -o scanner.c scanner.re -lemon -s zephir.lemon -ECHO #include ^ > parser.c -TYPE zephir.c >> parser.c -TYPE base.c >> parser.c diff --git a/.ci/lemon-parser.ps1 b/.ci/lemon-parser.ps1 new file mode 100644 index 00000000..567654c7 --- /dev/null +++ b/.ci/lemon-parser.ps1 @@ -0,0 +1,45 @@ +# This file is part of the Zephir Parser. +# +# (c) Zephir Team +# +# For the full copyright and license information, please view +# the LICENSE file that was distributed with this source code. + +Write-Output "-- Compiling Lemon parser..." +$LemonSrc = Join-Path -Path './parser' -ChildPath 'lemon.c' +$LemonBin = Join-Path -Path './parser' -ChildPath 'lemon.exe' + +if ($IsWindows) { + & cl /Fe${LemonExe} ${LemonSrc} +} +else { + $LemonBin = Join-Path -Path './parser' -ChildPath 'lemon' + & gcc ${LemonSrc} -o ${LemonBin} +} +& ${LemonBin} -x + +Write-Output "-- Cleanup initial file state..." + +$AutoFiles = "./parser/zephir.c", + "./parser/zephir.h", + "./parser/parser.c", + "./parser/scanner.c" + +foreach ($GeneratedFile in $AutoFiles) { + if (Test-Path -Path $GeneratedFile) { + Remove-Item $GeneratedFile + } +} + +Write-Output "-- Run re2c..." +& re2c -o (Join-Path -Path './parser' -ChildPath 'scanner.c') (Join-Path -Path './parser' -ChildPath 'scanner.re') + +Write-Output "-- Generating zephir.c file with lemon parser..." +& ${LemonBin} -s (Join-Path -Path './parser' -ChildPath 'zephir.lemon') + +Write-Output "-- Generating parser.c file..." +$ParserC = Join-Path -Path './parser' -ChildPath 'parser.c' +$ZephirC = Join-Path -Path './parser' -ChildPath 'zephir.c' +$BaseC = Join-Path -Path './parser' -ChildPath 'base.c' +Set-Content -Path ${ParserC} -Value '#include ' +Get-Content ${ZephirC}, ${BaseC} | Add-Content ${ParserC} diff --git a/.ci/release-notes.sh b/.ci/release-notes.sh new file mode 100755 index 00000000..03492db3 --- /dev/null +++ b/.ci/release-notes.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# This file is part of the Zephir Parser. +# +# (c) Zephir Team +# +# For the full copyright and license information, please view +# the LICENSE file that was distributed with this source code. + + +# -e Exit immediately if a command exits with a non-zero status. +# -u Treat unset variables as an error when substituting. + +set -eu +set -o pipefail + +# Get Release notes for the latest release from CHANGELOG.md +# How to use: +# release-notes.sh CHANGELOG.md + +startline=$(cat "$1" | grep -nE '^### ' | head -n 1 | cut -d ":" -f 1) +finishline=$(($(cat "$1" | grep -nE '^## \[[0-9]+' | head -n 2 | tail -n 1 | cut -d ":" -f 1) - 1)) +changelog=$(sed -n "${startline},${finishline}p" "$1"); + + +: "${GITHUB_ACTIONS:=0}" + +if [ "$GITHUB_ACTIONS" = "true" ] +then + changelog="${changelog//'%'/'%25'}" + changelog="${changelog//$'\n'/'%0A'}" + changelog="${changelog//$'\r'/'%0D'}" +fi + +echo "${changelog}" diff --git a/.ci/win-ci-tools.psm1 b/.ci/win-ci-tools.psm1 new file mode 100644 index 00000000..19869b11 --- /dev/null +++ b/.ci/win-ci-tools.psm1 @@ -0,0 +1,417 @@ +# This file is part of the Zephir Parser. +# +# (c) Zephir Team +# +# For the full copyright and license information, please view +# the LICENSE file that was distributed with this source code. + +function SetupCommonEnvironment { + <# + .SYNOPSIS + Creates common directories if not exists + #> + + $CommonPath = "C:\Downloads", "C:\Downloads\Choco" + + foreach ($path in $CommonPath) { + if (-not (Test-Path $path)) { + New-Item -ItemType Directory -Force -Path $path | Out-Null + } + } + + # Hide "You are in 'detached HEAD' state" message + git config --global advice.detachedHead false +} + +function InitializeReleaseVars { + <# + .SYNOPSIS + Configures Environment variables for Release build. + #> + + # Build artifacts should be names like this: + # zephir-parser-php-7.0-nts-win32-vc14-x86.zip + # zephir-parser-php-7.0-ts-win32-vc14-x64.zip + + $VC_Prefix = "vc" + if (${env:VC_VERSION} -ge 16) { + $VC_Prefix = "vc" + } + + # Configure for Windows define `BUILD_DIR` using the next logic: + # + # Release ZTS x86 => Release_TS\php_zephir_parser.dll + # Release NTS x86 => Release\php_zephir_parser.dll + # Release ZTS x64 => x64\Release_TS\php_zephir_parser.dll + # Release NTS x64 => x64\Release\php_zephir_parser.dll + + $env:RELEASE_FOLDER = "Release" + if (${env:BUILD_TYPE} -eq 'ts') { + $env:RELEASE_FOLDER = -join($env:RELEASE_FOLDER, "_TS") + } + + if (${env:PHP_ARCH} -eq 'x64') { + $env:RELEASE_FOLDER = -join("x64\", $env:RELEASE_FOLDER) + } + + $env:RELEASE_DLL_PATH = "${env:GITHUB_WORKSPACE}\${env:RELEASE_FOLDER}\${env:EXTENSION_FILE}" + $env:RELEASE_ZIPBALL = "zephir-parser-php-${env:PHP_MINOR}-${env:BUILD_TYPE}-win32-${VC_Prefix}${env:VC_VERSION}-${env:PHP_ARCH}" + + Write-Output "RELEASE_FOLDER=${env:RELEASE_FOLDER}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "RELEASE_ZIPBALL=${env:RELEASE_ZIPBALL}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "RELEASE_DLL_PATH=${env:RELEASE_DLL_PATH}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append +} + +function InstallPhpSdk { + <# + .SYNOPSIS + Install PHP SDK binary tools from sources. + #> + + Write-Output "Install PHP SDK binary tools: ${env:PHP_SDK_VERSION}" + + $PhpSdk = "php-sdk-${env:PHP_SDK_VERSION}.zip" + $RemoteUrl = "https://github.com/microsoft/php-sdk-binary-tools/archive/${PhpSdk}" + $DestinationPath = "C:\Downloads\${PhpSdk}" + + if (-not (Test-Path $env:PHP_SDK_PATH)) { + if (-not [System.IO.File]::Exists($DestinationPath)) { + Write-Output "Downloading PHP SDK binary tools: $RemoteUrl ..." + DownloadFile $RemoteUrl $DestinationPath + } + + $DestinationUnzipPath = "${env:Temp}\php-sdk-binary-tools-php-sdk-${env:PHP_SDK_VERSION}" + + if (-not (Test-Path "$DestinationUnzipPath")) { + Expand-Item7zip $DestinationPath $env:Temp + } + + Move-Item -Path $DestinationUnzipPath -Destination $env:PHP_SDK_PATH + } +} + +function InstallPhpDevPack { + <# + .SYNOPSIS + Intstall PHP Developer pack from sources. + #> + + Write-Output "Install PHP Dev pack: ${env:PHP_VERSION}" + + $TS = Get-ThreadSafety + + if ($env:VC_VERSION -gt 15) { + $VSPrefix = "VS" + $VSPrefixSmall = "vs" + } else { + $VSPrefix = "VC" + $VSPrefixSmall = "vc" + } + + $BaseUrl = "http://windows.php.net/downloads/releases" + $DevPack = "php-devel-pack-${env:PHP_VERSION}${TS}-Win32-${VSPrefixSmall}${env:VC_VERSION}-${env:PHP_ARCH}.zip" + + $RemoteUrl = "${BaseUrl}/${DevPack}" + $RemoteArchiveUrl = "${BaseUrl}/archives/${DevPack}" + $DestinationPath = "C:\Downloads\php-devel-pack-${env:PHP_VERSION}${TS}-${VSPrefix}${env:VC_VERSION}-${env:PHP_ARCH}.zip" + + if (-not (Test-Path $env:PHP_DEVPACK)) { + if (-not [System.IO.File]::Exists($DestinationPath)) { + DownloadFileUsingAlternative -RemoteUrl $RemoteUrl ` + -RemoteArchiveUrl $RemoteArchiveUrl ` + -DestinationPath $DestinationPath ` + -Message "Downloading PHP Dev pack" + } + + $DestinationUnzipPath = "${env:Temp}\php-${env:PHP_VERSION}-devel-${VSPrefix}${env:VC_VERSION}-${env:PHP_ARCH}" + + if (-not (Test-Path "$DestinationUnzipPath")) { + Expand-Item7zip $DestinationPath $env:Temp + } + + Move-Item -Path $DestinationUnzipPath -Destination $env:PHP_DEVPACK + } +} + +function DownloadFileUsingAlternative { + <# + .SYNOPSIS + Downloads files from URL using alternative ULR if primary URL not found + #> + + [CmdletBinding()] + param( + [parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateNotNullOrEmpty()] [System.String] $RemoteUrl, + [parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateNotNullOrEmpty()] [System.String] $RemoteArchiveUrl, + [parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateNotNullOrEmpty()] [System.String] $DestinationPath, + [parameter(Mandatory = $true, ValueFromPipeline = $true)] [ValidateNotNullOrEmpty()] [System.String] $Message + ) + + process { + try { + Write-Output "${Message}: ${RemoteUrl} ..." + DownloadFile $RemoteUrl $DestinationPath + } catch [System.Net.WebException] { + Write-Output "${Message} from archive: ${RemoteArchiveUrl} ..." + DownloadFile $RemoteArchiveUrl $DestinationPath + } + } +} + +function DownloadFile { + <# + .SYNOPSIS + Downloads file from providing URL to specified destionation. + + .NOTES + Throws System.Net.WebException if $RequestUrl not found. + #> + + [CmdletBinding()] + param( + [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.String] $RemoteUrl, + [parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.String] $DestinationPath + ) + + process { + $RetryMax = 5 + $RetryCount = 0 + $Completed = $false + + $WebClient = New-Object System.Net.WebClient + $WebClient.Headers.Add('User-Agent', 'GitHub Actions PowerShell Script') + + while (-not $Completed -or $RetryCount -eq $RetryMax) { + try { + $WebClient.DownloadFile($RemoteUrl, $DestinationPath) + $Completed = $true + } catch [System.Net.WebException] { + $ErrorMessage = $_.Exception.Message + + if ($_.Exception.Response.StatusCode -eq 404) { + Write-Warning -Message "Error downloading ${RemoteUrl}: $ErrorMessage" + throw [System.Net.WebException] "Error downloading ${RemoteUrl}" + } + + if ($RetryCount -ge $RetryMax) { + Write-Output "Error downloading ${RemoteUrl}: $ErrorMessage" + $Completed = $true + } else { + $RetryCount++ + } + } + } + } +} + +function Expand-Item7zip { + <# + .SYNOPSIS + Extracts ZIP archives to specified directory + #> + + param( + [Parameter(Mandatory = $true)] [System.String] $Archive, + [Parameter(Mandatory = $true)] [System.String] $Destination + ) + + if (-not (Test-Path -Path $Archive -PathType Leaf)) { + throw "Specified archive File is invalid: [$Archive]" + } + + if (-not (Test-Path -Path $Destination -PathType Container)) { + New-Item $Destination -ItemType Directory | Out-Null + } + + $Result = (& 7z x "$Archive" "-o$Destination" -aoa -bd -y -r) + + if ($LastExitCode -ne 0) { + Write-Output "An error occurred while unzipping [$Archive] to [$Destination]. Error code was: ${LastExitCode}" + Exit $LastExitCode + } +} + +function Get-ThreadSafety { + <# + .SYNOPSIS + Detects if Build is Thread Safety or not and returns `ts` suffix. + #> + + if ($env:BUILD_TYPE -Match "nts") { + return "-nts" + } + + return [string]::Empty +} + +function AppendSessionPath { + [string[]] $PathsCollection = @( + "${Env:VSCOMNTOOLS}\..\..\VC", + "C:\Program Files (x86)\Microsoft Visual Studio ${Env:VC_VERSION}.0\VC", + "C:\Program Files (x86)\Microsoft Visual Studio ${Env:VC_VERSION}.0\VC\bin", + "${Env:VSCOMNTOOLS}", + "C:\php" + "C:\php\bin" + "C:\php-sdk\bin", + "C:\php-devpack" + ) + + $CurrentPath = (Get-Item -Path ".\" -Verbose).FullName + + ForEach ($PathItem In $PathsCollection) { + Set-Location Env: + $AllPaths = (Get-ChildItem Path).value.split(";") | Sort-Object -Unique + $AddToPath = $true + + ForEach ($AddedPath In $AllPaths) { + If (-not "${AddedPath}") { + continue + } + + $AddedPath = $AddedPath -replace '\\$', '' + + If ($PathItem -eq $AddedPath) { + $AddToPath = $false + } + } + + If ($AddToPath) { + $Env:Path += ";$PathItem" + } + } + + Set-Location "${CurrentPath}" +} + +function EnableExtension { + <# + .SYNOPSIS + Enables PHP Extension. + #> + + if (-not (Test-Path env:RELEASE_DLL_PATH)) { + InitializeReleaseVars + } + + if (-not (Test-Path "${env:RELEASE_DLL_PATH}")) { + throw "Unable to locate extension path: ${env:RELEASE_DLL_PATH}" + } + + Copy-Item -Path "${env:RELEASE_DLL_PATH}" -Destination "${env:PHPROOT}\ext\" + + Enable-PhpExtension -Extension 'Zephir Parser' -Path "${env:PHPROOT}" +} + +function PrepareReleasePackage { + param ( + [Parameter(Mandatory=$true)] [System.String] $PhpVersion, + [Parameter(Mandatory=$true)] [System.String] $BuildType, + [Parameter(Mandatory=$true)] [System.String] $Platform, + [Parameter(Mandatory=$false)] [System.String] $ZipballName = '', + [Parameter(Mandatory=$false)] [System.String[]] $ReleaseFiles = @(), + [Parameter(Mandatory=$false)] [System.String] $ReleaseFile = 'RELEASE.txt', + [Parameter(Mandatory=$false)] [System.Boolean] $ConvertMd2Html = $false, + [Parameter(Mandatory=$false)] [System.String] $BasePath = '.' + ) + + $BasePath = Resolve-Path $BasePath + $ReleaseDirectory = "${Env:GITHUB_ACTOR}-${Env:RUNNER_OS}-${Env:GITHUB_JOB}-${Env:GITHUB_RUN_NUMBER}" + + Write-Output "ReleaseDirectory: ${ReleaseDirectory}" + + PrepareReleaseNote ` + -PhpVersion $PhpVersion ` + -BuildType $BuildType ` + -Platform $Platform ` + -ReleaseFile $ReleaseFile ` + -ReleaseDirectory $ReleaseDirectory ` + -BasePath $BasePath + + $ReleaseDestination = "${BasePath}\${ReleaseDirectory}" + + $CurrentPath = Resolve-Path '.' + + if ($ConvertMd2Html) { + FormatReleaseFiles -ReleaseDirectory $ReleaseDirectory + } + + if ($ReleaseFiles.count -gt 0) { + foreach ($File in $ReleaseFiles) { + Copy-Item "${File}" "${ReleaseDestination}" + Write-Debug "Copy ${File} to ${ReleaseDestination}" + } + } + + if (!$ZipballName) { + if (!$Env:RELEASE_ZIPBALL) { + throw "Required parameter `"ZipballName`" is missing" + } else { + $ZipballName = $Env:RELEASE_ZIPBALL; + } + } + + Set-Location "${ReleaseDestination}" + $Output = (& 7z a "${ZipballName}.zip" *) + $ExitCode = $LASTEXITCODE + + $DirectoryContents = Get-ChildItem -Path "${ReleaseDestination}" + Write-Debug ($DirectoryContents | Out-String) + + if ($ExitCode -ne 0) { + Set-Location "${CurrentPath}" + throw "An error occurred while creating release zipball: `"${ZipballName}`". ${Output}" + } + + Move-Item "${ZipballName}.zip" -Destination "${BasePath}" + Write-Output "Release file created: ${BasePath}\${ZipballName}.zip" + Set-Location "${CurrentPath}" +} + +function PrepareReleaseNote { + param ( + [Parameter(Mandatory=$true)] [System.String] $PhpVersion, + [Parameter(Mandatory=$true)] [System.String] $BuildType, + [Parameter(Mandatory=$true)] [System.String] $Platform, + [Parameter(Mandatory=$false)] [System.String] $ReleaseFile, + [Parameter(Mandatory=$false)] [System.String] $ReleaseDirectory, + [Parameter(Mandatory=$false)] [System.String] $BasePath + ) + + $Destination = "${BasePath}\${ReleaseDirectory}" + + if (-not (Test-Path $Destination)) { + New-Item -ItemType Directory -Force -Path "${Destination}" | Out-Null + } + + $ReleaseFile = "${Destination}\${ReleaseFile}" + $ReleaseDate = Get-Date -Format o + + $Version = Get-Content (Join-Path -Path ${BasePath} -ChildPath 'VERSION') -First 1 + + Write-Output "Release date: ${ReleaseDate}" | Out-File -Encoding "ASCII" -Append "${ReleaseFile}" + Write-Output "Release version: ${Version}" | Out-File -Encoding "ASCII" -Append "${ReleaseFile}" + Write-Output "Git commit: ${Env:GITHUB_SHA}" | Out-File -Encoding "ASCII" -Append "${ReleaseFile}" + Write-Output "Build type: ${BuildType}" | Out-File -Encoding "ASCII" -Append "${ReleaseFile}" + Write-Output "Platform: ${Platform}" | Out-File -Encoding "ASCII" -Append "${ReleaseFile}" + Write-Output "Target PHP version: ${PhpVersion}" | Out-File -Encoding "ASCII" -Append "${ReleaseFile}" +} + +function FormatReleaseFiles { + param ( + [Parameter(Mandatory=$true)] [System.String] $ReleaseDirectory, + [Parameter(Mandatory=$false)] [System.String] $BasePath = '.' + ) + + $CurrentPath = (Get-Item -Path ".\" -Verbose).FullName + + $BasePath = Resolve-Path $BasePath + Set-Location "${BasePath}" + + Get-ChildItem (Get-Item -Path ".\" -Verbose).FullName *.md | + ForEach-Object{ + $BaseName = $_.BaseName + pandoc -f markdown -t html5 "${BaseName}.md" > "${BasePath}\${ReleaseDirectory}\${BaseName}.html" + } + + Set-Location "${CurrentPath}" +} diff --git a/.editorconfig b/.editorconfig index b5023d03..e5cfdb0b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ indent_size = 4 charset = utf-8 trim_trailing_whitespace = true -[*.{yml,m4,sh,md,php,phpt,xml,json,w32}] +[*.{yml,m4,sh,md,php,phpt,xml,json,w32,ps1,psm1}] indent_style = space [*.{yml,m4,sh}] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..16570bc0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,403 @@ +name: Zephir Parser CI + +on: + schedule: + - cron: '0 2 * * *' # Daily at 02:00 runs only on default branch + push: + branches-ignore: + - 'wip-*' + paths-ignore: + - '*.md' + pull_request: + paths-ignore: + - '*.md' + branches: + - master + - development + +env: + RE2C_VERSION: 2.2 + PHP_SDK_VERSION: 2.2.0 + PHP_DEVPACK: C:\tools\php-devpack + PHP_SDK_PATH: C:\tools\php-sdk + EXTENSION_FILE: php_zephir_parser.dll + +jobs: + windows-builds: + # To prevent build a particular commit use + # git commit -m "......... [win skip] - skip Windows builds only" + # git commit -m "......... [ci skip] - skip all builds" + if: "!contains(github.event.head_commit.message, '[win skip]') || !contains(github.event.head_commit.message, '[ci skip]') " + + strategy: + fail-fast: false + + matrix: + php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + arch: ['x86', 'x64'] + build_type: ['ts', 'nts'] + + include: + - php: '7.0' + vc_num: 14 + vc_prefix: 'vc' + os: windows-2016 + + - php: '7.1' + vc_num: 14 + vc_prefix: 'vc' + os: windows-2016 + + - php: '7.2' + vc_num: 15 + vc_prefix: 'vc' + os: windows-2016 + + - php: '7.3' + vc_num: 15 + vc_prefix: 'vc' + os: windows-2016 + + - php: '7.4' + vc_num: 15 + vc_prefix: 'vc' + os: windows-2016 + + - php: '8.0' + vc_num: 16 + vc_prefix: 'vs' + os: windows-2019 + + name: "PHP-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}" + runs-on: ${{ matrix.os}} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + env: + PHPTS: ${{ matrix.build_type }} + + - name: Set Environment Variables + run: | + Write-Output "PHP_VERSION=$(php -r 'echo phpversion();')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "PHP_MINOR=${{ matrix.php }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "TEST_PHP_EXECUTABLE=${env:PHPROOT}\php.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "BUILD_TYPE=${{ matrix.build_type }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "VC_VERSION=${{ matrix.vc_num }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "PHP_ARCH=${{ matrix.arch }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + Write-Output "BUILD_VERSION=${env:GITHUB_RUN_NUMBER}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Setup Common Environmet + run: | + Import-Module .\.ci\win-ci-tools.psm1 + SetupCommonEnvironment + InitializeReleaseVars + + - name: Cache Downloads + uses: actions/cache@v2 + with: + path: C:\Downloads + key: ${{ runner.os }}-zephir_parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }} + + - name: Install System Dependencies + run: | + choco install -y --no-progress --cache-location=C:\Downloads\Choco pandoc + + - name: Install PHP SDK Binary Tools + run: | + Import-Module .\.ci\win-ci-tools.psm1 + InstallPhpSdk + + - name: Install PHP Dev pack + run: | + Import-Module .\.ci\win-ci-tools.psm1 + InstallPhpDevPack + + - name: Install MSVC Compiler Tool + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + + - name: Set PHP SDK Environment variables + shell: cmd + run: | + call C:\tools\php-sdk\phpsdk-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.bat + call C:\tools\php-sdk\bin\phpsdk_setvars.bat + + - name: Parse Zephir Parser (Lemon) + shell: cmd + run: | + call C:\tools\php-sdk\bin\phpsdk_setvars.bat + powershell.exe -File .\.ci\lemon-parser.ps1 + + - name: Phpize + shell: cmd + run: | + call C:\tools\php-devpack\phpize.bat + + - name: Configure + shell: cmd + run: | + call C:\tools\php-sdk\phpsdk-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.bat + call C:\tools\php-sdk\bin\phpsdk_setvars.bat + configure --with-codegen-arch=yes --with-prefix=C:\php --with-php-build=C:\php-devpack --disable-all --enable-zephir-parser=shared + + - name: Compile + shell: cmd + run: | + call C:\tools\php-sdk\phpsdk-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.bat + call C:\tools\php-sdk\bin\phpsdk_setvars.bat + nmake + + - name: Get Zephir Parser extension info + run: | + Get-Php "${env:PHPROOT}" + Get-PhpExtension "${env:RELEASE_DLL_PATH}" + & ${env:TEST_PHP_EXECUTABLE} --ini + + - name: Enable Zephir Parser + run: | + Add-Content -Path "${env:PHPROOT}\php.ini" -Value 'extension=php_zephir_parser.dll' + Copy-Item -Path "${env:RELEASE_DLL_PATH}" -Destination "${env:PHPROOT}\ext\" + + # Run tests only for x64 PHP builds (Windows currently not support setup php with multi arch) + - name: Run Tests + if: matrix.arch == 'x64' + run: | + & ${env:TEST_PHP_EXECUTABLE} --ri 'Zephir Parser' + & ${env:TEST_PHP_EXECUTABLE} run-tests.php + + - name: Prepare Release Package + run: | + Import-Module .\.ci\win-ci-tools.psm1 + PrepareReleasePackage ` + -PhpVersion $Env:PHP_VERSION ` + -BuildType $Env:BUILD_TYPE ` + -Platform $Env:PLATFORM ` + -ZipballName $Env:RELEASE_ZIPBALL ` + -ConvertMd2Html $true ` + -ReleaseFiles "${Env:RELEASE_DLL_PATH}",` + "${Env:GITHUB_WORKSPACE}\LICENSE",` + "${Env:GITHUB_WORKSPACE}\CREDITS",` + "${Env:GITHUB_WORKSPACE}\VERSION",` + "${Env:GITHUB_WORKSPACE}\NO_WARRANTY" + + - name: Upload Zephir Parser + uses: actions/upload-artifact@v2 + with: + name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.zip + path: | + ${{ github.workspace }}\zephir-parser-*.zip + + - name: Check for Errors + if: always() + run: | + Get-ChildItem (Get-Item -Path ".\" -Verbose).FullName *.log | + ForEach-Object{ + $BaseName = $_.BaseName + Write-Output "-- Log details: ${BaseName}.log --" + Get-Content -Path "${env:GITHUB_WORKSPACE}\${BaseName}.log" + } + + - name: Upload Info for Debug on Fail + if: failure() + uses: actions/upload-artifact@v2 + with: + retention-days: 2 + name: errors-zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }} + path: | + ${{ github.workspace }}\tests + ${{ github.workspace }}\parser + ${{ github.workspace }}\Release* + ${{ github.workspace }}\**\Release* + + unix-builds: + # To prevent build a particular commit use + # git commit -m "......... [unix skip] - skip Linux & macOS builds only" + # git commit -m "......... [ci skip] - skip all builds" + if: "!contains(github.event.head_commit.message, '[unix skip]') || !contains(github.event.head_commit.message, '[ci skip]') " + + strategy: + fail-fast: false + + matrix: + php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + arch: ['x64'] + build_type: ['nts'] + name: + - ubuntu + - macos + + include: + - name: ubuntu + os: ubuntu-18.04 + ccov: ON + compiler: gcc + + - name: macos + os: macos-latest + ccov: OFF + compiler: clang + + name: "PHP-${{ matrix.php }}-${{ matrix.build_type }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}" + runs-on: ${{ matrix.os }} + + env: + HOMEBREW_NO_INSTALL_CLEANUP: 1 + ZEND_DONT_UNLOAD_MODULES: 1 + USE_ZEND_ALLOC: 0 + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 5 + + - name: Install PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php }}' + coverage: none + env: + PHPTS: ${{ matrix.build_type }} + + - name: Cache RE2C Downloads + uses: actions/cache@v2 + with: + path: ~/.cache/re2c + key: ${{ runner.os }}-php-${{ matrix.php }}-re2c-${{env.RE2C_VERSION}} + + - name: Setup Prerequisites (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update --quiet --yes 1>/dev/null + sudo apt-get install --no-install-recommends --quiet --yes lcov gdb + + - name: Setup Prerequisites (macOS) + if: runner.os == 'macOS' && matrix.ccov == 'ON' + run: | + brew install lcov + sudo xcode-select -switch /Applications/Xcode.app + + - name: Setup Build System (Generic) + run: | + ulimit -c unlimited -S || true + + mkdir -p $HOME/.cache/re2c + mkdir -p $HOME/.local/opt/re2c + + echo "PATH=$PATH:$HOME/bin:$(brew --prefix lcov)/bin" >> $GITHUB_ENV + echo "MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN)" >> $GITHUB_ENV + echo "CI=true" >> $GITHUB_ENV + echo "ZEPHIR_PARSER_VERSION=$(head -1 VERSION)" >> $GITHUB_ENV + + - name: Setup Core Dump (Linux) + if: runner.os == 'Linux' + run: echo '/tmp/core.%e.%p.%t' | sudo tee /proc/sys/kernel/core_pattern + + - name: Install re2c + run: .ci/install-re2c.sh + + - name: Build extensions + run: | + phpize + + if [ "${{ matrix.ccov }}" = "ON" ]; then + ./configure \ + --enable-zephir-parser \ + --enable-zephir-parser-debug \ + --enable-coverage + else + ./configure \ + --enable-zephir-parser \ + --enable-zephir-parser-debug + fi + + make -j$(getconf _NPROCESSORS_ONLN) + + - name: Preparing to collect coverage data + if: matrix.ccov == 'ON' + run: make coverage-initial + + - name: Run Tests + run: | + php -d extension=./modules/zephir_parser.so --ri 'Zephir Parser' + make test NO_INTERACTION=1 REPORT_EXIT_STATUS=1 + + - name: Print failures + if: failure() && runner.os == 'Linux' + run: .ci/after-failure.sh + + - name: Capture coverage data + if: success() && matrix.ccov == 'ON' + run: make coverage-capture + + - name: Prepare Build Artifacts + working-directory: modules + run: | + echo "-- Creating ZIP with Zephir Parser extension" + zip -rv zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}.zip ./*.so + + - name: Upload code coverage report + if: matrix.ccov == 'ON' + uses: codecov/codecov-action@v1 + with: + token: ${{secrets.CODECOV_TOKEN}} + file: ./lcov.info + flags: unittests + fail_ci_if_error: false + + - name: Upload Zephir Parser + uses: actions/upload-artifact@v2 + with: + name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.arch }}.zip + path: | + ${{ github.workspace }}/modules/*.zip + + release: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + + needs: [windows-builds, unix-builds] + name: Create Release + runs-on: ubuntu-20.04 + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: Get the release version + id: get-version + run: | + echo ::set-output name=version::${GITHUB_REF#refs/tags/} + + - name: Download Zephir Parser build artifacts + id: download + uses: actions/download-artifact@v2 + with: + path: ./build-artifacts + + - name: Prepare Release assets + run: | + mkdir -p ./build-artifacts/release + find ./build-artifacts -type f -name zephir-parser*.zip -exec cp {} ./build-artifacts/release/ ";" + echo "-- Creating Release Notes" + GITHUB_ACTIONS=false ./.ci/release-notes.sh ./CHANGELOG.md > ./build-artifacts/release/release-notes.md + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: ${{ steps.get-version.outputs.version }} + tag: ${{ steps.get-version.outputs.version }} + bodyFile: "./build-artifacts/release/release-notes.md" + allowUpdates: true + artifacts: "./build-artifacts/release/*.zip" + artifactContentType: application/octet-stream diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index a416d5e7..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,134 +0,0 @@ -name: build - -on: - push: - branches-ignore: - - 'wip-*' - paths-ignore: - - '*.md' - pull_request: - branches: - - master - - development - schedule: - - cron: '0 11 * * *' - -jobs: - ci: - strategy: - fail-fast: false - - matrix: - re2c: - - '0.13.6' - - '1.3' - php: - - '7.0' - - '7.1' - - '7.3' - - '7.4' - - '8.0' - name: - - Ubuntu - - macOS - - include: - - name: Ubuntu - os: ubuntu-18.04 - ccov: ON - - - name: macOS - os: macos-latest - ccov: OFF - - name: "${{ matrix.name }}: PHP ${{ matrix.php }}, re2c ${{ matrix.re2c }}" - runs-on: ${{ matrix.os }} - - env: - ZEND_DONT_UNLOAD_MODULES: 1 - USE_ZEND_ALLOC: 0 - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 5 - - - name: Install PHP ${{ matrix.php }} - uses: shivammathur/setup-php@v2 - with: - php-version: '${{ matrix.php }}' - coverage: none - - - name: Setup Prerequisites (Linux) - if: runner.os == 'Linux' - run: | - sudo apt-get update --quiet --yes 1>/dev/null - sudo apt-get install --no-install-recommends --quiet --yes lcov gdb - - - name: Setup Prerequisites (macOS) - if: runner.os == 'macOS' && matrix.ccov == 'ON' - run: | - brew install lcov - sudo xcode-select -switch /Applications/Xcode.app - - - name: Setup Build System (Generic) - if: runner.os != 'Windows' - run: | - ulimit -c unlimited -S || true - - mkdir -p $HOME/.cache/re2c - mkdir -p $HOME/.local/opt/re2c - - echo "RE2C_VERSION=${{ matrix.re2c }}" >> $GITHUB_ENV - echo "PATH=$PATH:$HOME/bin:$(brew --prefix lcov)/bin" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN)" >> $GITHUB_ENV - echo "CI=true" >> $GITHUB_ENV - - - name: Setup Core Dump (Linux) - if: runner.os == 'Linux' - run: echo '/tmp/core.%e.%p.%t' | sudo tee /proc/sys/kernel/core_pattern - - - name: Install re2c ${{ matrix.re2c }} - run: .ci/install-re2c.sh - - - name: Build extensions - run: | - phpize - - if [ "${{ matrix.ccov }}" = "ON" ]; then - ./configure \ - --enable-zephir-parser \ - --enable-zephir-parser-debug \ - --enable-coverage - else - ./configure \ - --enable-zephir-parser \ - --enable-zephir-parser-debug - fi - - make -j$(getconf _NPROCESSORS_ONLN) - - - name: Preparing to collect coverage data - if: matrix.ccov == 'ON' - run: make coverage-initial - - - name: Run Tests - if: runner.os != 'Windows' - run: make test NO_INTERACTION=1 REPORT_EXIT_STATUS=1 - - - name: Print failures - if: failure() && runner.os == 'Linux' - run: .ci/after-failure.sh - - - name: Capture coverage data - if: success() && matrix.ccov == 'ON' - run: make coverage-capture - - - name: Upload code coverage report - if: matrix.ccov == 'ON' - uses: codecov/codecov-action@v1 - with: - token: ${{secrets.CODECOV_TOKEN}} - file: ./lcov.info - flags: unittests - fail_ci_if_error: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 523db180..1a971e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [1.3.8] - 2021-09-08 +### Changed +- Changed CI from AppVeyor to Github Actions [#110](https://github.com/phalcon/php-zephir-parser/issues/110) + ## [1.3.7] - 2021-08-13 ### Added -- Added support of `require_once` statement +- Added support of `require_once` statement [#107](https://github.com/zephir-lang/php-zephir-parser/pull/107) ## [1.3.6] - 2020-12-03 ### Added @@ -164,7 +168,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Initial stable release -[Unreleased]: https://github.com/phalcon/php-zephir-parser/compare/v1.3.7...HEAD +[Unreleased]: https://github.com/phalcon/php-zephir-parser/compare/v1.3.8...HEAD +[1.3.8]: https://github.com/phalcon/php-zephir-parser/compare/v1.3.7...v1.3.8 [1.3.7]: https://github.com/phalcon/php-zephir-parser/compare/v1.3.6...v1.3.7 [1.3.6]: https://github.com/phalcon/php-zephir-parser/compare/v1.3.5...v1.3.6 [1.3.5]: https://github.com/phalcon/php-zephir-parser/compare/v1.3.4...v1.3.5 diff --git a/README.md b/README.md index a12c44b3..019296c0 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # Zephir Parser [![Actions Status][actions badge]][actions link] -[![Build on Windows][:badge-appveyor:]][:build-appveyor:] [![Coverage Status][:badge-codecov:]][:build-codecov:] [![License][:badge-license:]][:ext-license:] +[![Discord][:badge-discord:]][discord link] The Zephir Parser delivered as a C extension for the PHP language. -Supported PHP versions: **7.0**, **7.1**, **7.2**, **7.3**, **7.4** and **8.0** +Supported PHP versions: **7.0**, **7.1**, **7.2**, **7.3**, **7.4** and **8.0** **NOTE:** The [`development`][:dev-branch:] branch will always contain the latest **unstable** version. If you wish to @@ -145,12 +145,12 @@ Zephir Parser is open source software licensed under the MIT License (MIT). See the [LICENSE][:ext-license:] file for more information. [actions link]: https://github.com/phalcon/php-zephir-parser/actions -[actions badge]: https://github.com/phalcon/php-zephir-parser/workflows/build/badge.svg +[actions badge]: https://github.com/zephir-lang/php-zephir-parser/actions/workflows/ci.yml/badge.svg -[:badge-appveyor:]: https://ci.appveyor.com/api/projects/status/r4k8baw1iy54v2wt/branch/development?svg=true +[discord link]: http://phalcon.io/discord +[:badge-discord:]: https://img.shields.io/discord/310910488152375297?label=Discord&logo=discord [:badge-codecov:]: https://codecov.io/gh/phalcon/php-zephir-parser/branch/development/graph/badge.svg [:badge-license:]: https://img.shields.io/badge/license-MIT-brightgreen.svg -[:build-appveyor:]: https://ci.appveyor.com/project/sergeyklay/php-zephir-parser/branch/master [:build-codecov:]: https://codecov.io/gh/phalcon/php-zephir-parser [:ext-license:]: https://github.com/phalcon/php-zephir-parser/blob/master/LICENSE [:latest-release:]: https://github.com/phalcon/php-zephir-parser/releases/latest diff --git a/VERSION b/VERSION index 3336003d..e05cb332 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.7 +1.3.8 diff --git a/docker/windows/Dockerfile b/docker/windows/Dockerfile new file mode 100644 index 00000000..cbec6e2d --- /dev/null +++ b/docker/windows/Dockerfile @@ -0,0 +1,77 @@ +FROM mcr.microsoft.com/windows/servercore:ltsc2019 + +COPY . C:/php-zephir-parser + +# Download required functions for git installation +RUN powershell.exe -Command \ + ((new-object net.webclient).DownloadFile('https://raw.githubusercontent.com/actions/virtual-environments/5690645f0e91c30d888353d7b58432dc0466eca9/images/win/scripts/ImageHelpers/ChocoHelpers.ps1', 'C:\ChocoHelpers.ps1')); \ + ((new-object net.webclient).DownloadFile('https://raw.githubusercontent.com/actions/virtual-environments/f93413492e47983bafbc29ab84cb697aeeb41f7b/images/win/scripts/ImageHelpers/InstallHelpers.ps1', 'C:\InstallHelpers.ps1')); \ + ((new-object net.webclient).DownloadFile('https://raw.githubusercontent.com/actions/virtual-environments/b7f276c003aea42575b52247bdb2183e355fca2f/images/win/scripts/ImageHelpers/PathHelpers.ps1', 'C:\PathHelpers.ps1')); + +# Install Choco and Git +RUN powershell.exe -Command \ + Import-Module C:\ChocoHelpers.ps1; \ + Import-Module C:\InstallHelpers.ps1; \ + Import-Module C:\PathHelpers.ps1; \ + Invoke-Expression ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/scripts/Installers/Install-Choco.ps1')); \ + Invoke-Expression ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/actions/virtual-environments/main/images/win/scripts/Installers/Install-Git.ps1')); + +# Clone 'virtual-environments' +RUN powershell.exe git clone https://github.com/actions/virtual-environments.git + +# Install all necessary dependecies +RUN powershell.exe -Command \ + Import-Module C:\virtual-environments\images\win\scripts\ImageHelpers\PathHelpers.ps1; \ + Import-Module C:\virtual-environments\images\win\scripts\ImageHelpers\InstallHelpers.ps1; \ + Import-Module C:\virtual-environments\images\win\scripts\ImageHelpers\ChocoHelpers.ps1; \ + Import-Module C:\virtual-environments\images\win\scripts\ImageHelpers\VisualStudioHelpers.ps1; \ + Invoke-Expression C:\virtual-environments\images\win\scripts\Installers\Install-VCRedist.ps1; \ + Invoke-Expression C:\virtual-environments\images\win\scripts\Installers\Install-VS.ps1; \ + Invoke-Expression C:\virtual-environments\images\win\scripts\Installers\Install-PHP.ps1; + +RUN curl -SL --output vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe && \ + (start /w vs_buildtools.exe --quiet --wait --norestart --nocache modify \ + --installPath "C:\BuildTools" \ + --add Microsoft.VisualStudio.Workload.AzureBuildTools \ + --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 \ + --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 \ + --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 \ + --remove Microsoft.VisualStudio.Component.Windows81SDK) && \ + del /q vs_buildtools.exe + +RUN dir "C:\BuildTools" + +#RUN call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat" + +ENV PHP_VERSION=8.0.9 +ENV PHP_MINOR=8.0 +ENV TEST_PHP_EXECUTABLE=C:/php/php.exe +ENV BUILD_TYPE=ts +ENV VC_VERSION=16 +ENV PHP_ARCH=x64 +ENV BUILD_VERSION=1 + +ENV PHP_SDK_VERSION=2.2.0 +ENV PHP_DEVPACK=C:/tools/php-devpack +ENV PHP_SDK_PATH=C:/tools/php-sdk +ENV EXTENSION_FILE=php_zephir_parser.dll + +# choco install visualstudio2019-workload-vctools; \ +# choco install llvm; \ +RUN powershell.exe -Command \ + choco install 7zip; \ + Import-Module C:\php-zephir-parser\.ci\win-ci-tools.psm1; \ + SetupCommonEnvironment; \ + InstallPhpSdk; \ + InstallPhpDevPack; \ + AppendSessionPath; + +RUN call C:\tools\php-sdk\bin\phpsdk_setvars.bat && \ + cd C:\php-zephir-parser\parser && \ + cl.exe lemon.c && \ + DEL zephir.c zephir.h parser.c scanner.c && \ + re2c.exe -o scanner.c scanner.re && \ + lemon.exe -s zephir.lemon && \ + ECHO #include ^ > parser.c && \ + TYPE zephir.c >> parser.c && \ + TYPE base.c >> parser.c diff --git a/tests/base/cblocks.phpt b/tests/base/cblocks.phpt index 26dc07b8..158977f4 100644 --- a/tests/base/cblocks.phpt +++ b/tests/base/cblocks.phpt @@ -2,6 +2,7 @@ Tests recognizing wrapping C-code in CBLOCKs --SKIPIF-- + --FILE-- + --FILE-- + --FILE-- diff --git a/zephir_parser.h b/zephir_parser.h index 956f4f39..1ef08044 100644 --- a/zephir_parser.h +++ b/zephir_parser.h @@ -15,7 +15,7 @@ extern zend_module_entry zephir_parser_module_entry; #define phpext_zephir_parser_ptr &zephir_parser_module_entry #define PHP_ZEPHIR_PARSER_NAME "Zephir Parser" -#define PHP_ZEPHIR_PARSER_VERSION "1.3.7" +#define PHP_ZEPHIR_PARSER_VERSION "1.3.8" #define PHP_ZEPHIR_PARSER_AUTHOR "Zephir Team and contributors" #define PHP_ZEPHIR_PARSER_DESCRIPTION "The Zephir Parser delivered as a C extension for the PHP language."