Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ jobs:
ts: [nts, ts]
os: ['2022']
include:
# PHP 7.4-8.3 use VS16, PHP 8.4 uses VS17.
# windows-2022 runners have both toolsets.
# PHP 7.4 requires VC15 (v141 toolset, MSVC 14.1x).
# PHP 8.0-8.3 use VS16, PHP 8.4 uses VS17.
# windows-2022 runners have vs16/vs17 but NOT vc15,
# so we install the v141 component for PHP 7.4.
- php: '7.4'
vs: vs16
- php: '8.0'
Expand All @@ -92,6 +94,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install VC15 (v141) toolset for PHP 7.4
if: matrix.php == '7.4'
shell: pwsh
run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
$installPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
$component = "Microsoft.VisualStudio.Component.VC.v141.x86.x64"
$args = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$installPath`"",
'--add', $component, '--quiet', '--norestart', '--nocache')
$process = Start-Process -FilePath cmd.exe -ArgumentList $args -Wait -PassThru -WindowStyle Hidden
if ($process.ExitCode -ne 0) {
Write-Warning "vs_installer exited with code $($process.ExitCode)"
}

- name: Setup PHP SDK
id: setup
uses: php/setup-php-sdk@v0.12
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Windows Build

on:
push:
branches: ['**']
paths:
- 'ext/**'
- '.github/workflows/windows-build.yml'
pull_request:
branches: ['**']
paths:
- 'ext/**'
- '.github/workflows/windows-build.yml'

jobs:
build-windows:
name: Windows - PHP ${{ matrix.php }} ${{ matrix.ts }} ${{ matrix.arch }}
runs-on: windows-${{ matrix.os }}
defaults:
run:
shell: cmd
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
arch: [x64]
ts: [nts, ts]
os: ['2022']
include:
# PHP 7.4 requires VC15 (v141 toolset, MSVC 14.1x).
# PHP 8.0-8.3 use VS16, PHP 8.4 uses VS17.
# windows-2022 runners have vs16/vs17 but NOT vc15,
# so we install the v141 component for PHP 7.4.
- php: '7.4'
vs: vs16
- php: '8.0'
vs: vs16
- php: '8.1'
vs: vs16
- php: '8.2'
vs: vs16
- php: '8.3'
vs: vs16
- php: '8.4'
vs: vs17

steps:
- uses: actions/checkout@v4

- name: Install VC15 (v141) toolset for PHP 7.4
if: matrix.php == '7.4'
shell: pwsh
run: |
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
$installPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
$component = "Microsoft.VisualStudio.Component.VC.v141.x86.x64"
$args = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$installPath`"",
'--add', $component, '--quiet', '--norestart', '--nocache')
$process = Start-Process -FilePath cmd.exe -ArgumentList $args -Wait -PassThru -WindowStyle Hidden
if ($process.ExitCode -ne 0) {
Write-Warning "vs_installer exited with code $($process.ExitCode)"
}

- name: Setup PHP SDK
id: setup
uses: php/setup-php-sdk@v0.12
with:
version: ${{ matrix.php }}
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}

- name: Enable MSVC Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
toolset: ${{ steps.setup.outputs.toolset }}

- name: phpize
working-directory: ext\mariadb_profiler
run: phpize

- name: configure
working-directory: ext\mariadb_profiler
run: configure --enable-mariadb_profiler --with-prefix=%INSTALL_DIR%
Comment on lines +82 to +84

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n .github/workflows/windows-build.yml

Repository: 39ff/php-ext-mariadb-salvage

Length of output: 2860


🌐 Web query:

php/setup-php-sdk action outputs environment variables INSTALL_DIR

💡 Result:

php/setup-php-sdk does not export an environment variable named INSTALL_DIR.

What it does provide:

  • It writes these step outputs: toolset, prefix, vs. [1]
  • The PHP “install dir” is effectively the prefix output, which is set to "$pwd\\php-bin" (the php-bin directory under the current working directory / workspace). [2]

So to get an INSTALL_DIR env var, define it yourself from the output:

- id: setup-php-sdk
  uses: php/setup-php-sdk@v0.12
  with:
    version: 8.4
    arch: x64
    ts: nts

- name: Export INSTALL_DIR
  shell: pwsh
  run: echo "INSTALL_DIR=${{ steps.setup-php-sdk.outputs.prefix }}" >> $env:GITHUB_ENV

Sources: [php/setup-php-sdk action.yml outputs] [1], [run.ps1 sets prefix=$pwd\php-bin] [2].

