Skip to content

133: Add bundled php exts support #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
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
59 changes: 59 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,65 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

bundled-php-extension-tests:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system:
- ubuntu-latest
php-versions:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
#- '8.5' # @todo enable
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tracking this todo

steps:
- name: Install platform dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
g++ gcc make autoconf libtool bison re2c pkg-config unzip \
libcurl4-openssl-dev \
liblmdb-dev \
libdb-dev \
libqdbm-dev \
libenchant-2-dev \
libexif-dev \
libgd-dev \
libpng-dev \
libtiff-dev \
libfreetype-dev \
libfreetype6 \
libfontconfig1-dev \
libgmp-dev \
libssl-dev \
libsodium-dev \
libxml2-dev \
libonig-dev \
libldap-dev \
libedit-dev \
libsnmp-dev \
libtidy-dev \
libxslt1-dev \
libsasl2-dev \
libpq-dev \
libsqlite3-dev \
libzip-dev
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: none, mbstring, libxml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Composer Install
run: composer install --ignore-platform-reqs
- name: Run bundled PHP install test
run: sudo php test/install-bundled-php-exts.php
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

behaviour-tests:
runs-on: ${{ matrix.operating-system }}
strategy:
Expand Down
30 changes: 30 additions & 0 deletions src/Building/UnixBuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Php\Pie\Building;

use Php\Pie\ComposerIntegration\BundledPhpExtensionsRepository;
use Php\Pie\Downloading\DownloadedPackage;
use Php\Pie\File\BinaryFile;
use Php\Pie\Platform\TargetPhp\PhpizePath;
Expand All @@ -15,8 +16,11 @@
use function count;
use function file_exists;
use function implode;
use function rename;
use function sprintf;

use const DIRECTORY_SEPARATOR;

/** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */
final class UnixBuild implements Build
{
Expand Down Expand Up @@ -90,6 +94,25 @@ public function __invoke(
return BinaryFile::fromFileWithSha256Checksum($expectedSoFile);
}

private function renamesToConfigM4(DownloadedPackage $downloadedPackage, OutputInterface $output): void
{
$configM4 = $downloadedPackage->extractedSourcePath . DIRECTORY_SEPARATOR . 'config.m4';
if (file_exists($configM4)) {
return;
}

$output->writeln('config.m4 does not exist; checking alternatives', OutputInterface::VERBOSITY_VERY_VERBOSE);
foreach (['config0.m4', 'config9.m4'] as $alternateConfigM4) {
$fullPathToAlternate = $downloadedPackage->extractedSourcePath . DIRECTORY_SEPARATOR . $alternateConfigM4;
if (file_exists($fullPathToAlternate)) {
$output->writeln(sprintf('Renaming %s to config.m4', $alternateConfigM4), OutputInterface::VERBOSITY_VERY_VERBOSE);
rename($fullPathToAlternate, $configM4);

return;
}
}
}

/** @param callable(SymfonyProcess::ERR|SymfonyProcess::OUT, string): void|null $outputCallback */
private function phpize(
PhpizePath $phpize,
Expand All @@ -103,6 +126,8 @@ private function phpize(
$output->writeln('<comment>Running phpize step using: ' . implode(' ', $phpizeCommand) . '</comment>');
}

$this->renamesToConfigM4($downloadedPackage, $output);

Process::run(
$phpizeCommand,
$downloadedPackage->extractedSourcePath,
Expand Down Expand Up @@ -150,6 +175,11 @@ private function make(
$makeCommand[] = sprintf('-j%d', $targetPlatform->makeParallelJobs);
}

$makeCommand = BundledPhpExtensionsRepository::augmentMakeCommandForPhpBundledExtensions(
$makeCommand,
$downloadedPackage,
);

if ($output->isVerbose()) {
$output->writeln('<comment>Running make step with: ' . implode(' ', $makeCommand) . '</comment>');
}
Expand Down
Loading