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