diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 09d1e25b..eb3b388f 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use SPC\builder\linux\library\LinuxLibraryBase; use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; @@ -18,23 +17,23 @@ trait postgresql */ protected function build() { - [$libdir, , $destdir] = SEPARATED_PATH; $builddir = BUILD_ROOT_PATH; $env = $this->builder->configure_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])) { $cppflags = $output[1][0]; $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])) { $ldflags = $output[1][0]; $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])) { $libs = $output[1][0]; $envs .= " LIBS=\"{$libs}\" "; @@ -43,62 +42,48 @@ trait postgresql FileSystem::resetDir($this->source_dir . '/build'); # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile - shell()->cd($this->source_dir . '/build')->exec( - <<<'EOF' - sed -i.backup "s/invokes exit'; exit 1;/invokes exit';/" ../src/interfaces/libpq/Makefile -EOF - ); - - 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 - ); + shell()->cd($this->source_dir . '/build') + ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') + ->exec(' sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib') + ->exec('sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib'); + // configure shell()->cd($this->source_dir . '/build') ->exec( - <<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( - <<cd($this->source_dir . '/build') + ->exec($envs . ' make -C src/bin/pg_config install') + ->exec($envs . ' make -C src/include install') + ->exec($envs . ' make -C src/common install') + ->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"); } }