mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +08:00
Merge remote-tracking branch 'origin/main' into feat/craft
This commit is contained in:
commit
d275a44895
@ -958,7 +958,6 @@
|
|||||||
},
|
},
|
||||||
"xlswriter": {
|
"xlswriter": {
|
||||||
"support": {
|
"support": {
|
||||||
"Windows": "wip",
|
|
||||||
"BSD": "wip"
|
"BSD": "wip"
|
||||||
},
|
},
|
||||||
"type": "external",
|
"type": "external",
|
||||||
|
|||||||
@ -18,4 +18,23 @@ class xlswriter extends Extension
|
|||||||
}
|
}
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getWindowsConfigureArg(): string
|
||||||
|
{
|
||||||
|
return '--with-xlswriter';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function patchBeforeMake(): bool
|
||||||
|
{
|
||||||
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
|
$content = file_get_contents($this->source_dir . '/library/libxlsxwriter/src/theme.c');
|
||||||
|
$bom = pack('CCC', 0xEF, 0xBB, 0xBF);
|
||||||
|
if (substr($content, 0, 3) !== $bom) {
|
||||||
|
file_put_contents($this->source_dir . '/library/libxlsxwriter/src/theme.c', $content);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ trait attr
|
|||||||
'LIBS' => $this->getLibExtraLibs(),
|
'LIBS' => $this->getLibExtraLibs(),
|
||||||
])
|
])
|
||||||
->execWithEnv('libtoolize --force --copy')
|
->execWithEnv('libtoolize --force --copy')
|
||||||
->execWithEnv('./autogen.sh')
|
->execWithEnv('./autogen.sh || autoreconf -if')
|
||||||
->execWithEnv('./configure --prefix= --enable-static --disable-shared --with-pic --disable-nls')
|
->execWithEnv('./configure --prefix= --enable-static --disable-shared --with-pic --disable-nls')
|
||||||
->execWithEnv("make -j {$this->builder->concurrency}")
|
->execWithEnv("make -j {$this->builder->concurrency}")
|
||||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
|
|||||||
@ -36,7 +36,7 @@ trait libacl
|
|||||||
'LIBS' => $this->getLibExtraLibs(),
|
'LIBS' => $this->getLibExtraLibs(),
|
||||||
])
|
])
|
||||||
->execWithEnv('libtoolize --force --copy')
|
->execWithEnv('libtoolize --force --copy')
|
||||||
->execWithEnv('./autogen.sh')
|
->execWithEnv('./autogen.sh || autoreconf -if')
|
||||||
->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls')
|
->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls')
|
||||||
->execWithEnv("make -j {$this->builder->concurrency}")
|
->execWithEnv("make -j {$this->builder->concurrency}")
|
||||||
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
|
|||||||
@ -79,9 +79,11 @@ class PackLibCommand extends BuildCommand
|
|||||||
'{libc}' => getenv('SPC_LIBC') ?: 'default',
|
'{libc}' => getenv('SPC_LIBC') ?: 'default',
|
||||||
'{libcver}' => PHP_OS_FAMILY === 'Linux' ? (SystemUtil::getLibcVersionIfExists() ?? 'default') : 'default',
|
'{libcver}' => PHP_OS_FAMILY === 'Linux' ? (SystemUtil::getLibcVersionIfExists() ?? 'default') : 'default',
|
||||||
];
|
];
|
||||||
|
// detect suffix, for proper tar option
|
||||||
|
$tar_option = $this->getTarOptionFromSuffix(Config::getPreBuilt('match-pattern'));
|
||||||
$filename = str_replace(array_keys($replace), array_values($replace), $filename);
|
$filename = str_replace(array_keys($replace), array_values($replace), $filename);
|
||||||
$filename = WORKING_DIR . '/dist/' . $filename;
|
$filename = WORKING_DIR . '/dist/' . $filename;
|
||||||
f_passthru('tar -czf ' . $filename . ' -T ' . WORKING_DIR . '/packlib_files.txt');
|
f_passthru("tar {$tar_option} {$filename} -T " . WORKING_DIR . '/packlib_files.txt');
|
||||||
logger()->info('Pack library ' . $lib->getName() . ' to ' . $filename . ' complete.');
|
logger()->info('Pack library ' . $lib->getName() . ' to ' . $filename . ' complete.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,4 +117,30 @@ class PackLibCommand extends BuildCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get tar compress options from suffix
|
||||||
|
*
|
||||||
|
* @param string $name Package file name
|
||||||
|
* @return string Tar options for packaging libs
|
||||||
|
*/
|
||||||
|
private function getTarOptionFromSuffix(string $name): string
|
||||||
|
{
|
||||||
|
if (str_ends_with($name, '.tar')) {
|
||||||
|
return '-cf';
|
||||||
|
}
|
||||||
|
if (str_ends_with($name, '.tar.gz') || str_ends_with($name, '.tgz')) {
|
||||||
|
return '-czf';
|
||||||
|
}
|
||||||
|
if (str_ends_with($name, '.tar.bz2') || str_ends_with($name, '.tbz2')) {
|
||||||
|
return '-cjf';
|
||||||
|
}
|
||||||
|
if (str_ends_with($name, '.tar.xz') || str_ends_with($name, '.txz')) {
|
||||||
|
return '-cJf';
|
||||||
|
}
|
||||||
|
if (str_ends_with($name, '.tar.lz') || str_ends_with($name, '.tlz')) {
|
||||||
|
return '-c --lzma -f';
|
||||||
|
}
|
||||||
|
return '-cf';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,6 +121,7 @@ class Downloader
|
|||||||
retries: self::getRetryAttempts()
|
retries: self::getRetryAttempts()
|
||||||
), true);
|
), true);
|
||||||
$url = null;
|
$url = null;
|
||||||
|
$filename = null;
|
||||||
foreach ($data as $release) {
|
foreach ($data as $release) {
|
||||||
if (($source['prefer-stable'] ?? false) === true && $release['prerelease'] === true) {
|
if (($source['prefer-stable'] ?? false) === true && $release['prerelease'] === true) {
|
||||||
continue;
|
continue;
|
||||||
@ -131,16 +132,16 @@ class Downloader
|
|||||||
}
|
}
|
||||||
foreach ($release['assets'] as $asset) {
|
foreach ($release['assets'] as $asset) {
|
||||||
if (preg_match('|' . $source['match'] . '|', $asset['name'])) {
|
if (preg_match('|' . $source['match'] . '|', $asset['name'])) {
|
||||||
$url = $asset['browser_download_url'];
|
$url = "https://api.github.com/repos/{$source['repo']}/releases/assets/{$asset['id']}";
|
||||||
|
$filename = $asset['name'];
|
||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$url) {
|
if (!$url || !$filename) {
|
||||||
throw new DownloaderException("failed to find {$name} release metadata");
|
throw new DownloaderException("failed to find {$name} release metadata");
|
||||||
}
|
}
|
||||||
$filename = basename($url);
|
|
||||||
|
|
||||||
return [$url, $filename];
|
return [$url, $filename];
|
||||||
}
|
}
|
||||||
@ -191,7 +192,7 @@ class Downloader
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* @throws WrongUsageException
|
* @throws WrongUsageException
|
||||||
*/
|
*/
|
||||||
public static function downloadFile(string $name, string $url, string $filename, ?string $move_path = null, int $download_as = SPC_DOWNLOAD_SOURCE): void
|
public static function downloadFile(string $name, string $url, string $filename, ?string $move_path = null, int $download_as = SPC_DOWNLOAD_SOURCE, array $headers = [], array $hooks = []): void
|
||||||
{
|
{
|
||||||
logger()->debug("Downloading {$url}");
|
logger()->debug("Downloading {$url}");
|
||||||
$cancel_func = function () use ($filename) {
|
$cancel_func = function () use ($filename) {
|
||||||
@ -201,7 +202,7 @@ class Downloader
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
self::registerCancelEvent($cancel_func);
|
self::registerCancelEvent($cancel_func);
|
||||||
self::curlDown(url: $url, path: FileSystem::convertPath(DOWNLOAD_PATH . "/{$filename}"), retries: self::getRetryAttempts());
|
self::curlDown(url: $url, path: FileSystem::convertPath(DOWNLOAD_PATH . "/{$filename}"), headers: $headers, hooks: $hooks, retries: self::getRetryAttempts());
|
||||||
self::unregisterCancelEvent();
|
self::unregisterCancelEvent();
|
||||||
logger()->debug("Locking {$filename}");
|
logger()->debug("Locking {$filename}");
|
||||||
if ($download_as === SPC_DOWNLOAD_PRE_BUILT) {
|
if ($download_as === SPC_DOWNLOAD_PRE_BUILT) {
|
||||||
@ -341,15 +342,15 @@ class Downloader
|
|||||||
break;
|
break;
|
||||||
case 'ghtar': // GitHub Release (tar)
|
case 'ghtar': // GitHub Release (tar)
|
||||||
[$url, $filename] = self::getLatestGithubTarball($name, $pkg);
|
[$url, $filename] = self::getLatestGithubTarball($name, $pkg);
|
||||||
self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null, SPC_DOWNLOAD_PACKAGE);
|
self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null, SPC_DOWNLOAD_PACKAGE, hooks: [[CurlHook::class, 'setupGithubToken']]);
|
||||||
break;
|
break;
|
||||||
case 'ghtagtar': // GitHub Tag (tar)
|
case 'ghtagtar': // GitHub Tag (tar)
|
||||||
[$url, $filename] = self::getLatestGithubTarball($name, $pkg, 'tags');
|
[$url, $filename] = self::getLatestGithubTarball($name, $pkg, 'tags');
|
||||||
self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null, SPC_DOWNLOAD_PACKAGE);
|
self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null, SPC_DOWNLOAD_PACKAGE, hooks: [[CurlHook::class, 'setupGithubToken']]);
|
||||||
break;
|
break;
|
||||||
case 'ghrel': // GitHub Release (uploaded)
|
case 'ghrel': // GitHub Release (uploaded)
|
||||||
[$url, $filename] = self::getLatestGithubRelease($name, $pkg);
|
[$url, $filename] = self::getLatestGithubRelease($name, $pkg);
|
||||||
self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null, SPC_DOWNLOAD_PACKAGE);
|
self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null, SPC_DOWNLOAD_PACKAGE, ['Accept: application/octet-stream'], [[CurlHook::class, 'setupGithubToken']]);
|
||||||
break;
|
break;
|
||||||
case 'filelist': // Basic File List (regex based crawler)
|
case 'filelist': // Basic File List (regex based crawler)
|
||||||
[$url, $filename] = self::getFromFileList($name, $pkg);
|
[$url, $filename] = self::getFromFileList($name, $pkg);
|
||||||
@ -447,15 +448,15 @@ class Downloader
|
|||||||
break;
|
break;
|
||||||
case 'ghtar': // GitHub Release (tar)
|
case 'ghtar': // GitHub Release (tar)
|
||||||
[$url, $filename] = self::getLatestGithubTarball($name, $source);
|
[$url, $filename] = self::getLatestGithubTarball($name, $source);
|
||||||
self::downloadFile($name, $url, $filename, $source['path'] ?? null, $download_as);
|
self::downloadFile($name, $url, $filename, $source['path'] ?? null, $download_as, hooks: [[CurlHook::class, 'setupGithubToken']]);
|
||||||
break;
|
break;
|
||||||
case 'ghtagtar': // GitHub Tag (tar)
|
case 'ghtagtar': // GitHub Tag (tar)
|
||||||
[$url, $filename] = self::getLatestGithubTarball($name, $source, 'tags');
|
[$url, $filename] = self::getLatestGithubTarball($name, $source, 'tags');
|
||||||
self::downloadFile($name, $url, $filename, $source['path'] ?? null, $download_as);
|
self::downloadFile($name, $url, $filename, $source['path'] ?? null, $download_as, hooks: [[CurlHook::class, 'setupGithubToken']]);
|
||||||
break;
|
break;
|
||||||
case 'ghrel': // GitHub Release (uploaded)
|
case 'ghrel': // GitHub Release (uploaded)
|
||||||
[$url, $filename] = self::getLatestGithubRelease($name, $source);
|
[$url, $filename] = self::getLatestGithubRelease($name, $source);
|
||||||
self::downloadFile($name, $url, $filename, $source['path'] ?? null, $download_as);
|
self::downloadFile($name, $url, $filename, $source['path'] ?? null, $download_as, ['Accept: application/octet-stream'], [[CurlHook::class, 'setupGithubToken']]);
|
||||||
break;
|
break;
|
||||||
case 'filelist': // Basic File List (regex based crawler)
|
case 'filelist': // Basic File List (regex based crawler)
|
||||||
[$url, $filename] = self::getFromFileList($name, $source);
|
[$url, $filename] = self::getFromFileList($name, $source);
|
||||||
|
|||||||
@ -13,23 +13,23 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
// test php version (8.1 ~ 8.4 available, multiple for matrix)
|
||||||
$test_php_version = [
|
$test_php_version = [
|
||||||
// '8.1',
|
'8.1',
|
||||||
// '8.2',
|
'8.2',
|
||||||
// '8.3',
|
'8.3',
|
||||||
'8.4',
|
'8.4',
|
||||||
];
|
];
|
||||||
|
|
||||||
// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
|
// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
|
||||||
$test_os = [
|
$test_os = [
|
||||||
// 'macos-13',
|
// 'macos-13',
|
||||||
'macos-14',
|
// 'macos-14',
|
||||||
'macos-15',
|
// 'macos-15',
|
||||||
// 'ubuntu-latest',
|
// 'ubuntu-latest',
|
||||||
// 'ubuntu-22.04',
|
// 'ubuntu-22.04',
|
||||||
// 'ubuntu-24.04',
|
// 'ubuntu-24.04',
|
||||||
// 'ubuntu-22.04-arm',
|
// 'ubuntu-22.04-arm',
|
||||||
// 'ubuntu-24.04-arm',
|
// 'ubuntu-24.04-arm',
|
||||||
// 'windows-latest',
|
'windows-latest',
|
||||||
];
|
];
|
||||||
|
|
||||||
// whether enable thread safe
|
// whether enable thread safe
|
||||||
@ -46,7 +46,7 @@ $prefer_pre_built = false;
|
|||||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||||
$extensions = match (PHP_OS_FAMILY) {
|
$extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'pgsql',
|
'Linux', 'Darwin' => 'pgsql',
|
||||||
'Windows' => 'ev',
|
'Windows' => 'xlswriter',
|
||||||
};
|
};
|
||||||
|
|
||||||
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
|
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user