diff --git a/.github/workflows/tensor.yml b/.github/workflows/tensor.yml index 9f482e5..bc8d5b5 100644 --- a/.github/workflows/tensor.yml +++ b/.github/workflows/tensor.yml @@ -1,38 +1,63 @@ name: 'Tensor' -on: - workflow_dispatch: +on: [workflow_dispatch] jobs: build: - name: build - runs-on: windows-2019 + defaults: + run: + shell: cmd strategy: - fail-fast: false matrix: - php: ['8.0', '8.1', '8.2', '8.3'] - extensions: [tensor] - sdk_version: [master] - vs: [vs16] - ts: [ts, nts] - arch: [x64] - include: - - extensions: tensor - repo: RubixML/Tensor - branch: master - args: enable-tensor + # version: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + version: ['8.2'] + arch: [x64] + ts: [ts, nts] + runs-on: windows-2019 steps: - - uses: actions/checkout@v3 - - name: build - run: | - pwsh scripts/tensor.ps1 ${{ matrix.extensions }} ${{ matrix.repo }} ${{ matrix.branch }} ${{ matrix.args }} ${{ matrix.sdk_version }} ${{ matrix.vs }} ${{ matrix.arch }} ${{ matrix.ts }} ${{ matrix.php }} - $exit_code = $? - if(-not($exit_code)) { - exit $exit_code - } - - name: Upload Artifact - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.extensions }}_${{ matrix.ts }}_${{ matrix.arch }} - path: ${{ matrix.extensions }} + - name: Checkout tensor + uses: actions/checkout@v2 + - name: Setup PHP + id: setup-php + uses: cmb69/setup-php-sdk@v0.2 + with: + version: ${{matrix.version}} + arch: ${{matrix.arch}} + ts: ${{matrix.ts}} + - name: Enable Developer Command Prompt + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{matrix.arch}} + toolset: ${{steps.setup-php.outputs.toolset}} + - name: Download dependencies + run: | + curl -LO https://github.com/xianyi/OpenBLAS/releases/download/v0.3.20/OpenBLAS-0.3.20-x64.zip + 7z x OpenBLAS-0.3.20-x64.zip -odeps + - name: phpize + run: cd ext && phpize + - name: configure + run: cd ext && configure --enable-tensor --enable-debug-pack --with-prefix=${{steps.setup-php.outputs.prefix}} + - name: make + run: cd ext && nmake + - name: package + run: | + xcopy deps\bin\libopenblas.dll install\* + if exist ext\${{matrix.arch}}\Release ( + xcopy ext\${{matrix.arch}}\Release\php_tensor.dll install\* + xcopy ext\${{matrix.arch}}\Release\php_tensor.pdb install\* + ) else if exist ext\Release ( + xcopy ext\Release\php_tensor.dll install\* + xcopy ext\Release\php_tensor.pdb install\* + ) else if exist ext\${{matrix.arch}}\Release_TS ( + xcopy ext\${{matrix.arch}}\Release_TS\php_tensor.dll install\* + xcopy ext\${{matrix.arch}}\Release_TS\php_tensor.pdb install\* + ) else if exist ext\Release_TS ( + xcopy ext\Release_TS\php_tensor.dll install\* + xcopy ext\Release_TS\php_tensor.pdb install\* + ) + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: php_tensor-dev-${{matrix.version}}-${{matrix.ts}}-vs16-${{matrix.arch}} + path: install release: runs-on: ubuntu-latest needs: build diff --git a/scripts/tensor.ps1 b/scripts/tensor.ps1 deleted file mode 100644 index 6b7d840..0000000 --- a/scripts/tensor.ps1 +++ /dev/null @@ -1,201 +0,0 @@ -param ( - [Parameter(Position = 0, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $extension, - [Parameter(Position = 1, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $repo, - [Parameter(Position = 2, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $branch, - [Parameter(Position = 3, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $config_args, - [Parameter(Position = 4, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $sdk_version, - [Parameter(Position = 5, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $vs, - [Parameter(Position = 6, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $arch, - [Parameter(Position = 7, Mandatory = $false)] - [string] - $ts, - [Parameter(Position = 8, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $php -) - -Function Cleanup() { - if(Test-Path $ext_dir) { - Remove-Item $ext_dir -Recurse -Force - } - if(Test-Path $cache_dir) { - Remove-Item $cache_dir -Recurse -Force - } - New-Item -Path $cache_dir -ItemType "directory" -} - -Function Get-Extension() { - git clone --branch=$branch $github/$repo.git $ext_dir - # git clone --branch=$branch $github/$repo.git $ext_dir-project - # Move-Item "C:/projects/tensor-project/ext" "C:/projects/tensor" -} - -Function Get-Package { - param ( - [Parameter(Position = 0, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $package, - [Parameter(Position = 1, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $url, - [Parameter(Position = 2, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $tmp_dir, - [Parameter(Position = 3, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $package_dir - ) - if (-not (Test-Path $cache_dir\$package)) { - Invoke-WebRequest $url -OutFile "$cache_dir\$package" - } - - if (-not (Test-Path $package_dir)) { - Expand-Archive -Path $cache_dir\$package -DestinationPath $cache_dir -Force - if($tmp_dir -ne $package_dir) { - Rename-Item -Path $cache_dir\$tmp_dir -NewName $package_dir -Force - } - } -} - -Function Add-TaskFile() { - param ( - [Parameter(Position = 0, Mandatory = $true)] - [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] - $filename - ) - $bat_content = @() - $bat_content += "" - $bat_content += "curl -LO https://windows.php.net/downloads/pecl/deps/OpenBLAS-0.3.18-vs16-x64.zip" - $bat_content += '7z x OpenBLAS-0.3.18-vs16-x64.zip -o"..\deps"' - $bat_content += "tree /f ..\deps" - $bat_content += "call phpize 2>&1" - $bat_content += "call configure --help" - $bat_content += "call configure --$config_args --enable-debug-pack --with-extra-libs=..\deps\bin 2>&1" - $bat_content += "nmake /nologo 2>&1" - $bat_content += "exit %errorlevel%" - Set-Content -Encoding "ASCII" -Path $filename -Value $bat_content -} - -Function Get-TSPath() { - if($ts -eq 'nts') { - return '-nts' - } - - return '' -} - -Function Get-ReleaseDirectory() { - $arch_path = '' - if($arch -eq 'x64') { - $arch_path = 'x64' - } - - $release_path = 'Release' - if($ts -eq 'ts') { - $release_path = 'Release_TS' - } - - return [IO.Path]::Combine($arch_path, $release_path) -} - -Function Get-PHPBranch() { - $php_branch = 'master' - if($php -ne $nightly_version) { - $php_branch = "PHP-$php" - } - - return $php_branch -} - -Function Build-Extension() { - $ts_path = Get-TSPath - $package_zip = "php-devel-pack-$php_version$ts_path-Win32-$vs-$arch.zip" - $tmp_dir = "php-$php_version-devel-$vs-$arch" - $package_dir = "php-$php_version$ts_path-devel-$vs-$arch" - $url = "$trunk/$package_zip" - Get-Package $package_zip $url $tmp_dir $package_dir - & "C:\projects\$extension\build-ext.bat" - - Set-Location "$ext_dir\ext" - Add-TaskFile "task.bat" - $env:PATH = "$cache_dir\$package_dir;$env:PATH" - $builder = "$cache_dir\php-sdk-$sdk_version\phpsdk-$vs-$arch.bat" - $task = (Get-Item -Path "." -Verbose).FullName + '\task.bat' - & $builder -t $task -} - -Function Copy-Extension() { - Set-Location $workspace - New-Item -Path $extension -ItemType "directory" - $release_dir = Get-ReleaseDirectory - $ext_path = [IO.Path]::Combine($ext_dir, $release_dir, "php_$extension.dll") - Write-Output "Extension Path: $ext_path" - if(Test-Path $ext_path) { - Copy-Item -Path $ext_path -Destination "$extension\php$php`_$ts`_$arch`_$extension.dll" - Get-ChildItem $extension - } else { - exit 1 - } -} - -$workspace = (Get-Location).Path -$cache_dir = "C:\build-cache" -$ext_dir = "C:\projects\$extension" -$github = "https://github.com" -$trunk = "$github/shivammathur/php-builder-windows/releases/download/php$php" -$nightly_version = '8.3' -$php_branch = Get-PHPBranch -$php_version = Invoke-RestMethod "https://raw.githubusercontent.com/php/php-src/$php_branch/main/php_version.h" | Where-Object { $_ -match 'PHP_VERSION "(.*)"' } | Foreach-Object {$Matches[1]} -$package_zip = "php-sdk-$sdk_version.zip" -$tmp_dir = "php-sdk-binary-tools-php-sdk-$sdk_version" -if($sdk_version -eq 'master') { - $package_zip = "master.zip" - $tmp_dir = "php-sdk-binary-tools-master" -} -$package_dir = "php-sdk-$sdk_version" -$url = "$github/php/php-sdk-binary-tools/archive/$package_zip" -Cleanup -Get-Package $package_zip $url $tmp_dir $package_dir -Get-Extension -Build-Extension -Copy-Extension