From 347a3c3c112e0cecf8db81e551163fb6847349fd Mon Sep 17 00:00:00 2001 From: henderkes Date: Wed, 22 Jul 2026 22:36:15 +0700 Subject: [PATCH] move opentelemetry back to PIE --- config/pkg/ext/ext-opentelemetry.yml | 5 ++-- config/pkg/lib/krb5.yml | 2 +- src/StaticPHP/Artifact/Artifact.php | 6 ++--- src/StaticPHP/Config/ConfigValidator.php | 4 +-- src/StaticPHP/Package/Package.php | 2 +- src/StaticPHP/Package/PhpExtensionPackage.php | 25 ++++++++++++++----- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/config/pkg/ext/ext-opentelemetry.yml b/config/pkg/ext/ext-opentelemetry.yml index 5caebef2..af2190e7 100644 --- a/config/pkg/ext/ext-opentelemetry.yml +++ b/config/pkg/ext/ext-opentelemetry.yml @@ -2,8 +2,9 @@ ext-opentelemetry: type: php-extension artifact: source: - type: pecl - name: opentelemetry + type: pie + repo: open-telemetry/ext-opentelemetry + build-root: ext metadata: license-files: [LICENSE] license: Apache-2.0 diff --git a/config/pkg/lib/krb5.yml b/config/pkg/lib/krb5.yml index e3234ade..a6e5df6e 100644 --- a/config/pkg/lib/krb5.yml +++ b/config/pkg/lib/krb5.yml @@ -4,10 +4,10 @@ krb5: source: type: url url: 'https://web.mit.edu/kerberos/dist/krb5/1.22/krb5-1.22.2.tar.gz' + build-root: src metadata: license-files: [NOTICE] license: BSD-3-Clause - source-root: src depends: - openssl suggests: diff --git a/src/StaticPHP/Artifact/Artifact.php b/src/StaticPHP/Artifact/Artifact.php index 12b81a89..aae8e0a9 100644 --- a/src/StaticPHP/Artifact/Artifact.php +++ b/src/StaticPHP/Artifact/Artifact.php @@ -331,13 +331,13 @@ class Artifact /** * Get source build root directory. - * It's only worked when 'source-root' is defined in artifact config. + * It's only used when source.build-root is defined in artifact config. * Normally it's equal to source dir. */ public function getSourceRoot(): string { - if (isset($this->config['metadata']['source-root'])) { - return FileSystem::convertPath($this->getSourceDir() . '/' . ltrim($this->config['metadata']['source-root'], '/')); + if (isset($this->config['source']['build-root'])) { + return FileSystem::convertPath($this->getSourceDir() . '/' . ltrim($this->config['source']['build-root'], '/')); } return $this->getSourceDir(); } diff --git a/src/StaticPHP/Config/ConfigValidator.php b/src/StaticPHP/Config/ConfigValidator.php index b66250cc..0ba6658f 100644 --- a/src/StaticPHP/Config/ConfigValidator.php +++ b/src/StaticPHP/Config/ConfigValidator.php @@ -297,8 +297,8 @@ class ConfigValidator throw new ValidationException("Artifact source object of type '{$type}' must have required field '{$field}'"); } } - // check for unknown fields - $allowed_fields = array_merge(['type'], $required_fields, $optional_fields); + // check for unknown fields ('build-root': optional build subdir, applies to any type) + $allowed_fields = array_merge(['type', 'build-root'], $required_fields, $optional_fields); self::validateNoInvalidFields('artifact object', $item_name, $data, $allowed_fields); } diff --git a/src/StaticPHP/Package/Package.php b/src/StaticPHP/Package/Package.php index 1ec1a503..6f7e5f28 100644 --- a/src/StaticPHP/Package/Package.php +++ b/src/StaticPHP/Package/Package.php @@ -251,7 +251,7 @@ abstract class Package /** * Get source build root directory. - * It's only worked when 'source-root' is defined in artifact config. + * It's only worked when source.build-root is defined in artifact config. * Normally it's equal to source dir. */ public function getSourceRoot(): string diff --git a/src/StaticPHP/Package/PhpExtensionPackage.php b/src/StaticPHP/Package/PhpExtensionPackage.php index 8a6dc4bc..bdbdbb08 100644 --- a/src/StaticPHP/Package/PhpExtensionPackage.php +++ b/src/StaticPHP/Package/PhpExtensionPackage.php @@ -60,6 +60,19 @@ class PhpExtensionPackage extends Package return parent::getSourceDir(); } + /** + * Directory the extension is actually built in: cd'd into by phpize/configure/make. + * Equals getSourceDir() unless the artifact declares source.build-root (e.g. a PIE + * package whose config.m4 lives in an ext/ subdir). + */ + public function getSourceRoot(): string + { + if ($this->getArtifact() === null) { + return $this->getSourceDir(); + } + return parent::getSourceRoot(); + } + public function getExtensionName(): string { return str_replace('ext-', '', $this->getName()); @@ -299,7 +312,7 @@ class PhpExtensionPackage extends Package #[Stage] public function phpizeForUnix(array $env, PhpExtensionPackage $package): void { - shell()->cd($package->getSourceDir())->setEnv($env)->exec(BUILD_BIN_PATH . '/phpize'); + shell()->cd($package->getSourceRoot())->setEnv($env)->exec(BUILD_BIN_PATH . '/phpize'); } /** @@ -310,7 +323,7 @@ class PhpExtensionPackage extends Package { $phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: ''; // CustomPhpConfigureArg keys are OS names ('Linux'/'Darwin'), not platform strings - shell()->cd($package->getSourceDir()) + shell()->cd($package->getSourceRoot()) ->setEnv($env) ->exec( './configure ' . $this->getPhpConfigureArg(SystemTarget::getTargetOS(), true) . @@ -329,7 +342,7 @@ class PhpExtensionPackage extends Package $package->patchSharedLibAdd(); $extra_ldflags = (string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'); $makeArgs = $extra_ldflags !== '' ? 'EXTRA_LDFLAGS=' . escapeshellarg($extra_ldflags) : ''; - shell()->cd($package->getSourceDir()) + shell()->cd($package->getSourceRoot()) ->setEnv($env) ->exec('make clean') ->exec("make -j{$builder->concurrency} {$makeArgs}") @@ -355,7 +368,7 @@ class PhpExtensionPackage extends Package ? '-l:libstdc++.a' : (str_contains($sharedLibs, '-lstdc++') ? '-lstdc++' : ''); - $makefile = $this->getSourceDir() . '/Makefile'; + $makefile = $this->getSourceRoot() . '/Makefile'; if (!is_file($makefile)) { return; } @@ -390,9 +403,9 @@ class PhpExtensionPackage extends Package return; } - if (!is_dir($this->getSourceDir())) { + if (!is_dir($this->getSourceRoot())) { throw new ValidationException( - "Extension source directory not found: {$this->getSourceDir()}", + "Extension source directory not found: {$this->getSourceRoot()}", validation_module: "Extension {$this->getName()} source" ); }