reformat code

This commit is contained in:
crazywhalecc
2023-07-22 16:12:12 +08:00
parent bc978ecbde
commit 47101d058b

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace SPC\builder\unix\library; namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\builder\macos\library\MacOSLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException; use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException; use SPC\exception\RuntimeException;
@@ -18,23 +17,23 @@ trait postgresql
*/ */
protected function build() protected function build()
{ {
[$libdir, , $destdir] = SEPARATED_PATH;
$builddir = BUILD_ROOT_PATH; $builddir = BUILD_ROOT_PATH;
$env = $this->builder->configure_env; $env = $this->builder->configure_env;
$envs = $env; $envs = $env;
$packages = 'openssl zlib readline libxml-2.0 '; // icu-uc icu-io icu-i18n libzstd $packages = 'openssl zlib readline libxml-2.0'; // icu-uc icu-io icu-i18n libzstd
$output = shell()->execWithResult($env . ' pkg-config --cflags-only-I --static ' . $packages); $pkgconfig_executable = $builddir . '/bin/pkg-config';
$output = shell()->execWithResult($env . " {$pkgconfig_executable} --cflags-only-I --static " . $packages);
if (!empty($output[1][0])) { if (!empty($output[1][0])) {
$cppflags = $output[1][0]; $cppflags = $output[1][0];
$envs .= " CPPFLAGS=\"{$cppflags}\""; $envs .= " CPPFLAGS=\"{$cppflags}\"";
} }
$output = shell()->execWithResult($env . ' pkg-config --libs-only-L --static ' . $packages); $output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-L --static " . $packages);
if (!empty($output[1][0])) { if (!empty($output[1][0])) {
$ldflags = $output[1][0]; $ldflags = $output[1][0];
$envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" "; $envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" ";
} }
$output = shell()->execWithResult($env . ' pkg-config --libs-only-l --static ' . $packages); $output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-l --static " . $packages);
if (!empty($output[1][0])) { if (!empty($output[1][0])) {
$libs = $output[1][0]; $libs = $output[1][0];
$envs .= " LIBS=\"{$libs}\" "; $envs .= " LIBS=\"{$libs}\" ";
@@ -43,62 +42,48 @@ trait postgresql
FileSystem::resetDir($this->source_dir . '/build'); FileSystem::resetDir($this->source_dir . '/build');
# 有静态链接配置 参考文件: src/interfaces/libpq/Makefile # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile
shell()->cd($this->source_dir . '/build')->exec( shell()->cd($this->source_dir . '/build')
<<<'EOF' ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile')
sed -i.backup "s/invokes exit'; exit 1;/invokes exit';/" ../src/interfaces/libpq/Makefile ->exec(' sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib')
EOF ->exec('sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib');
);
shell()->cd($this->source_dir . '/build')->exec(
<<<'EOF'
sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib
EOF
);
shell()->cd($this->source_dir . '/build')->exec(
<<<'EOF'
sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib
EOF
);
// configure
shell()->cd($this->source_dir . '/build') shell()->cd($this->source_dir . '/build')
->exec( ->exec(
<<<EOF "{$env} ../configure " .
{$envs} \\ "--prefix={$builddir} " .
../configure \\ '--disable-thread-safety ' .
--prefix={$builddir} \\ '--enable-coverage=no ' .
--disable-thread-safety \\ '--with-ssl=openssl ' .
--enable-coverage=no \\ '--with-readline ' .
--with-ssl=openssl \\ '--with-libxml ' .
--with-readline \\ '--without-icu ' .
--without-icu \\ '--without-ldap ' .
--without-ldap \\ '--without-libxslt ' .
--with-libxml \\ '--without-lz4 ' .
--without-libxslt \\ '--without-zstd ' .
--without-lz4 \\ '--without-perl ' .
--without-zstd \\ '--without-python ' .
--without-perl \\ '--without-pam ' .
--without-python \\ '--without-ldap ' .
--without-pam \\ '--without-bonjour ' .
--without-ldap \\ '--without-tcl '
--without-bonjour \\
--without-tcl
EOF
); );
// 方便调试,
shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/bin/pg_config install');
shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/include install');
shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/common install');
shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/backend/port install');
shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/port install');
shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/backend/libpq install');
shell()->cd($this->source_dir . '/build')->exec($envs . ' make -C src/interfaces/libpq install');
shell()->cd($this->source_dir . '/build')->exec( // build
<<<EOF shell()->cd($this->source_dir . '/build')
rm -rf {$builddir}/lib/*.so.* ->exec($envs . ' make -C src/bin/pg_config install')
rm -rf {$builddir}/lib/*.so ->exec($envs . ' make -C src/include install')
rm -rf {$builddir}/lib/*.dylib ->exec($envs . ' make -C src/common install')
EOF ->exec($envs . ' make -C src/backend/port install')
); ->exec($envs . ' make -C src/port install')
->exec($envs . ' make -C src/backend/libpq install')
->exec($envs . ' make -C src/interfaces/libpq install');
// remove dynamic libs
shell()->cd($this->source_dir . '/build')
->exec("rm -rf {$builddir}/lib/*.so.*")
->exec("rm -rf {$builddir}/lib/*.so")
->exec("rm -rf {$builddir}/lib/*.dylib");
} }
} }