mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
add cache file option to autoconf executor by default (if cflags and ldflags match default)
This commit is contained in:
parent
0695fb9381
commit
5577cd0fab
@ -18,13 +18,8 @@ class libffi extends LinuxLibraryBase
|
||||
*/
|
||||
public function build(): void
|
||||
{
|
||||
$arch = getenv('SPC_ARCH');
|
||||
UnixAutoconfExecutor::create($this)
|
||||
->configure(
|
||||
"--host={$arch}-unknown-linux",
|
||||
"--target={$arch}-unknown-linux",
|
||||
"--libdir={$this->getLibDir()}"
|
||||
)
|
||||
->configure()
|
||||
->make();
|
||||
|
||||
if (is_file(BUILD_ROOT_PATH . '/lib64/libffi.a')) {
|
||||
|
||||
@ -24,7 +24,7 @@ trait gettext
|
||||
if ($this->builder->getOption('enable-zts')) {
|
||||
$autoconf->addConfigureArgs('--enable-threads=isoc+posix')
|
||||
->appendEnv([
|
||||
'CFLAGS' => '-lpthread -D_REENTRANT',
|
||||
'CFLAGS' => '-D_REENTRANT',
|
||||
'LDFLGAS' => '-lpthread',
|
||||
]);
|
||||
} else {
|
||||
|
||||
@ -17,6 +17,7 @@ trait unixodbc
|
||||
protected function build(): void
|
||||
{
|
||||
UnixAutoconfExecutor::create($this)
|
||||
->removeConfigureArgs('--cache-file')
|
||||
->configure(
|
||||
'--disable-debug',
|
||||
'--disable-dependency-tracking',
|
||||
|
||||
@ -129,4 +129,9 @@ class UnixShell
|
||||
}
|
||||
return $cmd;
|
||||
}
|
||||
|
||||
public function getEnv(): array
|
||||
{
|
||||
return $this->env;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,13 @@ class UnixAutoconfExecutor extends Executor
|
||||
// remove all the ignored args
|
||||
$args = array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args);
|
||||
$args = array_diff($args, $this->ignore_args);
|
||||
$args = array_filter(
|
||||
$args,
|
||||
fn ($arg) => !array_filter(
|
||||
$this->ignore_args,
|
||||
fn ($ignore) => str_starts_with($arg, $ignore . '=')
|
||||
)
|
||||
);
|
||||
$configure_args = implode(' ', $args);
|
||||
|
||||
$this->shell->exec("./configure {$configure_args}");
|
||||
@ -46,7 +53,7 @@ class UnixAutoconfExecutor extends Executor
|
||||
/**
|
||||
* Run make
|
||||
*
|
||||
* @param string $target Build target
|
||||
* @param string $target Build target
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function make(string $target = '', false|string $with_install = 'install', bool $with_clean = true, array $after_env_vars = []): static
|
||||
@ -72,9 +79,9 @@ class UnixAutoconfExecutor extends Executor
|
||||
* Add optional library configuration.
|
||||
* This method checks if a library is available and adds the corresponding arguments to the CMake configuration.
|
||||
*
|
||||
* @param string $name library name to check
|
||||
* @param \Closure|string $true_args arguments to use if the library is available (allow closure, returns string)
|
||||
* @param string $false_args arguments to use if the library is not available
|
||||
* @param string $name library name to check
|
||||
* @param \Closure|string $true_args arguments to use if the library is available (allow closure, returns string)
|
||||
* @param string $false_args arguments to use if the library is not available
|
||||
* @return $this
|
||||
*/
|
||||
public function optionalLib(string $name, \Closure|string $true_args, string $false_args = ''): static
|
||||
@ -119,13 +126,23 @@ class UnixAutoconfExecutor extends Executor
|
||||
*/
|
||||
private function getDefaultConfigureArgs(): array
|
||||
{
|
||||
return [
|
||||
$args = [
|
||||
'--disable-shared',
|
||||
'--enable-static',
|
||||
"--prefix={$this->library->getBuildRootPath()}",
|
||||
'--with-pic',
|
||||
'--enable-pic',
|
||||
];
|
||||
|
||||
// only add the cache file if CFLAGS and LDFLAGS are defaulted
|
||||
$env = $this->shell->getEnv();
|
||||
$expected_cflags = '-I' . BUILD_INCLUDE_PATH . ' ' . getenv('SPC_DEFAULT_C_FLAGS');
|
||||
$expected_ldflags = '-L' . BUILD_LIB_PATH;
|
||||
|
||||
if (($env['CFLAGS'] ?? '') === $expected_cflags && ($env['LDFLAGS'] ?? '') === $expected_ldflags) {
|
||||
$args[] = '--cache-file=' . BUILD_ROOT_PATH . '/config.cache';
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user