mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +08:00
Use SPCConfigUtil to generate shared extension env
This commit is contained in:
parent
61eafa48ff
commit
7bfb8d6f53
@ -9,6 +9,7 @@ use SPC\exception\RuntimeException;
|
|||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
|
use SPC\util\SPCConfigUtil;
|
||||||
|
|
||||||
class Extension
|
class Extension
|
||||||
{
|
{
|
||||||
@ -281,13 +282,23 @@ class Extension
|
|||||||
/**
|
/**
|
||||||
* Build shared extension for Unix
|
* Build shared extension for Unix
|
||||||
*
|
*
|
||||||
|
* @throws FileSystemException
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
|
* @throws WrongUsageException
|
||||||
|
* @throws \ReflectionException
|
||||||
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function buildUnixShared(): void
|
public function buildUnixShared(): void
|
||||||
{
|
{
|
||||||
|
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()]);
|
||||||
|
$env = [
|
||||||
|
'CFLAGS' => $config['cflags'],
|
||||||
|
'LDFLAGS' => $config['ldflags'],
|
||||||
|
'LIBS' => $config['libs'],
|
||||||
|
];
|
||||||
// prepare configure args
|
// prepare configure args
|
||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
->setEnv(['CFLAGS' => $this->builder->arch_c_flags ?? ''])
|
->setEnv($env)
|
||||||
->execWithEnv(BUILD_BIN_PATH . '/phpize')
|
->execWithEnv(BUILD_BIN_PATH . '/phpize')
|
||||||
->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static')
|
->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static')
|
||||||
->execWithEnv('make clean')
|
->execWithEnv('make clean')
|
||||||
|
|||||||
@ -7,6 +7,9 @@ namespace SPC\util;
|
|||||||
use SPC\builder\BuilderBase;
|
use SPC\builder\BuilderBase;
|
||||||
use SPC\builder\BuilderProvider;
|
use SPC\builder\BuilderProvider;
|
||||||
use SPC\builder\macos\MacOSBuilder;
|
use SPC\builder\macos\MacOSBuilder;
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
|
||||||
@ -21,6 +24,24 @@ class SPCConfigUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate configuration for building PHP extensions.
|
||||||
|
*
|
||||||
|
* @param array $extensions Extension name list
|
||||||
|
* @param array $libraries Additional library name list
|
||||||
|
* @param bool $include_suggest_ext Include suggested extensions
|
||||||
|
* @param bool $include_suggest_lib Include suggested libraries
|
||||||
|
* @return array{
|
||||||
|
* cflags: string,
|
||||||
|
* ldflags: string,
|
||||||
|
* libs: string
|
||||||
|
* }
|
||||||
|
* @throws \ReflectionException
|
||||||
|
* @throws FileSystemException
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws WrongUsageException
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array
|
public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array
|
||||||
{
|
{
|
||||||
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
[$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user