[1] (raw.githubusercontent.com)
[2] (raw.githubusercontent.com)

Citations:


%INSTALL_DIR% は定義されていません。ビルドが失敗します。

configure コマンドで --with-prefix=%INSTALL_DIR% を使用していますが、この環境変数はワークフロー内で定義されていません。php/setup-php-sdk@v0.12 アクションは INSTALL_DIR をエクスポートせず、環境変数は空文字列に展開されてビルド設定が不正になります。

アクションの prefix 出力から INSTALL_DIR を設定する必要があります:

修正例
      - name: Setup PHP SDK
        id: setup
        uses: php/setup-php-sdk@v0.12
        with:
          version: ${{ matrix.php }}
          arch: ${{ matrix.arch }}
          ts: ${{ matrix.ts }}

      - name: Set INSTALL_DIR
        run: echo INSTALL_DIR=${{ steps.setup.outputs.prefix }} >> %GITHUB_ENV%

      - name: Enable MSVC Developer Command Prompt
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: ${{ matrix.arch }}
          toolset: ${{ steps.setup.outputs.toolset }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/windows-build.yml around lines 66 - 68, `%INSTALL_DIR%`
が未定義で configure --with-prefix=%INSTALL_DIR% が失敗するので、php/setup-php-sdk@v0.12 の
prefix 出力を取り込んで環境変数に設定してください;具体的には Setup PHP SDK ステップに id: setup
を付け(既にある場合はそのまま)、その直後に "Set INSTALL_DIR" ステップを追加して steps.setup.outputs.prefix を
%GITHUB_ENV% に書き出して INSTALL_DIR をエクスポートし、これにより ext\mariadb_profiler の configure
ステップの --with-prefix=%INSTALL_DIR% が正しい値を参照するようにします(同じ領域で Enable MSVC Developer
Command Prompt に steps.setup.outputs.toolset を渡すことも維持してください)。


- name: nmake
working-directory: ext\mariadb_profiler
run: nmake

- name: Verify DLL exists
shell: pwsh
run: |
$dll = Get-ChildItem -Path ext\mariadb_profiler -Recurse -Filter "php_mariadb_profiler.dll" |
Select-Object -First 1
if (-not $dll) {
Write-Error "php_mariadb_profiler.dll not found"
exit 1
}
Write-Host "Built DLL: $($dll.FullName)"
Write-Host "Size: $([math]::Round($dll.Length / 1KB, 1)) KB"
25 changes: 23 additions & 2 deletions ext/mariadb_profiler/php_mariadb_profiler_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,27 @@ static inline struct tm *profiler_localtime_r(const time_t *timep, struct tm *re
# define LOCK_UN 8
# endif

/*
* Map a Windows error code to errno.
* PHP's internal _dosmaperr() is not exported for use by extensions,
* so we provide our own minimal mapping for the error codes we handle.
*/
static inline void profiler_dosmaperr(unsigned long winerr)
{
switch (winerr) {
case ERROR_ACCESS_DENIED: errno = EACCES; break;
case ERROR_INVALID_HANDLE: errno = EBADF; break;
case ERROR_NOT_ENOUGH_MEMORY: errno = ENOMEM; break;
case ERROR_LOCK_VIOLATION: errno = EACCES; break;
case ERROR_SHARING_VIOLATION: errno = EACCES; break;
case ERROR_FILE_NOT_FOUND: errno = ENOENT; break;
case ERROR_PATH_NOT_FOUND: errno = ENOENT; break;
case ERROR_ALREADY_EXISTS: errno = EEXIST; break;
case ERROR_FILE_EXISTS: errno = EEXIST; break;
default: errno = EINVAL; break;
}
}

static inline int profiler_flock(int fd, int operation)
{
HANDLE h = (HANDLE)_get_osfhandle(fd);
Expand All @@ -257,7 +278,7 @@ static inline int profiler_flock(int fd, int operation)
if (UnlockFileEx(h, 0, MAXDWORD, MAXDWORD, &ov)) {
return 0;
}
_dosmaperr(GetLastError());
profiler_dosmaperr(GetLastError());
return -1;
}

Expand All @@ -275,7 +296,7 @@ static inline int profiler_flock(int fd, int operation)
if ((operation & LOCK_NB) && lasterr == ERROR_LOCK_VIOLATION) {
errno = EWOULDBLOCK;
} else {
_dosmaperr(lasterr);
profiler_dosmaperr(lasterr);
}
}
return -1;
Expand Down