[web-downloads] main: Add arm64 support to winlibs

From: Date: Wed, 22 Apr 2026 02:24:43 +0000
Subject: [web-downloads] main: Add arm64 support to winlibs
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-33683@lists.php.net to get a copy of this message
Author: Shivam Mathur (shivammathur) Date: 2026-04-22T07:54:17+05:30 Commit: https://github.com/php/web-downloads/commit/a0633d9ffe206fda7f70a7c5d21c19d995b6f712 Raw diff: https://github.com/php/web-downloads/commit/a0633d9ffe206fda7f70a7c5d21c19d995b6f712.diff Add arm64 support to winlibs Changed paths: M src/Console/Command/WinlibsCommand.php M tests/Console/Command/WinlibsCommandTest.php Diff: diff --git a/src/Console/Command/WinlibsCommand.php b/src/Console/Command/WinlibsCommand.php index 81ac219..f85b5af 100644 --- a/src/Console/Command/WinlibsCommand.php +++ b/src/Console/Command/WinlibsCommand.php @@ -165,21 +165,26 @@ private function updatePhpSeriesFiles( $fileName = str_replace($file['artifact_name'], $library, $file['file_name']); $arch = $file['arch']; $seriesFile = $baseDirectory . "/packages-$php_version-$vs_version_target-$arch-$stability_value.txt"; + if (!file_exists($seriesFile) && $arch === 'arm64') { + $this->seedArm64SeriesFile($baseDirectory, $php_version, $vs_version_target, $stability_value); + } + if (!file_exists($seriesFile)) { $file_lines = [$fileName]; } else { $file_lines = file($seriesFile, FILE_IGNORE_NEW_LINES); - $found = false; - foreach ($file_lines as $no => $line) { - if (str_starts_with($line, $library)) { - $file_lines[$no] = $fileName; - $found = true; - } - } - if (!$found) { - $file_lines[] = $fileName; + } + + $found = false; + foreach ($file_lines as $no => $line) { + if (str_starts_with($line, $library)) { + $file_lines[$no] = $fileName; + $found = true; } } + if (!$found) { + $file_lines[] = $fileName; + } file_put_contents($seriesFile, implode("\n", $file_lines)); } } @@ -187,6 +192,23 @@ private function updatePhpSeriesFiles( } } + private function seedArm64SeriesFile( + string $baseDirectory, + string $phpVersion, + string $vsVersionTarget, + string $stability + ): void { + $arm64SeriesFile = $baseDirectory . "/packages-$phpVersion-$vsVersionTarget-arm64-$stability.txt"; + if (file_exists($arm64SeriesFile)) { + return; + } + + $x64SeriesFile = $baseDirectory . "/packages-$phpVersion-$vsVersionTarget-x64-$stability.txt"; + if (file_exists($x64SeriesFile)) { + copy($x64SeriesFile, $arm64SeriesFile); + } + } + private function updatePackagesFile(array $files, string $library): void { $baseDirectory = $this->baseDirectory . "/pecl/deps"; diff --git a/tests/Console/Command/WinlibsCommandTest.php b/tests/Console/Command/WinlibsCommandTest.php index 2b8512b..03dad63 100644 --- a/tests/Console/Command/WinlibsCommandTest.php +++ b/tests/Console/Command/WinlibsCommandTest.php @@ -186,6 +186,14 @@ public function testSuccessfulPeclFileOperations(): void $this->assertFileExists($this->baseDirectory . "/pecl/deps/$library-$ref-$vsVersion-$arch.zip"); } + public function testSuccessfulPeclArm64FileOperations(): void + { + $result = $this->runPeclWinlibsCommand('redis', 'phpredis', '5.3.7', 'vs16', 'arm64'); + + $this->assertSame(0, $result, 'Command should return success.'); + $this->assertFileExists($this->baseDirectory . '/pecl/deps/phpredis-5.3.7-vs16-arm64.zip'); + } + public function testPackagesFileIsGenerated(): void { $result = $this->runPeclWinlibsCommand('redis', 'phpredis', '5.3.7', 'vs16', 'x64'); @@ -331,6 +339,100 @@ public function testCopiesPhpSdkFilesWithoutUpdatingSeriesWhenDisabled(): void ); } + public function testCreatesMissingPhpSdkArm64DirectoryAndCopiesArtifact(): void + { + mkdir($this->winlibsDirectory . '/curl', 0755, true); + + $library = 'curl'; + $ref = '8.8.0'; + $phpVersion = '8.4'; + $vsVersion = 'vs17'; + $arch = 'arm64'; + + file_put_contents($this->winlibsDirectory . '/curl/data.json', json_encode([ + 'type' => 'php', + 'library' => $library, + 'ref' => $ref, + 'vs_version_targets' => $vsVersion, + 'php_versions' => $phpVersion, + 'stability' => 'staging', + 'update_series' => 'false', + ])); + + $zipPath = $this->winlibsDirectory . "/curl/curl-$ref-$vsVersion-$arch.zip"; + $zip = new ZipArchive(); + if ($zip->open($zipPath, ZipArchive::CREATE) === TRUE) { + $zip->addFromString('dummy_file.txt', 'dummy content'); + $zip->close(); + } + + $command = new WinlibsCommand(); + $command->setOption('base-directory', $this->baseDirectory); + $command->setOption('builds-directory', $this->buildsDirectory); + + $result = $command->handle(); + + $this->assertSame(0, $result); + $this->assertDirectoryExists($this->baseDirectory . "/php-sdk/deps/$vsVersion/$arch"); + $this->assertFileExists($this->baseDirectory . "/php-sdk/deps/$vsVersion/$arch/curl-$ref-$vsVersion-$arch.zip"); + } + + public function testSeedsMissingArm64SeriesFileFromX64BeforeReplacingLibrary(): void + { + mkdir($this->winlibsDirectory . '/curl', 0755, true); + mkdir($this->baseDirectory . '/php-sdk/deps/series', 0755, true); + + $library = 'curl'; + $ref = '8.8.0'; + $phpVersion = '8.4'; + $vsVersion = 'vs17'; + $arch = 'arm64'; + $stability = 'staging'; + + file_put_contents( + $this->baseDirectory . "/php-sdk/deps/series/packages-$phpVersion-$vsVersion-x64-$stability.txt", + implode("\n", [ + "curl-8.7.1-$vsVersion-x64.zip", + "openssl-3.4.1-$vsVersion-x64.zip", + ]) + ); + + file_put_contents($this->winlibsDirectory . '/curl/data.json', json_encode([ + 'type' => 'php', + 'library' => $library, + 'ref' => $ref, + 'vs_version_targets' => $vsVersion, + 'php_versions' => $phpVersion, + 'stability' => $stability, + 'update_series' => 'true', + ])); + + $zipPath = $this->winlibsDirectory . "/curl/curl-$ref-$vsVersion-$arch.zip"; + $zip = new ZipArchive(); + if ($zip->open($zipPath, ZipArchive::CREATE) === TRUE) { + $zip->addFromString('dummy_file.txt', 'dummy content'); + $zip->close(); + } + + $command = new WinlibsCommand(); + $command->setOption('base-directory', $this->baseDirectory); + $command->setOption('builds-directory', $this->buildsDirectory); + + $result = $command->handle(); + + $this->assertSame(0, $result); + $this->assertSame( + [ + "curl-$ref-$vsVersion-$arch.zip", + "openssl-3.4.1-$vsVersion-x64.zip", + ], + file( + $this->baseDirectory . "/php-sdk/deps/series/packages-$phpVersion-$vsVersion-$arch-$stability.txt", + FILE_IGNORE_NEW_LINES + ) + ); + } + public function testCommandHandlesMissingBaseDirectory(): void { $command = new WinlibsCommand(); @@ -447,6 +549,14 @@ public static function fileProvider(): array 'vs_version' => 'vs16', 'arch' => 'x86', ]], + ['/tmp/curl-8.8.0-vs17-arm64.zip', [ + 'file_path' => '/tmp/curl-8.8.0-vs17-arm64.zip', + 'file_name' => 'curl-8.8.0-vs17-arm64.zip', + 'extension' => 'zip', + 'artifact_name' => 'curl', + 'vs_version' => 'vs17', + 'arch' => 'arm64', + ]], ]; }

« previous php.webmaster (#33683) next »