Compare commits

..

5 Commits

Author SHA1 Message Date
crazywhalecc
331da67049 Fix gen-ext-test-matrix AND bug (should be OR) 2026-07-07 15:48:35 +08:00
crazywhalecc
cc448d463b simdjson test 2026-07-07 15:42:34 +08:00
crazywhalecc
dc55881b78 libde265 fix build 2026-07-07 15:21:19 +08:00
crazywhalecc
a59473e4ab ext-test-matrix generation fix 2026-07-07 15:03:31 +08:00
crazywhalecc
c6a227f4de libde265 test 2026-07-07 14:50:32 +08:00
4 changed files with 91 additions and 16 deletions

View File

@@ -50,6 +50,7 @@ class simdjson extends PhpExtensionPackage
if (!str_contains((string) $extra, '-lstdc++')) { if (!str_contains((string) $extra, '-lstdc++')) {
f_putenv('SPC_COMPILER_EXTRA=' . clean_spaces($extra . ' -lstdc++')); f_putenv('SPC_COMPILER_EXTRA=' . clean_spaces($extra . ' -lstdc++'));
} }
$env['CFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512'; $env['CFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
$env['CXXFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512'; $env['CXXFLAGS'] .= ' -Xclang -target-feature -Xclang +evex512';
} }

View File

@@ -20,6 +20,7 @@ class libde265 extends LibraryPackage
->addConfigureArgs( ->addConfigureArgs(
'-DENABLE_SDL=OFF', '-DENABLE_SDL=OFF',
'-DENABLE_DECODER=OFF', '-DENABLE_DECODER=OFF',
'-DENABLE_SIMD=OFF',
'-DHAVE_NEON=OFF', '-DHAVE_NEON=OFF',
) )
->build(); ->build();

View File

@@ -107,7 +107,12 @@ class GenExtTestMatrixCommand extends BaseCommand
// Separate into regular and virtual extensions (build-static:false excluded globally) // Separate into regular and virtual extensions (build-static:false excluded globally)
$all_regular = []; $all_regular = [];
$all_virtual = []; $all_virtual = [];
$all_libraries = [];
foreach ($all as $pkg_name => $config) { foreach ($all as $pkg_name => $config) {
if (($config['type'] ?? '') === 'library') {
$all_libraries[$pkg_name] = $config;
continue;
}
if (($config['type'] ?? '') !== 'php-extension') { if (($config['type'] ?? '') !== 'php-extension') {
continue; continue;
} }
@@ -154,10 +159,7 @@ class GenExtTestMatrixCommand extends BaseCommand
$raw, $raw,
fn ($d) => isset($pool_set[$d]) && $d !== $pkg_name fn ($d) => isset($pool_set[$d]) && $d !== $pkg_name
)); ));
$os_lib_deps[$this->displayName($pkg_name)] = array_values(array_filter( $os_lib_deps[$this->displayName($pkg_name)] = $this->collectLibraryDeps($raw, $all_libraries, $os);
$raw,
fn ($d) => !str_starts_with($d, 'ext-')
));
} }
$all_ext_lib_deps[$os] = $os_lib_deps; $all_ext_lib_deps[$os] = $os_lib_deps;
@@ -246,22 +248,23 @@ class GenExtTestMatrixCommand extends BaseCommand
} }
} }
if (!empty($filter_extensions)) { if (!empty($filter_extensions) || !empty($filter_libs)) {
$entries = array_values(array_filter($entries, function (array $entry) use ($filter_extensions): bool { $entries = array_values(array_filter($entries, function (array $entry) use ($filter_extensions, $filter_libs, $all_ext_lib_deps): bool {
$names = explode(',', $entry['extension']); $names = explode(',', $entry['extension']);
return count(array_intersect($names, $filter_extensions)) > 0;
}));
}
if (!empty($filter_libs)) { if (!empty($filter_extensions) && count(array_intersect($names, $filter_extensions)) > 0) {
$entries = array_values(array_filter($entries, function (array $entry) use ($filter_libs, $all_ext_lib_deps): bool { return true;
$names = explode(',', $entry['extension']); }
$lib_deps = $all_ext_lib_deps[$entry['os']] ?? [];
foreach ($names as $name) { if (!empty($filter_libs)) {
if (count(array_intersect($lib_deps[$name] ?? [], $filter_libs)) > 0) { $lib_deps = $all_ext_lib_deps[$entry['os']] ?? [];
return true; foreach ($names as $name) {
if (count(array_intersect($lib_deps[$name] ?? [], $filter_libs)) > 0) {
return true;
}
} }
} }
return false; return false;
})); }));
} }
@@ -300,6 +303,41 @@ class GenExtTestMatrixCommand extends BaseCommand
return str_starts_with($pkg_name, 'ext-') ? substr($pkg_name, 4) : $pkg_name; return str_starts_with($pkg_name, 'ext-') ? substr($pkg_name, 4) : $pkg_name;
} }
/**
* Collect direct and transitive library dependencies from a package dependency list.
*
* @param string[] $deps
* @param array<string, mixed[]> $library_configs
* @param array<string, true> $seen
*
* @return string[]
*/
private function collectLibraryDeps(array $deps, array $library_configs, string $platform, array $seen = []): array
{
$collected = [];
foreach ($deps as $dep) {
if (str_starts_with($dep, 'ext-') || isset($seen[$dep])) {
continue;
}
$seen[$dep] = true;
$collected[$dep] = $dep;
if (!isset($library_configs[$dep])) {
continue;
}
$child_deps = array_merge(
$this->resolvePlatformList($library_configs[$dep], 'depends', $platform),
$this->resolvePlatformList($library_configs[$dep], 'suggests', $platform),
);
foreach ($this->collectLibraryDeps($child_deps, $library_configs, $platform, $seen) as $child_dep) {
$collected[$child_dep] = $child_dep;
}
}
return array_values($collected);
}
/** /**
* Split orphans into batches such that no two conflicting extensions share a batch. * Split orphans into batches such that no two conflicting extensions share a batch.
* Uses a greedy graph-coloring approach. * Uses a greedy graph-coloring approach.

View File

@@ -176,6 +176,31 @@ class GenExtTestMatrixCommandTest extends TestCase
} }
} }
/**
* --for-libs must include extensions that depend on the library through other libraries.
*/
public function testForLibsFilterIncludesTransitiveLibraryDeps(): void
{
$matrix = $this->runMatrix(['--os' => 'Linux', '--for-libs' => 'libde265']);
$this->assertNotEmpty($matrix, '--for-libs=libde265 must yield at least one entry');
foreach ($matrix as $entry) {
$parts = explode(',', $entry['extension']);
$this->assertContains('imagick', $parts, "Entry {$entry['extension']} should not appear in --for-libs=libde265 results");
}
}
/**
* Multiple filters should include entries matching any changed package.
*/
public function testExtensionAndLibraryFiltersAreCombinedAsUnion(): void
{
$matrix = $this->runMatrix(['--os' => 'Linux', '--for-extensions' => 'simdjson', '--for-libs' => 'libde265']);
$this->assertNotEmpty($this->findEntriesContaining($matrix, 'simdjson'), 'simdjson entry must be included');
$this->assertNotEmpty($this->findEntriesContaining($matrix, 'imagick'), 'imagick entry must be included through libde265');
}
/** /**
* --tier2 must produce only Tier2 runners and no Windows entries. * --tier2 must produce only Tier2 runners and no Windows entries.
*/ */
@@ -258,14 +283,17 @@ class GenExtTestMatrixCommandTest extends TestCase
* - ext-swoole-hook-* virtual (arg-type: none) — must be bundled with swoole * - ext-swoole-hook-* virtual (arg-type: none) — must be bundled with swoole
* - ext-curl simple orphan, depended on by swoole but must NOT be pulled into swoole entry * - ext-curl simple orphan, depended on by swoole but must NOT be pulled into swoole entry
* - ext-redis simple orphan * - ext-redis simple orphan
* - ext-simdjson simple orphan used for combined filter tests
* - ext-xml depends on lib 'libxml2' * - ext-xml depends on lib 'libxml2'
* - ext-dom depends on ext-xml (DFS chain) * - ext-dom depends on ext-xml (DFS chain)
* - ext-imagick depends on imagemagick -> libheif -> libde265
* - ext-linux-only restricted to Linux via os: [Linux] * - ext-linux-only restricted to Linux via os: [Linux]
*/ */
private static function buildFixture(): array private static function buildFixture(): array
{ {
// php-extension must be a non-empty assoc array ([] fails is_assoc_array() check). // php-extension must be a non-empty assoc array ([] fails is_assoc_array() check).
$ext = static fn (array $phpExt = ['arg-type' => 'standard'], array $topLevel = []): array => array_merge(['type' => 'php-extension', 'php-extension' => $phpExt], $topLevel); $ext = static fn (array $phpExt = ['arg-type' => 'standard'], array $topLevel = []): array => array_merge(['type' => 'php-extension', 'php-extension' => $phpExt], $topLevel);
$lib = static fn (array $topLevel = []): array => array_merge(['type' => 'library', 'artifact' => ['source' => 'custom']], $topLevel);
return [ return [
// Isolated standalones // Isolated standalones
@@ -279,11 +307,18 @@ class GenExtTestMatrixCommandTest extends TestCase
// Simple orphans // Simple orphans
'ext-curl' => $ext(), 'ext-curl' => $ext(),
'ext-redis' => $ext(), 'ext-redis' => $ext(),
'ext-simdjson' => $ext(),
// DFS chain: dom depends on xml; xml depends on lib 'libxml2' // DFS chain: dom depends on xml; xml depends on lib 'libxml2'
'ext-xml' => $ext(['arg-type' => 'standard'], ['depends' => ['libxml2']]), 'ext-xml' => $ext(['arg-type' => 'standard'], ['depends' => ['libxml2']]),
'ext-dom' => $ext(['arg-type' => 'standard'], ['depends' => ['ext-xml']]), 'ext-dom' => $ext(['arg-type' => 'standard'], ['depends' => ['ext-xml']]),
// Transitive library chain: imagick -> imagemagick -> libheif -> libde265
'ext-imagick' => $ext(['arg-type' => 'standard'], ['depends' => ['imagemagick']]),
'imagemagick' => $lib(['depends' => ['libheif']]),
'libheif' => $lib(['depends' => ['libde265']]),
'libde265' => $lib(),
// OS-restricted to Linux only // OS-restricted to Linux only
'ext-linux-only' => $ext(['os' => ['Linux']]), 'ext-linux-only' => $ext(['os' => ['Linux']]),
]; ];