mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
simplify
This commit is contained in:
parent
101b4febb9
commit
17acb966de
@ -79,7 +79,7 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
|
||||
SPC_LIBC=musl
|
||||
; uncomment to link libc dynamically on musl
|
||||
; SPC_MUSL_DYNAMIC=true
|
||||
SPC_STATIC_LIBS=true
|
||||
SPC_LINK_STATIC=true
|
||||
|
||||
; Recommended: specify your target here. Zig toolchain will be used.
|
||||
; examples:
|
||||
|
||||
@ -42,9 +42,8 @@ class openssl extends BSDLibraryBase
|
||||
|
||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||
->exec(
|
||||
"./Configure " .
|
||||
(getenv('SPC_STATIC_LIBS') ? 'no-shared' : '') .
|
||||
" {$extra} " . '--prefix=/ ' . // use prefix=/
|
||||
"./Configure {$extra} " .
|
||||
'--prefix=/ ' . // use prefix=/
|
||||
"--libdir={$lib} " .
|
||||
'--openssldir=/etc/ssl ' .
|
||||
'BSD-' . arch2gnu($this->builder->getOption('arch'))
|
||||
|
||||
@ -59,9 +59,8 @@ class openssl extends LinuxLibraryBase
|
||||
|
||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||
->exec(
|
||||
"./Configure " .
|
||||
(getenv('SPC_STATIC_LIBS') ? 'no-shared' : '') .
|
||||
" {$extra} " . '--prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||
"./Configure {$extra} " .
|
||||
'--prefix=' . BUILD_ROOT_PATH . ' ' .
|
||||
'--libdir=' . BUILD_LIB_PATH . ' ' .
|
||||
"--openssldir={$openssl_dir} " .
|
||||
"{$zlib_extra}" .
|
||||
|
||||
@ -43,9 +43,7 @@ class openssl extends MacOSLibraryBase
|
||||
|
||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||
->exec(
|
||||
"./Configure " .
|
||||
(getenv('SPC_STATIC_LIBS') ? 'no-shared' : '') .
|
||||
" {$extra} " .
|
||||
"./Configure {$extra} " .
|
||||
'--prefix=' . BUILD_ROOT_PATH . ' ' . // use prefix=/
|
||||
'--libdir=lib ' .
|
||||
'--openssldir=/etc/ssl ' .
|
||||
|
||||
@ -11,7 +11,7 @@ trait libuv
|
||||
protected function build(): void
|
||||
{
|
||||
UnixCMakeExecutor::create($this)
|
||||
->addConfigureArgs('-DLIBUV_BUILD_SHARED=OFF')
|
||||
->addConfigureArgs('-DLIBUV_BUILD_SHARED=ON')
|
||||
->build();
|
||||
// patch pkgconfig
|
||||
$this->patchPkgconfPrefix(['libuv-static.pc']);
|
||||
|
||||
@ -13,7 +13,7 @@ trait mimalloc
|
||||
{
|
||||
$cmake = UnixCMakeExecutor::create($this)
|
||||
->addConfigureArgs(
|
||||
'-DMI_BUILD_SHARED=OFF',
|
||||
'-DMI_BUILD_SHARED=ON',
|
||||
'-DMI_BUILD_OBJECT=OFF',
|
||||
'-DMI_INSTALL_TOPLEVEL=ON',
|
||||
);
|
||||
|
||||
@ -14,7 +14,7 @@ trait tidy
|
||||
->setBuildDir("{$this->source_dir}/build-dir")
|
||||
->addConfigureArgs(
|
||||
'-DSUPPORT_CONSOLE_APP=OFF',
|
||||
'-DBUILD_SHARED_LIB=OFF'
|
||||
'-DBUILD_SHARED_LIB=ON'
|
||||
);
|
||||
if (version_compare(get_cmake_version(), '4.0.0', '>=')) {
|
||||
$cmake->addConfigureArgs('-DCMAKE_POLICY_VERSION_MINIMUM=3.5');
|
||||
|
||||
@ -10,7 +10,7 @@ trait zlib
|
||||
{
|
||||
protected function build(): void
|
||||
{
|
||||
$static = getenv('SPC_STATIC_LIBS') ? '--static' : '';
|
||||
$static = getenv('SPC_LINK_STATIC') ? '--static' : '';
|
||||
UnixAutoconfExecutor::create($this)->exec("./configure {$static} --prefix={$this->getBuildRootPath()}")->make();
|
||||
$this->patchPkgconfPrefix(['zlib.pc']);
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ trait zstd
|
||||
UnixCMakeExecutor::create($this)
|
||||
->setBuildDir("{$this->source_dir}/build/cmake/build")
|
||||
->addConfigureArgs(
|
||||
'-DZSTD_BUILD_STATIC=ON', // otherwise zstd util fails to build
|
||||
'-DZSTD_BUILD_SHARED='. (getenv('SPC_STATIC_LIBS') ? 'OFF' : 'ON'),
|
||||
'-DZSTD_BUILD_STATIC=ON',
|
||||
'-DZSTD_BUILD_SHARED=ON',
|
||||
)
|
||||
->build();
|
||||
$this->patchPkgconfPrefix();
|
||||
|
||||
@ -33,7 +33,6 @@ class openssl extends WindowsLibraryBase
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper($this->perl),
|
||||
'Configure zlib VC-WIN64A ' .
|
||||
(getenv('SPC_STATIC_LIBS') ? 'no-shared' : '') .
|
||||
'--prefix=' . quote(BUILD_ROOT_PATH) . ' ' .
|
||||
'--with-zlib-lib=' . quote(BUILD_LIB_PATH) . ' ' .
|
||||
'--with-zlib-include=' . quote(BUILD_INCLUDE_PATH) . ' ' .
|
||||
|
||||
@ -61,7 +61,7 @@ class PkgConfigUtil
|
||||
*/
|
||||
public static function getCflags(string $pkg_config_str): string
|
||||
{
|
||||
$static = getenv('SPC_STATIC_LIBS') ? '--static' : '';
|
||||
$static = getenv('SPC_LINK_STATIC') ? '--static' : '';
|
||||
// get other things
|
||||
$result = self::execWithResult("pkg-config {$static} --cflags-only-other {$pkg_config_str}");
|
||||
return trim($result);
|
||||
@ -79,7 +79,7 @@ class PkgConfigUtil
|
||||
public static function getLibsArray(string $pkg_config_str): array
|
||||
{
|
||||
// Use this instead of shell() to avoid unnecessary outputs
|
||||
$static = getenv('SPC_STATIC_LIBS') ? '--static' : '';
|
||||
$static = getenv('SPC_LINK_STATIC') ? '--static' : '';
|
||||
$result = self::execWithResult("pkg-config {$static} --libs-only-l {$pkg_config_str}");
|
||||
$libs = explode(' ', trim($result));
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ class SPCConfigUtil
|
||||
if (in_array('imap', $libraries) && SPCTarget::getLibc() === 'glibc') {
|
||||
$lib_names[] = '-lcrypt';
|
||||
}
|
||||
if (getenv('SPC_STATIC_LIBS')) {
|
||||
if (getenv('SPC_LINK_STATIC')) {
|
||||
$lib_names = array_map(fn ($l) => $this->getStaticLibname($l), $lib_names);
|
||||
}
|
||||
return implode(' ', $lib_names);
|
||||
|
||||
@ -133,8 +133,8 @@ class UnixAutoconfExecutor extends Executor
|
||||
private function getDefaultConfigureArgs(): array
|
||||
{
|
||||
return [
|
||||
getenv('SPC_STATIC_LIBS') ? '--disable-shared' : '--enable-shared',
|
||||
getenv('SPC_STATIC_LIBS') ? '--enable-static' : '--enable-static', // TODO: not always static
|
||||
'--enable-static',
|
||||
'--enable-shared',
|
||||
"--prefix={$this->library->getBuildRootPath()}",
|
||||
'--with-pic',
|
||||
'--enable-pic',
|
||||
|
||||
@ -151,7 +151,7 @@ class UnixCMakeExecutor extends Executor
|
||||
'-DCMAKE_INSTALL_LIBDIR=lib',
|
||||
'-DCMAKE_INSTALL_INCLUDEDIR=include',
|
||||
'-DPOSITION_INDEPENDENT_CODE=ON',
|
||||
'-DBUILD_SHARED_LIBS=' . (getenv('SPC_STATIC_LIBS') ? 'OFF' : 'ON'),
|
||||
'-DBUILD_SHARED_LIBS=ON',
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->makeCmakeToolchainFile()}",
|
||||
]);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user