diff --git a/src/SPC/builder/freebsd/library/openssl.php b/src/SPC/builder/freebsd/library/openssl.php index 3c62ba2e..1bbabf52 100644 --- a/src/SPC/builder/freebsd/library/openssl.php +++ b/src/SPC/builder/freebsd/library/openssl.php @@ -48,13 +48,8 @@ class openssl extends BSDLibraryBase $ex_lib = trim($zlib->getStaticLibFiles() . ' ' . $ex_lib); } - shell()->cd($this->source_dir) - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs() . " {$ex_lib}", - ]) - ->execWithEnv( + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec( "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index 87a92234..aa2825b7 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -17,13 +17,8 @@ class icu extends LinuxLibraryBase $cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -DPIC -fPIC"'; $cxxflags = 'CXXFLAGS="-std=c++17 -DPIC -fPIC -fno-ident"'; $ldflags = getenv('SPC_LIBC') !== 'glibc' ? 'LDFLAGS="-static"' : ''; - shell()->cd($this->source_dir . '/source') - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]) - ->execWithEnv( + shell()->cd($this->source_dir . '/source')->initializeEnv($this) + ->exec( "{$cppflags} {$cxxflags} {$ldflags} " . './runConfigureICU Linux ' . '--enable-static ' . @@ -38,9 +33,9 @@ class icu extends LinuxLibraryBase '--enable-samples=no ' . '--prefix=' . BUILD_ROOT_PATH ) - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency}") - ->execWithEnv('make install'); + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); $this->patchPkgconfPrefix(['icu-i18n.pc', 'icu-io.pc', 'icu-uc.pc'], PKGCONF_PATCH_PREFIX); FileSystem::removeDir(BUILD_LIB_PATH . '/icu'); diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index 4e911c54..da660aff 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -55,9 +55,9 @@ class libpng extends LinuxLibraryBase $optimizations . '--prefix=' ) - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") - ->execWithEnv('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") + ->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); $this->cleanLaFiles(); } diff --git a/src/SPC/builder/unix/library/libsodium.php b/src/SPC/builder/unix/library/libsodium.php index c6bc6168..894310bd 100644 --- a/src/SPC/builder/unix/library/libsodium.php +++ b/src/SPC/builder/unix/library/libsodium.php @@ -8,16 +8,11 @@ trait libsodium { protected function build(): void { - shell()->cd($this->source_dir) - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]) - ->execWithEnv('./configure --with-pic --enable-static --disable-shared --prefix=') - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency}") - ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec('./configure --with-pic --enable-static --disable-shared --prefix=') + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libsodium.pc'], PKGCONF_PATCH_PREFIX); } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 69907556..21dce791 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -86,9 +86,8 @@ trait postgresql 'LIBS' => $this->getLibExtraLibs(), ]; // configure - shell()->cd($this->source_dir . '/build') - ->setEnv($env) - ->execWithEnv( + shell()->cd($this->source_dir . '/build')->initializeEnv($this) + ->exec( "{$envs} ../configure " . "--prefix={$builddir} " . ($this->builder->getOption('enable-zts') ? '--enable-thread-safety ' : '--disable-thread-safety ') . @@ -108,11 +107,11 @@ trait postgresql '--without-bonjour ' . '--without-tcl ' ) - ->execWithEnv($envs . ' make -C src/bin/pg_config install') - ->execWithEnv($envs . ' make -C src/include install') - ->execWithEnv($envs . ' make -C src/common install') - ->execWithEnv($envs . ' make -C src/port install') - ->execWithEnv($envs . ' make -C src/interfaces/libpq install'); + ->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/port install') + ->exec($envs . ' make -C src/interfaces/libpq install'); // remove dynamic libs shell()->cd($this->source_dir . '/build') diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index be7e9297..0e40629d 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -15,13 +15,8 @@ trait unixodbc */ protected function build(): void { - shell()->cd($this->source_dir) - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]) - ->execWithEnv( + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec( './configure ' . '--enable-static --disable-shared ' . '--disable-debug ' . @@ -32,9 +27,9 @@ trait unixodbc '--enable-gui=no ' . '--prefix=' ) - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency}") - ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']); $this->cleanLaFiles(); } diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index f3b4d934..3aed6a15 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -15,13 +15,8 @@ trait xz */ public function build(): void { - shell()->cd($this->source_dir) - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]) - ->execWithEnv( + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec( './configure ' . '--enable-static ' . '--disable-shared ' . @@ -31,9 +26,9 @@ trait xz '--with-libiconv ' . '--prefix=' ) - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency}") - ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['liblzma.pc']); $this->patchLaDependencyPrefix(['liblzma.la']); } diff --git a/src/SPC/util/WindowsCmd.php b/src/SPC/util/WindowsCmd.php index ca06dc25..4398dc44 100644 --- a/src/SPC/util/WindowsCmd.php +++ b/src/SPC/util/WindowsCmd.php @@ -75,24 +75,4 @@ class WindowsCmd $this->env = array_merge($this->env, $env); return $this; } - - /** - * @throws RuntimeException - */ - public function execWithEnv(string $cmd): WindowsCmd - { - if ($this->getEnvString() !== '') { - return $this->exec($this->getEnvString() . "call {$cmd}"); - } - return $this->exec($cmd); - } - - private function getEnvString(): string - { - $str = ''; - foreach ($this->env as $k => $v) { - $str .= 'set ' . $k . '=' . $v . ' && '; - } - return $str; - } }