Add libzip

This commit is contained in:
crazywhalecc
2026-03-24 10:52:13 +08:00
parent 41f5948392
commit 1f42f1a479
2 changed files with 31 additions and 2 deletions

View File

@@ -8,9 +8,10 @@ libzip:
prefer-stable: true
metadata:
license-files: [LICENSE]
depends@unix:
license: BSD-3-Clause
depends:
- zlib
suggests@unix:
suggests:
- bzip2
- xz
- zstd
@@ -20,3 +21,5 @@ libzip:
- zipconf.h
static-libs@unix:
- libzip.a
static-libs@windows:
- libzip_a.lib

View File

@@ -8,6 +8,8 @@ use StaticPHP\Attribute\Package\BuildFor;
use StaticPHP\Attribute\Package\Library;
use StaticPHP\Package\LibraryPackage;
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
use StaticPHP\Runtime\Executor\WindowsCMakeExecutor;
use StaticPHP\Util\FileSystem;
#[Library('libzip')]
class libzip
@@ -33,4 +35,28 @@ class libzip
->build();
$lib->patchPkgconfPrefix(['libzip.pc'], PKGCONF_PATCH_PREFIX);
}
#[BuildFor('Windows')]
public function buildWin(LibraryPackage $lib): void
{
WindowsCMakeExecutor::create($lib)
->optionalPackage('bzip2', ...cmake_boolean_args('ENABLE_BZIP2'))
->optionalPackage('xz', ...cmake_boolean_args('ENABLE_LZMA'))
->optionalPackage('openssl', ...cmake_boolean_args('ENABLE_OPENSSL'))
->optionalPackage('zstd', ...cmake_boolean_args('ENABLE_ZSTD'))
->addConfigureArgs(
'-DENABLE_GNUTLS=OFF',
'-DENABLE_MBEDTLS=OFF',
'-DBUILD_DOC=OFF',
'-DBUILD_EXAMPLES=OFF',
'-DBUILD_REGRESS=OFF',
'-DBUILD_TOOLS=OFF',
'-DBUILD_OSSFUZZ=OFF',
)
->build();
FileSystem::copy(
$lib->getBuildRootPath() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'zip.lib',
$lib->getBuildRootPath() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'libzip_a.lib'
);
}
}