From 82a347be99280163783ad73c006f87de76d2be94 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Mon, 13 Jul 2026 20:37:55 +0100 Subject: [PATCH 1/3] 650: add freebsd pipeline to CI --- .github/workflows/continuous-integration.yml | 58 +++++++++++++++++++ .../Command/InstallCommandTest.php | 1 + .../Installing/UnixInstallTest.php | 1 + 3 files changed, 60 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9b10e16d..2c49afbb 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -50,6 +50,64 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + unit-tests-freebsd: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: + - '82' + - '83' + - '84' + - '85' + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0 + with: + persist-credentials: false + - name: Test in FreeBSD + uses: vmactions/freebsd-vm@5a72679103d223925653750faa878a143340fbd0 #v1.5.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + envs: 'GITHUB_TOKEN' + usesh: true + prepare: | + pkg install -y \ + php${{ matrix.php-versions }} \ + php${{ matrix.php-versions }}-composer \ + php${{ matrix.php-versions }}-ctype \ + php${{ matrix.php-versions }}-curl \ + php${{ matrix.php-versions }}-dom \ + php${{ matrix.php-versions }}-filter \ + php${{ matrix.php-versions }}-iconv \ + php${{ matrix.php-versions }}-intl \ + php${{ matrix.php-versions }}-mbstring \ + php${{ matrix.php-versions }}-pcntl \ + php${{ matrix.php-versions }}-phar \ + php${{ matrix.php-versions }}-posix \ + php${{ matrix.php-versions }}-session \ + php${{ matrix.php-versions }}-simplexml \ + php${{ matrix.php-versions }}-sodium \ + php${{ matrix.php-versions }}-tokenizer \ + php${{ matrix.php-versions }}-xml \ + php${{ matrix.php-versions }}-xmlwriter \ + php${{ matrix.php-versions }}-zip \ + autoconf \ + automake \ + bash \ + bison \ + ca_root_nss \ + gmake \ + pkgconf \ + re2c \ + sudo \ + git + run: | + export PATH="/usr/local/bin:/usr/local/sbin:$PATH" + composer config --global --auth github-oauth.github.com "$GITHUB_TOKEN" + composer install + vendor/bin/phpunit + bundled-php-extension-tests: runs-on: ${{ matrix.operating-system }} strategy: diff --git a/test/integration/Command/InstallCommandTest.php b/test/integration/Command/InstallCommandTest.php index 62921439..027c706e 100644 --- a/test/integration/Command/InstallCommandTest.php +++ b/test/integration/Command/InstallCommandTest.php @@ -70,6 +70,7 @@ public static function phpPathProvider(): array '/usr/bin/php-config8.1', '/usr/bin/php-config8.0', '/usr/bin/php-config7.4', + '/usr/local/bin/php-config', ], static fn (string $phpConfigPath) => file_exists($phpConfigPath) && is_executable($phpConfigPath), diff --git a/test/integration/Installing/UnixInstallTest.php b/test/integration/Installing/UnixInstallTest.php index 435f0664..ea61d5bf 100644 --- a/test/integration/Installing/UnixInstallTest.php +++ b/test/integration/Installing/UnixInstallTest.php @@ -68,6 +68,7 @@ public static function phpPathProvider(): array '/usr/bin/php-config7.4', '/usr/bin/php-config7.3', '/usr/bin/php-config7.2', + '/usr/local/bin/php-config', ], static fn (string $phpConfigPath) => file_exists($phpConfigPath) && is_executable($phpConfigPath), From fe87c999110d6c91c07617db78882b214469f480 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Mon, 13 Jul 2026 21:47:34 +0100 Subject: [PATCH 2/3] 650: add support for checking gmake on freebsd --- src/Building/UnixBuild.php | 3 +- src/Installing/UnixInstall.php | 3 +- src/Platform/MakePath.php | 66 +++++++++++++++++++++++++++++ test/unit/Platform/MakePathTest.php | 23 ++++++++++ 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/Platform/MakePath.php create mode 100644 test/unit/Platform/MakePathTest.php diff --git a/src/Building/UnixBuild.php b/src/Building/UnixBuild.php index 3c296413..f287b1dc 100644 --- a/src/Building/UnixBuild.php +++ b/src/Building/UnixBuild.php @@ -10,6 +10,7 @@ use Php\Pie\Downloading\DownloadedPackage; use Php\Pie\Downloading\DownloadUrlMethod; use Php\Pie\File\BinaryFile; +use Php\Pie\Platform\MakePath; use Php\Pie\Platform\TargetPhp\PhpizePath; use Php\Pie\Platform\TargetPlatform; use Php\Pie\Util\Process; @@ -198,7 +199,7 @@ private function make( IOInterface $io, callable|null $outputCallback, ): void { - $makeCommand = ['make']; + $makeCommand = [MakePath::guess()]; if ($targetPlatform->makeParallelJobs === 1) { $io->write('Running make without parallelization - try providing -jN to PIE where N is the number of cores you have.'); diff --git a/src/Installing/UnixInstall.php b/src/Installing/UnixInstall.php index 0084655b..d61c5f79 100644 --- a/src/Installing/UnixInstall.php +++ b/src/Installing/UnixInstall.php @@ -10,6 +10,7 @@ use Php\Pie\Downloading\DownloadUrlMethod; use Php\Pie\File\BinaryFile; use Php\Pie\File\Sudo; +use Php\Pie\Platform\MakePath; use Php\Pie\Platform\TargetPlatform; use Php\Pie\Util\Process; use RuntimeException; @@ -76,7 +77,7 @@ public function __invoke( break; default: - $installCommands[] = ['make', 'install']; + $installCommands[] = [MakePath::guess(), 'install']; } // If the target directory isn't writable, or a .so file already exists and isn't writable, try to use sudo diff --git a/src/Platform/MakePath.php b/src/Platform/MakePath.php new file mode 100644 index 00000000..e0e59e8e --- /dev/null +++ b/src/Platform/MakePath.php @@ -0,0 +1,66 @@ +run() !== 0) { + return false; + } + + return preg_match('/GNU Make/i', $makeVersionProcess->getOutput()) === 1; + } + + /** + * PHP extension Makefiles (generated by phpize/configure) rely on GNU + * Make syntax. On some platforms (e.g. FreeBSD, NetBSD, OpenBSD), the + * `make` found on the PATH is the native BSD make, which cannot parse + * these Makefiles; GNU Make is available there as `gmake` instead. + * + * @return non-empty-string + */ + public static function guess(): string + { + foreach (['make', 'gmake'] as $candidate) { + $which = new Process(['which', $candidate]); + if ($which->run() !== 0) { + continue; + } + + $candidatePath = trim($which->getOutput()); + + if (! self::looksLikeValidGnuMake($candidatePath)) { + continue; + } + + assert($candidatePath !== ''); + + return $candidatePath; + } + + throw new RuntimeException('Could not find a suitable GNU `make` binary (checked "make" and "gmake" on your PATH).'); + } +} diff --git a/test/unit/Platform/MakePathTest.php b/test/unit/Platform/MakePathTest.php new file mode 100644 index 00000000..8a1afe79 --- /dev/null +++ b/test/unit/Platform/MakePathTest.php @@ -0,0 +1,23 @@ + Date: Tue, 14 Jul 2026 19:43:16 +0100 Subject: [PATCH 3/3] 650: fall back to make if which is not available --- src/Platform/MakePath.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Platform/MakePath.php b/src/Platform/MakePath.php index e0e59e8e..44b1a9ef 100644 --- a/src/Platform/MakePath.php +++ b/src/Platform/MakePath.php @@ -4,7 +4,6 @@ namespace Php\Pie\Platform; -use RuntimeException; use Symfony\Component\Process\Process; use function assert; @@ -45,6 +44,7 @@ private static function looksLikeValidGnuMake(string $makePathToCheck): bool public static function guess(): string { foreach (['make', 'gmake'] as $candidate) { + // Note: depends on `which` existing, which doesn't always... $which = new Process(['which', $candidate]); if ($which->run() !== 0) { continue; @@ -61,6 +61,7 @@ public static function guess(): string return $candidatePath; } - throw new RuntimeException('Could not find a suitable GNU `make` binary (checked "make" and "gmake" on your PATH).'); + // Fall back to assuming/hoping make is on the path + return 'make'; } }