mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
Implement fastlz, zlib (unix)
This commit is contained in:
parent
22fc7030f6
commit
c27ed8b0b4
@ -31,3 +31,22 @@ bzip2:
|
||||
metadata:
|
||||
license-files: ['{registry_root}/src/globals/licenses/bzip2.txt']
|
||||
license: bzip2-1.0.6
|
||||
|
||||
fastlz:
|
||||
source:
|
||||
type: git
|
||||
url: 'https://github.com/ariya/FastLZ.git'
|
||||
rev: master
|
||||
metadata:
|
||||
license-files: ['LICENSE.MIT']
|
||||
license: MIT
|
||||
|
||||
zlib:
|
||||
source:
|
||||
type: ghrel
|
||||
repo: madler/zlib
|
||||
match: 'zlib.+\.tar\.gz'
|
||||
binary: hosted
|
||||
metadata:
|
||||
license-files: ['{registry_root}/src/globals/licenses/zlib.txt']
|
||||
license: Zlib-Custom
|
||||
|
||||
@ -19,3 +19,20 @@ bzip2:
|
||||
headers:
|
||||
- bzlib.h
|
||||
artifact: bzip2
|
||||
|
||||
fastlz:
|
||||
type: library
|
||||
static-libs@unix:
|
||||
- libfastlz.a
|
||||
headers:
|
||||
- fastlz.h
|
||||
artifact: fastlz
|
||||
|
||||
zlib:
|
||||
type: library
|
||||
static-libs@unix:
|
||||
- libz.a
|
||||
headers:
|
||||
- zlib.h
|
||||
- zconf.h
|
||||
artifact: zlib
|
||||
|
||||
36
src/Package/Library/fastlz.php
Normal file
36
src/Package/Library/fastlz.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Exception\BuildFailureException;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
|
||||
#[Library('fastlz')]
|
||||
class fastlz
|
||||
{
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
{
|
||||
$cc = getenv('CC') ?: 'cc';
|
||||
$ar = getenv('AR') ?: 'ar';
|
||||
|
||||
shell()->cd($lib->getSourceDir())->initializeEnv($lib)
|
||||
->exec("{$cc} -c -O3 -fPIC fastlz.c -o fastlz.o")
|
||||
->exec("{$ar} rcs libfastlz.a fastlz.o");
|
||||
|
||||
// Copy header file
|
||||
if (!copy($lib->getSourceDir() . '/fastlz.h', $lib->getIncludeDir() . '/fastlz.h')) {
|
||||
throw new BuildFailureException('Failed to copy fastlz.h');
|
||||
}
|
||||
|
||||
// Copy static library
|
||||
if (!copy($lib->getSourceDir() . '/libfastlz.a', $lib->getLibDir() . '/libfastlz.a')) {
|
||||
throw new BuildFailureException('Failed to copy libfastlz.a');
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/Package/Library/zlib.php
Normal file
24
src/Package/Library/zlib.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?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\UnixAutoconfExecutor;
|
||||
|
||||
#[Library('zlib')]
|
||||
class zlib
|
||||
{
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($lib)->exec("./configure --static --prefix={$lib->getBuildRootPath()}")->make();
|
||||
|
||||
// Patch pkg-config file
|
||||
$lib->patchPkgconfPrefix(['zlib.pc'], PKGCONF_PATCH_PREFIX);
|
||||
}
|
||||
}
|
||||
20
src/globals/licenses/zlib.txt
Normal file
20
src/globals/licenses/zlib.txt
Normal file
@ -0,0 +1,20 @@
|
||||
(C) 1995-2022 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
Loading…
x
Reference in New Issue
Block a user