From 1dce50622283b3eaeb998dcc75e6e4afceddddfa Mon Sep 17 00:00:00 2001 From: m-this <52073029+m-this@users.noreply.github.com> Date: Wed, 8 Jul 2026 10:11:27 +0200 Subject: [PATCH] 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 --- config/pkg/lib/postgresql.yml | 5 ++++ config/pkg/tool/meson.yml | 11 ++++++++ config/pkg/tool/ninja.yml | 9 ++++++ config/pkg/tool/winflexbison.yml | 12 ++++++++ src/Package/Artifact/meson_win.php | 45 ++++++++++++++++++++++++++++++ src/Package/Library/postgresql.php | 3 +- 6 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 config/pkg/tool/meson.yml create mode 100644 config/pkg/tool/ninja.yml create mode 100644 config/pkg/tool/winflexbison.yml create mode 100644 src/Package/Artifact/meson_win.php diff --git a/config/pkg/lib/postgresql.yml b/config/pkg/lib/postgresql.yml index 4be33190..290650df 100644 --- a/config/pkg/lib/postgresql.yml +++ b/config/pkg/lib/postgresql.yml @@ -17,6 +17,11 @@ postgresql: depends@windows: - openssl - zlib + tools@windows: + - meson + - ninja + - winflexbison + - strawberry-perl suggests@unix: - icu - libxslt diff --git a/config/pkg/tool/meson.yml b/config/pkg/tool/meson.yml new file mode 100644 index 00000000..0021bf93 --- /dev/null +++ b/config/pkg/tool/meson.yml @@ -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 diff --git a/config/pkg/tool/ninja.yml b/config/pkg/tool/ninja.yml new file mode 100644 index 00000000..820e154d --- /dev/null +++ b/config/pkg/tool/ninja.yml @@ -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 diff --git a/config/pkg/tool/winflexbison.yml b/config/pkg/tool/winflexbison.yml new file mode 100644 index 00000000..f117b5b9 --- /dev/null +++ b/config/pkg/tool/winflexbison.yml @@ -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 diff --git a/src/Package/Artifact/meson_win.php b/src/Package/Artifact/meson_win.php new file mode 100644 index 00000000..d3a911be --- /dev/null +++ b/src/Package/Artifact/meson_win.php @@ -0,0 +1,45 @@ +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"); + } +} diff --git a/src/Package/Library/postgresql.php b/src/Package/Library/postgresql.php index d0fcc2eb..25d600e2 100644 --- a/src/Package/Library/postgresql.php +++ b/src/Package/Library/postgresql.php @@ -98,7 +98,8 @@ class postgresql extends LibraryPackage . ' -Dextra_lib_dirs=' . escapeshellarg($lib_dir); // 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'; cmd()->cd($src)