Add zstd,libcares

This commit is contained in:
crazywhalecc 2026-02-02 16:15:36 +08:00
parent 3d102363c4
commit 6ee8dc7994
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
4 changed files with 109 additions and 0 deletions

View File

@ -0,0 +1,23 @@
libcares:
type: library
artifact:
source:
type: ghrel
repo: c-ares/c-ares
match: c-ares-.+\.tar\.gz
prefer-stable: true
source-mirror:
type: filelist
url: 'https://c-ares.org/download/'
regex: '/href="\/download\/(?<file>c-ares-(?<version>[^"]+)\.tar\.gz)"/'
binary: hosted
metadata:
license-files: [LICENSE.md]
headers@unix:
- ares.h
- ares_dns.h
- ares_nameser.h
static-libs@unix:
- libcares.a
pkg-configs:
- libcares

19
config/pkg/lib/zstd.yml Normal file
View File

@ -0,0 +1,19 @@
zstd:
type: library
artifact:
source:
type: ghrel
repo: facebook/zstd
match: zstd.+\.tar\.gz
prefer-stable: true
metadata:
license-files: [LICENSE]
license: BSD-3-Clause
headers@unix:
- zdict.h
- zstd.h
- zstd_errors.h
static-libs@unix:
- libzstd.a
pkg-configs:
- libzstd

View File

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Attribute\Package\PatchBeforeBuild;
use StaticPHP\Attribute\PatchDescription;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
use StaticPHP\Util\FileSystem;
#[Library('libcares')]
class libcares
{
#[PatchBeforeBuild]
#[PatchDescription('Add missing dnsinfo.h for Apple platforms')]
public function patchBeforeBuild(LibraryPackage $lib): bool
{
if (!file_exists("{$lib->getSourceDir()}/src/lib/thirdparty/apple/dnsinfo.h")) {
FileSystem::createDir("{$lib->getSourceDir()}/src/lib/thirdparty/apple");
copy(ROOT_DIR . '/src/globals/extra/libcares_dnsinfo.h', "{$lib->getSourceDir()}/src/lib/thirdparty/apple/dnsinfo.h");
return true;
}
return false;
}
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void
{
UnixAutoconfExecutor::create($lib)->configure('--disable-tests')->make();
$lib->patchPkgconfPrefix(['libcares.pc'], PKGCONF_PATCH_PREFIX);
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Package\Library;
use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
#[Library('zstd')]
class zstd
{
#[BuildFor('Linux')]
#[BuildFor('Darwin')]
public function build(LibraryPackage $lib): void
{
UnixCMakeExecutor::create($lib)
->setBuildDir("{$lib->getSourceDir()}/build/cmake/build")
->addConfigureArgs(
'-DZSTD_BUILD_STATIC=ON',
'-DZSTD_BUILD_SHARED=OFF',
)
->build();
$lib->patchPkgconfPrefix(['libzstd.pc'], PKGCONF_PATCH_PREFIX);
}
}