diff --git a/src/Building/Build.php b/src/Building/Build.php index 2325f8e2..14fd88ca 100644 --- a/src/Building/Build.php +++ b/src/Building/Build.php @@ -5,6 +5,7 @@ namespace Php\Pie\Building; use Php\Pie\Downloading\DownloadedPackage; +use Php\Pie\Platform\TargetPlatform; use Symfony\Component\Console\Output\OutputInterface; /** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */ @@ -13,6 +14,7 @@ interface Build /** @param list $configureOptions */ public function __invoke( DownloadedPackage $downloadedPackage, + TargetPlatform $targetPlatform, array $configureOptions, OutputInterface $output, ): void; diff --git a/src/Building/UnixBuild.php b/src/Building/UnixBuild.php index 8a8816a6..61c42c5d 100644 --- a/src/Building/UnixBuild.php +++ b/src/Building/UnixBuild.php @@ -5,6 +5,7 @@ namespace Php\Pie\Building; use Php\Pie\Downloading\DownloadedPackage; +use Php\Pie\Platform\TargetPlatform; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\Process; @@ -19,12 +20,18 @@ final class UnixBuild implements Build /** {@inheritDoc} */ public function __invoke( DownloadedPackage $downloadedPackage, + TargetPlatform $targetPlatform, array $configureOptions, OutputInterface $output, ): void { $this->phpize($downloadedPackage); $output->writeln('phpize complete.'); + $phpConfigPath = $targetPlatform->phpBinaryPath->phpConfigPath(); + if ($phpConfigPath !== null) { + $configureOptions[] = '--with-php-config=' . $phpConfigPath; + } + $this->configure($downloadedPackage, $configureOptions); $optionsOutput = count($configureOptions) ? ' with options: ' . implode(' ', $configureOptions) : '.'; $output->writeln('Configure complete' . $optionsOutput); diff --git a/src/Building/WindowsBuild.php b/src/Building/WindowsBuild.php index 6f430809..3e743e39 100644 --- a/src/Building/WindowsBuild.php +++ b/src/Building/WindowsBuild.php @@ -5,6 +5,7 @@ namespace Php\Pie\Building; use Php\Pie\Downloading\DownloadedPackage; +use Php\Pie\Platform\TargetPlatform; use Symfony\Component\Console\Output\OutputInterface; /** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */ @@ -13,6 +14,7 @@ final class WindowsBuild implements Build /** {@inheritDoc} */ public function __invoke( DownloadedPackage $downloadedPackage, + TargetPlatform $targetPlatform, array $configureOptions, OutputInterface $output, ): void { diff --git a/src/Command/BuildCommand.php b/src/Command/BuildCommand.php index 607c5b9b..2cc03774 100644 --- a/src/Command/BuildCommand.php +++ b/src/Command/BuildCommand.php @@ -51,7 +51,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $configureOptionsValues = CommandHelper::processConfigureOptionsFromInput($downloadedPackage->package, $input); - ($this->build)($downloadedPackage, $configureOptionsValues, $output); + ($this->build)($downloadedPackage, $targetPlatform, $configureOptionsValues, $output); return Command::SUCCESS; } diff --git a/src/Platform/TargetPhp/PhpBinaryPath.php b/src/Platform/TargetPhp/PhpBinaryPath.php index cc8ded70..025cc8dc 100644 --- a/src/Platform/TargetPhp/PhpBinaryPath.php +++ b/src/Platform/TargetPhp/PhpBinaryPath.php @@ -24,12 +24,12 @@ class PhpBinaryPath { /** - * @param non-empty-string $phpBinaryPath + * @param non-empty-string $phpBinaryPath * @param non-empty-string|null $phpConfigPath */ private function __construct( public readonly string $phpBinaryPath, - private readonly string|null $phpConfigPath + private readonly string|null $phpConfigPath, ) { // @todo https://github.com/php/pie/issues/12 - we could verify that the given $phpBinaryPath really is a PHP install } diff --git a/test/integration/Building/UnixBuildTest.php b/test/integration/Building/UnixBuildTest.php index 920adcd4..08fe1823 100644 --- a/test/integration/Building/UnixBuildTest.php +++ b/test/integration/Building/UnixBuildTest.php @@ -10,6 +10,8 @@ use Php\Pie\DependencyResolver\Package; use Php\Pie\Downloading\DownloadedPackage; use Php\Pie\ExtensionName; +use Php\Pie\Platform\TargetPhp\PhpBinaryPath; +use Php\Pie\Platform\TargetPlatform; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Output\BufferedOutput; @@ -40,7 +42,12 @@ public function testUnixBuildCanBuildExtension(): void ); $unixBuilder = new UnixBuild(); - $unixBuilder->__invoke($downloadedPackage, ['--enable-pie_test_ext'], $output); + $unixBuilder->__invoke( + $downloadedPackage, + TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromCurrentProcess()), + ['--enable-pie_test_ext'], + $output, + ); $outputString = $output->fetch(); diff --git a/test/unit/Platform/TargetPhp/PhpBinaryPathTest.php b/test/unit/Platform/TargetPhp/PhpBinaryPathTest.php index 6eb8b356..03f8f628 100644 --- a/test/unit/Platform/TargetPhp/PhpBinaryPathTest.php +++ b/test/unit/Platform/TargetPhp/PhpBinaryPathTest.php @@ -48,7 +48,7 @@ public function testFromPhpConfigExecutable(): void $exitCode = $process->run(); $phpConfigExecutable = trim($process->getOutput()); - if ($exitCode !== 0 || ! file_exists($phpConfigExecutable) || ! is_executable($phpConfigExecutable)) { + if ($exitCode !== 0 || ! file_exists($phpConfigExecutable) || ! is_executable($phpConfigExecutable) || $phpConfigExecutable === '') { self::markTestSkipped('Needs php-config in path to run this test'); }