fix(postgresql): provision meson, ninja and winflexbison on windows

- the meson build assumed meson/ninja/win_flex/win_bison/perl on PATH,
  which only held on machines that had them installed
- add meson, ninja and winflexbison tool packages and declare them via
  tools@windows on postgresql, together with the existing strawberry-perl
- meson no longer ships a Windows MSI, so the wheel is installed offline
  into a venv: postgres re-invokes meson through find_program, which
  needs the real meson.exe launcher pip generates
This commit is contained in:
m-this
2026-07-08 10:11:27 +02:00
parent 323f21a6f2
commit 1dce506222
6 changed files with 84 additions and 1 deletions

View File

@@ -17,6 +17,11 @@ postgresql:
depends@windows: depends@windows:
- openssl - openssl
- zlib - zlib
tools@windows:
- meson
- ninja
- winflexbison
- strawberry-perl
suggests@unix: suggests@unix:
- icu - icu
- libxslt - libxslt

11
config/pkg/tool/meson.yml Normal file
View File

@@ -0,0 +1,11 @@
meson:
type: tool
artifact:
binary:
windows-x86_64: { type: url, url: 'https://github.com/mesonbuild/meson/releases/download/1.11.1/meson-1.11.1-py3-none-any.whl', extract: '{pkg_root_path}/meson/meson-1.11.1-py3-none-any.whl' }
path@windows:
- '{pkg_root_path}\meson'
tool:
provides:
- meson.bat
binary-subdir: meson

View File

@@ -0,0 +1,9 @@
ninja:
type: tool
artifact:
binary:
windows-x86_64: { type: url, url: 'https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-win.zip', extract: { ninja.exe: '{pkg_root_path}/bin/ninja.exe' } }
tool:
provides:
- ninja.exe
binary-subdir: bin

View File

@@ -0,0 +1,12 @@
winflexbison:
type: tool
artifact:
binary:
windows-x86_64: { type: url, url: 'https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip', extract: '{pkg_root_path}/winflexbison' }
path@windows:
- '{pkg_root_path}\winflexbison'
tool:
provides:
- win_flex.exe
- win_bison.exe
binary-subdir: winflexbison

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace Package\Artifact;
use StaticPHP\Attribute\Artifact\AfterBinaryExtract;
use StaticPHP\Exception\EnvironmentException;
use StaticPHP\Util\FileSystem;
class meson_win
{
/**
* Meson 1.11 dropped the Windows MSI, so the artifact is the wheel, installed offline
* into a private venv. The venv is not just packaging hygiene: pip generates a real
* meson.exe launcher there, and PostgreSQL needs one because its build re-invokes meson
* through find_program(), which rejects non-executables like the meson.pyz zipapp.
*/
#[AfterBinaryExtract('meson', ['windows-x86_64'])]
public function afterExtract(string $target_path): void
{
$dir = dirname($target_path);
$venv = "{$dir}\\venv";
$python = null;
foreach (['python', 'py -3'] as $candidate) {
[$code] = cmd()->execWithResult("{$candidate} --version", false);
if ($code === 0) {
$python = $candidate;
break;
}
}
if ($python === null) {
throw new EnvironmentException('meson needs Python 3 on PATH. Install it from https://www.python.org or with `winget install Python.Python.3.13`.');
}
if (is_dir($venv)) {
FileSystem::removeDir($venv);
}
cmd()->exec("{$python} -m venv \"{$venv}\"")
->exec("\"{$venv}\\Scripts\\python.exe\" -m pip install --no-index --no-deps \"{$target_path}\"");
FileSystem::writeFile("{$dir}\\meson.bat", "@echo off\r\n\"%~dp0venv\\Scripts\\meson.exe\" %*\r\n");
}
}

View File

@@ -98,7 +98,8 @@ class postgresql extends LibraryPackage
. ' -Dextra_lib_dirs=' . escapeshellarg($lib_dir); . ' -Dextra_lib_dirs=' . escapeshellarg($lib_dir);
// Build only the three frontend static libs (not the server) — keeps it fast and avoids // Build only the three frontend static libs (not the server) — keeps it fast and avoids
// needing every backend dependency. meson/ninja/win_bison/win_flex/perl come from PATH. // needing every backend dependency. meson/ninja/win_bison/win_flex/perl come from the
// tool packages declared in the package config (tools@windows).
$targets = 'src/interfaces/libpq/libpq.a src/common/libpgcommon.a src/port/libpgport.a'; $targets = 'src/interfaces/libpq/libpq.a src/common/libpgcommon.a src/port/libpgport.a';
cmd()->cd($src) cmd()->cd($src)