Skip to content
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
31 changes: 0 additions & 31 deletions config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"type": "url",
"url": "https://pecl.php.net/get/amqp",
"path": "php-src/ext/amqp",
"filename": "amqp.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -21,7 +20,6 @@
"type": "url",
"url": "https://pecl.php.net/get/APCu",
"path": "php-src/ext/apcu",
"filename": "apcu.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -31,7 +29,6 @@
"type": "url",
"url": "https://pecl.php.net/get/ast",
"path": "php-src/ext/ast",
"filename": "ast.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -88,7 +85,6 @@
"type": "url",
"url": "https://pecl.php.net/get/dio",
"path": "php-src/ext/dio",
"filename": "dio.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -98,7 +94,6 @@
"type": "url",
"url": "https://pecl.php.net/get/ev",
"path": "php-src/ext/ev",
"filename": "ev.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -118,7 +113,6 @@
"type": "url",
"url": "https://pecl.php.net/get/ds",
"path": "php-src/ext/ds",
"filename": "ds.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -155,7 +149,6 @@
"type": "url",
"url": "https://pecl.php.net/get/grpc",
"path": "php-src/ext/grpc",
"filename": "grpc.tgz",
"license": {
"type": "file",
"path": [
Expand All @@ -167,7 +160,6 @@
"type": "url",
"url": "https://pecl.php.net/get/imagick",
"path": "php-src/ext/imagick",
"filename": "imagick.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -177,7 +169,6 @@
"type": "url",
"url": "https://pecl.php.net/get/imap",
"path": "php-src/ext/imap",
"filename": "imap.tgz",
"license": {
"type": "file",
"path": [
Expand All @@ -199,7 +190,6 @@
"ext-maxminddb": {
"type": "url",
"url": "https://pecl.php.net/get/maxminddb",
"filename": "ext-maxminddb.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -209,7 +199,6 @@
"type": "url",
"url": "https://pecl.php.net/get/memcache",
"path": "php-src/ext/memcache",
"filename": "memcache.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -228,7 +217,6 @@
"type": "url",
"url": "https://pecl.php.net/get/simdjson",
"path": "php-src/ext/simdjson",
"filename": "simdjson.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -248,7 +236,6 @@
"type": "url",
"url": "https://pecl.php.net/get/ssh2",
"path": "php-src/ext/ssh2",
"filename": "ssh2.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -258,7 +245,6 @@
"type": "url",
"url": "https://pecl.php.net/get/trader",
"path": "php-src/ext/trader",
"filename": "trader.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -268,7 +254,6 @@
"type": "url",
"url": "https://pecl.php.net/get/uuid",
"path": "php-src/ext/uuid",
"filename": "uuid.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -278,7 +263,6 @@
"type": "url",
"url": "https://pecl.php.net/get/uv",
"path": "php-src/ext/uv",
"filename": "uv.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -297,7 +281,6 @@
"ext-zip": {
"type": "url",
"url": "https://pecl.php.net/get/zip",
"filename": "ext-zip.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -405,7 +388,6 @@
"type": "url",
"url": "https://pecl.php.net/get/igbinary",
"path": "php-src/ext/igbinary",
"filename": "igbinary.tgz",
"license": {
"type": "file",
"path": "COPYING"
Expand All @@ -432,7 +414,6 @@
"type": "url",
"url": "https://pecl.php.net/get/inotify",
"path": "php-src/ext/inotify",
"filename": "inotify.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -837,7 +818,6 @@
"type": "url",
"url": "https://pecl.php.net/get/memcached",
"path": "php-src/ext/memcached",
"filename": "memcached.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -878,7 +858,6 @@
"type": "url",
"url": "https://pecl.php.net/get/msgpack",
"path": "php-src/ext/msgpack",
"filename": "msgpack.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -981,7 +960,6 @@
"type": "url",
"url": "https://pecl.php.net/get/opentelemetry",
"path": "php-src/ext/opentelemetry",
"filename": "opentelemetry.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -991,7 +969,6 @@
"type": "url",
"url": "https://pecl.php.net/get/parallel",
"path": "php-src/ext/parallel",
"filename": "parallel.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -1000,7 +977,6 @@
"pcov": {
"type": "url",
"url": "https://pecl.php.net/get/pcov",
"filename": "pcov.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -1010,7 +986,6 @@
"type": "url",
"url": "https://pecl.php.net/get/pdo_sqlsrv",
"path": "php-src/ext/pdo_sqlsrv",
"filename": "pdo_sqlsrv.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -1046,7 +1021,6 @@
"type": "url",
"url": "https://pecl.php.net/get/protobuf",
"path": "php-src/ext/protobuf",
"filename": "protobuf.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -1108,7 +1082,6 @@
"type": "url",
"url": "https://pecl.php.net/get/redis",
"path": "php-src/ext/redis",
"filename": "redis.tgz",
"license": {
"type": "file",
"path": [
Expand Down Expand Up @@ -1148,7 +1121,6 @@
"type": "url",
"url": "https://pecl.php.net/get/sqlsrv",
"path": "php-src/ext/sqlsrv",
"filename": "sqlsrv.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down Expand Up @@ -1214,7 +1186,6 @@
"type": "url",
"url": "https://pecl.php.net/get/xhprof",
"path": "php-src/ext/xhprof-src",
"filename": "xhprof.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -1224,7 +1195,6 @@
"type": "url",
"url": "https://pecl.php.net/get/xlswriter",
"path": "php-src/ext/xlswriter",
"filename": "xlswriter.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand All @@ -1245,7 +1215,6 @@
"type": "url",
"url": "https://pecl.php.net/get/yac",
"path": "php-src/ext/yac",
"filename": "yac.tgz",
"license": {
"type": "file",
"path": "LICENSE"
Expand Down
12 changes: 10 additions & 2 deletions src/SPC/builder/BuilderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function proveExts(array $static_extensions, array $shared_extensions = [
}
if (!$skip_extract) {
$this->emitPatchPoint('before-php-extract');
SourceManager::initSource(sources: ['php-src'], source_only: true);
SourceManager::initSource(sources: [$this->getPhpSrcName()], source_only: true);
$this->emitPatchPoint('after-php-extract');
if ($this->getPHPVersionID() >= 80000) {
$this->emitPatchPoint('before-micro-extract');
Expand Down Expand Up @@ -319,7 +319,7 @@ public function getPHPVersion(bool $exception_on_failure = true): string
public function getPHPVersionFromArchive(?string $file = null): false|string
{
if ($file === null) {
$lock = LockFile::get('php-src');
$lock = LockFile::get($this->getPhpSrcName());
if ($lock === null) {
return false;
}
Expand Down Expand Up @@ -498,6 +498,14 @@ public function checkBeforeBuildPHP(int $rule): void
}
}

/**
* Get the php-src name to use for lock file lookups (supports version-specific names like php-src-8.2)
*/
protected function getPhpSrcName(): string
{
return getenv('SPC_PHP_SRC_NAME') ?: 'php-src';
}

/**
* Generate micro extension test php code.
*/
Expand Down
26 changes: 26 additions & 0 deletions src/SPC/command/BuildPHPCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function configure(): void
$this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx (windows only)');
$this->addOption('enable-micro-win32', null, null, 'Enable win32 mode for phpmicro (Windows only)');
$this->addOption('with-frankenphp-app', null, InputOption::VALUE_REQUIRED, 'Path to a folder to be embedded in FrankenPHP');
$this->addOption('with-php', null, InputOption::VALUE_REQUIRED, 'PHP version to build (e.g., 8.2, 8.3, 8.4). Uses php-src-X.Y if available, otherwise php-src');
}

public function handle(): int
Expand Down Expand Up @@ -120,6 +121,31 @@ public function handle(): int
logger()->warning('Some cases micro.sfx cannot be packed via UPX due to dynamic size bug, be aware!');
}
}

// Determine which php-src to use based on --with-php option
$php_version = $this->getOption('with-php');
if ($php_version !== null) {
// Check if version-specific php-src exists in lock file
$version_specific_name = "php-src-{$php_version}";
$lock_file_path = DOWNLOAD_PATH . '/.lock.json';
if (file_exists($lock_file_path)) {
$lock_content = json_decode(file_get_contents($lock_file_path), true);
if (isset($lock_content[$version_specific_name])) {
// Use version-specific php-src
f_putenv("SPC_PHP_SRC_NAME={$version_specific_name}");
logger()->info("Building with PHP {$php_version} (using {$version_specific_name})");
} else {
logger()->error('No php-src found in downloads. Please run download command first.');
return static::FAILURE;
}
} else {
logger()->error('Lock file not found. Please download sources first.');
return static::FAILURE;
}
} else {
f_putenv('SPC_PHP_SRC_NAME=php-src');
}

// create builder
$builder = BuilderProvider::makeBuilderByInput($this->input);
$include_suggest_ext = $this->getOption('with-suggested-exts');
Expand Down
Loading
Loading