mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
bzip2, fastlz, jbig, qdbm: thread SPC_DEFAULT_CFLAGS into the
hand-rolled Makefile patches and shell compile commands. Backward
compatible when the env var is empty.
icu: append SPC_DEFAULT_CXXFLAGS/LDFLAGS to runConfigureICU's CXXFLAGS
and LDFLAGS so user flags reach the bundled cxx invocation.
openssl: append user CFLAGS/LDFLAGS after the target name on Configure
so options like -flto and -fprofile-* reach the openssl build.
libheif: rewrite libheif 1.22+'s C-incompatible
`struct heif_bad_pixel { uint32_t row; uint32_t column; };` as a
typedef so C consumers compile.
ncurses: filter the clang/zig-cc "N warning(s) generated." stdout line
out of MKlib_gen.sh's preprocessor pipe before sed turns it into
invalid C in lib_gen.c.
libaom: detect target CPU from SystemTarget instead of hard-coding
generic, fall back to generic only when neither nasm nor yasm is
available, and turn off examples/tests/tools/docs.
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?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';
|
|
$extra = trim((string) getenv('SPC_DEFAULT_CFLAGS'));
|
|
$extra = $extra !== '' ? $extra . ' -fPIC' : '-O3 -fPIC';
|
|
|
|
shell()->cd($lib->getSourceDir())->initializeEnv($lib)
|
|
->exec("{$cc} -c {$extra} 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');
|
|
}
|
|
}
|
|
}
|