diff --git a/src/Platform/PrePackagedBinaryAssetName.php b/src/Platform/PrePackagedBinaryAssetName.php index eda3f94..a291a87 100644 --- a/src/Platform/PrePackagedBinaryAssetName.php +++ b/src/Platform/PrePackagedBinaryAssetName.php @@ -21,51 +21,32 @@ final class PrePackagedBinaryAssetName /** @return non-empty-list */ public static function packageNames(TargetPlatform $targetPlatform, Package $package): array { - return array_values(array_unique([ - strtolower(sprintf( - 'php_%s-%s_php%s-%s-%s-%s%s%s.zip', - $package->extensionName()->name(), - $package->version(), - $targetPlatform->phpBinaryPath->majorMinorVersion(), - $targetPlatform->architecture->name, - $targetPlatform->operatingSystemFamily->value, - $targetPlatform->libcFlavour()->value, - $targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '', - $targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '', - )), - strtolower(sprintf( - 'php_%s-%s_php%s-%s-%s-%s%s%s.tgz', - $package->extensionName()->name(), - $package->version(), - $targetPlatform->phpBinaryPath->majorMinorVersion(), - $targetPlatform->architecture->name, - $targetPlatform->operatingSystemFamily->value, - $targetPlatform->libcFlavour()->value, - $targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '', - $targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '', - )), - strtolower(sprintf( - 'php_%s-%s_php%s-%s-%s-%s%s%s.zip', - $package->extensionName()->name(), - $package->version(), - $targetPlatform->phpBinaryPath->majorMinorVersion(), - $targetPlatform->architecture->name, - $targetPlatform->operatingSystemFamily->value, - $targetPlatform->libcFlavour()->value, - $targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '', - $targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '-nts', - )), - strtolower(sprintf( - 'php_%s-%s_php%s-%s-%s-%s%s%s.tgz', - $package->extensionName()->name(), - $package->version(), - $targetPlatform->phpBinaryPath->majorMinorVersion(), - $targetPlatform->architecture->name, - $targetPlatform->operatingSystemFamily->value, - $targetPlatform->libcFlavour()->value, - $targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : '', - $targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '-nts', - )), - ])); + $debug = $targetPlatform->phpBinaryPath->debugMode() === DebugBuild::Debug ? '-debug' : ''; + $tsNoSuffix = $targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : ''; + $tsWithSuffix = $targetPlatform->threadSafety === ThreadSafetyMode::ThreadSafe ? '-zts' : '-nts'; + $libc = $targetPlatform->libcFlavour()->value; + + $name = $package->extensionName()->name(); + $version = $package->version(); + $phpVer = $targetPlatform->phpBinaryPath->majorMinorVersion(); + $arch = $targetPlatform->architecture->name; + $os = $targetPlatform->operatingSystemFamily->value; + + $names = [ + strtolower(sprintf('php_%s-%s_php%s-%s-%s-%s%s%s.zip', $name, $version, $phpVer, $arch, $os, $libc, $debug, $tsNoSuffix)), + strtolower(sprintf('php_%s-%s_php%s-%s-%s-%s%s%s.tgz', $name, $version, $phpVer, $arch, $os, $libc, $debug, $tsNoSuffix)), + strtolower(sprintf('php_%s-%s_php%s-%s-%s-%s%s%s.zip', $name, $version, $phpVer, $arch, $os, $libc, $debug, $tsWithSuffix)), + strtolower(sprintf('php_%s-%s_php%s-%s-%s-%s%s%s.tgz', $name, $version, $phpVer, $arch, $os, $libc, $debug, $tsWithSuffix)), + ]; + + // Fallbacks with anylibc suffix, for unified binaries compatible with both glibc and musl (Linux only) + if ($targetPlatform->operatingSystemFamily === OperatingSystemFamily::Linux) { + $names[] = strtolower(sprintf('php_%s-%s_php%s-%s-%s-anylibc%s%s.zip', $name, $version, $phpVer, $arch, $os, $debug, $tsNoSuffix)); + $names[] = strtolower(sprintf('php_%s-%s_php%s-%s-%s-anylibc%s%s.tgz', $name, $version, $phpVer, $arch, $os, $debug, $tsNoSuffix)); + $names[] = strtolower(sprintf('php_%s-%s_php%s-%s-%s-anylibc%s%s.zip', $name, $version, $phpVer, $arch, $os, $debug, $tsWithSuffix)); + $names[] = strtolower(sprintf('php_%s-%s_php%s-%s-%s-anylibc%s%s.tgz', $name, $version, $phpVer, $arch, $os, $debug, $tsWithSuffix)); + } + + return array_values(array_unique($names)); } } diff --git a/test/unit/Downloading/DownloadUrlMethodTest.php b/test/unit/Downloading/DownloadUrlMethodTest.php index 442f4be..93478b5 100644 --- a/test/unit/Downloading/DownloadUrlMethodTest.php +++ b/test/unit/Downloading/DownloadUrlMethodTest.php @@ -149,6 +149,8 @@ final class DownloadUrlMethodTest extends TestCase [ 'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug-zts.zip', 'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug-zts.tgz', + 'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug-zts.zip', + 'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug-zts.tgz', ], $downloadUrlMethod->possibleAssetNames($package, $targetPlatform), ); @@ -227,6 +229,10 @@ final class DownloadUrlMethodTest extends TestCase 'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug.tgz', 'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug-nts.zip', 'php_bar-1.2.3_php8.3-x86_64-linux-glibc-debug-nts.tgz', + 'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug.zip', + 'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug.tgz', + 'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug-nts.zip', + 'php_bar-1.2.3_php8.3-x86_64-linux-anylibc-debug-nts.tgz', ], $firstMethod->possibleAssetNames($package, $targetPlatform), ); diff --git a/test/unit/Platform/PrePackagedBinaryAssetNameTest.php b/test/unit/Platform/PrePackagedBinaryAssetNameTest.php index 66f7078..4110220 100644 --- a/test/unit/Platform/PrePackagedBinaryAssetNameTest.php +++ b/test/unit/Platform/PrePackagedBinaryAssetNameTest.php @@ -46,6 +46,10 @@ final class PrePackagedBinaryAssetNameTest extends TestCase 'php_foobar-1.2.3_php8.2-x86_64-linux-' . $libc->value . '.tgz', 'php_foobar-1.2.3_php8.2-x86_64-linux-' . $libc->value . '-nts.zip', 'php_foobar-1.2.3_php8.2-x86_64-linux-' . $libc->value . '-nts.tgz', + 'php_foobar-1.2.3_php8.2-x86_64-linux-anylibc.zip', + 'php_foobar-1.2.3_php8.2-x86_64-linux-anylibc.tgz', + 'php_foobar-1.2.3_php8.2-x86_64-linux-anylibc-nts.zip', + 'php_foobar-1.2.3_php8.2-x86_64-linux-anylibc-nts.tgz', ], PrePackagedBinaryAssetName::packageNames( $targetPlatform, @@ -83,6 +87,8 @@ final class PrePackagedBinaryAssetNameTest extends TestCase [ 'php_foobar-1.2.3_php8.3-x86_64-linux-' . $libc->value . '-zts.zip', 'php_foobar-1.2.3_php8.3-x86_64-linux-' . $libc->value . '-zts.tgz', + 'php_foobar-1.2.3_php8.3-x86_64-linux-anylibc-zts.zip', + 'php_foobar-1.2.3_php8.3-x86_64-linux-anylibc-zts.tgz', ], PrePackagedBinaryAssetName::packageNames( $targetPlatform,