mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 00:05:42 +08:00
26 lines
845 B
PHP
26 lines
845 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\builder\unix\library;
|
|
|
|
use SPC\exception\BuildFailureException;
|
|
|
|
trait fastlz
|
|
{
|
|
protected function build(): void
|
|
{
|
|
$extra = trim((string) getenv('SPC_DEFAULT_C_FLAGS'));
|
|
shell()->cd($this->source_dir)->initializeEnv($this)
|
|
->exec((getenv('CC') ?: 'cc') . " -c {$extra} fastlz.c -o fastlz.o")
|
|
->exec((getenv('AR') ?: 'ar') . ' rcs libfastlz.a fastlz.o');
|
|
|
|
if (!copy($this->source_dir . '/fastlz.h', BUILD_INCLUDE_PATH . '/fastlz.h')) {
|
|
throw new BuildFailureException('Failed to copy fastlz.h, file does not exist');
|
|
}
|
|
if (!copy($this->source_dir . '/libfastlz.a', BUILD_LIB_PATH . '/libfastlz.a')) {
|
|
throw new BuildFailureException('Failed to copy libfastlz.a, file does not exist');
|
|
}
|
|
}
|
|
}
|