diff --git a/config/ext.json b/config/ext.json index 8fc641f9..f2698d5e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -146,7 +146,6 @@ }, "intl": { "type": "builtin", - "cpp-extension": true, "lib-depends": [ "icu" ] diff --git a/config/lib.json b/config/lib.json index 0dd26ed5..6a602d16 100644 --- a/config/lib.json +++ b/config/lib.json @@ -111,6 +111,7 @@ }, "icu": { "source": "icu", + "cpp-library": true, "static-libs-unix": [ "libicui18n.a", "libicuio.a", @@ -129,13 +130,13 @@ "zlib", "libpng", "libjpeg", - "bzip2", "libwebp", "freetype" ], "lib-suggests": [ "zstd", "xz", + "bzip2", "libzip", "libxml2" ] diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 8d8d46dd..eb18f485 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -112,6 +112,16 @@ abstract class BuilderBase return $this->libs[$name] ?? null; } + /** + * Get all library objects. + * + * @return LibraryBase[] + */ + public function getLibs(): array + { + return $this->libs; + } + /** * Add extension to build. */ @@ -139,12 +149,12 @@ abstract class BuilderBase } /** - * Check if there is a cpp extension. + * Check if there is a cpp extensions or libraries. * * @throws FileSystemException * @throws WrongUsageException */ - public function hasCppExtension(): bool + public function hasCpp(): bool { // judge cpp-extension $exts = array_keys($this->getExts()); @@ -153,6 +163,12 @@ abstract class BuilderBase return true; } } + $libs = array_keys($this->getLibs()); + foreach ($libs as $lib) { + if (Config::getLib($lib, 'cpp-library', false) === true) { + return true; + } + } return false; } diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index ef965d58..3c225471 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -14,7 +14,6 @@ class imagick extends Extension { // imagick may call omp_pause_all which requires -lgomp $extra_libs = $this->builder->getOption('extra-libs', ''); - $extra_libs .= ' -lgomp '; $this->builder->setOption('extra-libs', $extra_libs); return true; } diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index 64587c76..469c7534 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -31,9 +31,16 @@ class BSDBuilder extends BuilderBase // ---------- set necessary options ---------- // set C Compiler (default: clang) - $this->setOptionIfNotExist('cc', 'clang'); + f_putenv('CC=' . $this->getOption('cc', 'clang')); // set C++ Composer (default: clang++) - $this->setOptionIfNotExist('cxx', 'clang++'); + f_putenv('CXX=' . $this->getOption('cxx', 'clang++')); + // set PATH + f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + // set PKG_CONFIG + f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); + // set PKG_CONFIG_PATH + f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/'); + // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); @@ -46,16 +53,6 @@ class BSDBuilder extends BuilderBase $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch')); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('BSD', $this->getOption('arch'), $this->arch_c_flags); - // configure environment - $this->configure_env = SystemUtil::makeEnvVarString([ - 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', - 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig/', - 'CC' => $this->getOption('cc'), - 'CXX' => $this->getOption('cxx'), - 'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os", - 'LIBS' => '-ldl -lpthread', - 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), - ]); // create pkgconfig and include dir (some libs cannot create them automatically) f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); @@ -75,7 +72,7 @@ class BSDBuilder extends BuilderBase // ---------- Update extra-libs ---------- $extra_libs = $this->getOption('extra-libs', ''); // add libc++, some extensions or libraries need it (C++ cannot be linked statically) - $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : ''); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : ''); if (!$this->getOption('bloat', false)) { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { @@ -115,8 +112,7 @@ class BSDBuilder extends BuilderBase ($enableMicro ? '--enable-micro ' : '--disable-micro ') . $json_74 . $zts . - $this->makeExtensionArgs() . ' ' . - $this->configure_env + $this->makeExtensionArgs() ); SourcePatcher::patchBeforeMake($this); @@ -173,12 +169,14 @@ class BSDBuilder extends BuilderBase /** * Build phpmicro sapi * - * @throws FileSystemException|RuntimeException + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { - throw new RuntimeException('phpmicro only support PHP >= 8.0!'); + throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); } if ($this->getExt('phar')) { $this->phar_patched = true; @@ -228,6 +226,11 @@ class BSDBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_FPM); } + /** + * Build embed sapi + * + * @throws RuntimeException + */ public function buildEmbed(): void { $vars = SystemUtil::makeEnvVarString([ diff --git a/src/SPC/builder/freebsd/library/openssl.php b/src/SPC/builder/freebsd/library/openssl.php index ea521f47..e525745a 100644 --- a/src/SPC/builder/freebsd/library/openssl.php +++ b/src/SPC/builder/freebsd/library/openssl.php @@ -49,7 +49,7 @@ class openssl extends BSDLibraryBase shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./Configure no-shared {$extra} " . + "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . '--openssldir=/etc/ssl ' . diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 92c760ed..1aa6cdc9 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -21,9 +21,6 @@ class LinuxBuilder extends BuilderBase /** @var array Tune cflags */ public array $tune_c_flags; - /** @var string pkg-config env, including PKG_CONFIG_PATH, PKG_CONFIG */ - public string $pkgconf_env; - /** @var bool Micro patch phar flag */ private bool $phar_patched = false; @@ -39,21 +36,33 @@ class LinuxBuilder extends BuilderBase // ---------- set necessary options ---------- // set C/C++ compilers (default: alpine: gcc, others: musl-cross-make) if (SystemUtil::isMuslDist()) { - $this->setOptionIfNotExist('cc', 'gcc'); - $this->setOptionIfNotExist('cxx', 'g++'); - $this->setOptionIfNotExist('ar', 'ar'); - $this->setOptionIfNotExist('ld', 'ld.gold'); - $this->setOptionIfNotExist('library_path', ''); - $this->setOptionIfNotExist('ld_library_path', ''); + f_putenv("CC={$this->getOption('cc', 'gcc')}"); + f_putenv("CXX={$this->getOption('cxx', 'g++')}"); + f_putenv("AR={$this->getOption('ar', 'ar')}"); + f_putenv("LD={$this->getOption('ld', 'ld.gold')}"); } else { $arch = arch2gnu(php_uname('m')); - $this->setOptionIfNotExist('cc', "{$arch}-linux-musl-gcc"); - $this->setOptionIfNotExist('cxx', "{$arch}-linux-musl-g++"); - $this->setOptionIfNotExist('ar', "{$arch}-linux-musl-ar"); - $this->setOptionIfNotExist('ld', "/usr/local/musl/{$arch}-linux-musl/bin/ld.gold"); + f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}"); + f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}"); + f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}"); + f_putenv("LD={$this->getOption('ld', "/usr/local/musl/{$arch}-linux-musl/bin/ld.gold")}"); + f_putenv('PATH=/usr/local/musl/bin:/usr/local/musl/' . $arch . '-linux-musl/bin:' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + + // set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused) $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); $this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); + + // check musl-cross make installed if we use musl-cross-make + if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { + throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); + } } + + // set PKG_CONFIG + f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); + // set PKG_CONFIG_PATH + f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig'); + // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); @@ -61,32 +70,18 @@ class LinuxBuilder extends BuilderBase // concurrency $this->concurrency = SystemUtil::getCpuCount(); // cflags - $this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('cc'), $this->getOption('arch')); - $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('cxx'), $this->getOption('arch')); - $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), $this->getOption('cc')); + $this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch')); + $this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch')); + $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC')); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile( 'Linux', $this->getOption('arch'), $this->arch_c_flags, - $this->getOption('cc'), - $this->getOption('cxx'), + getenv('CC'), + getenv('CXX'), ); - // pkg-config - $vars = [ - 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', - 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig', - ]; - $this->pkgconf_env = SystemUtil::makeEnvVarString($vars); - // configure environment - $this->configure_env = SystemUtil::makeEnvVarString([ - ...$vars, - 'CC' => $this->getOption('cc'), - 'CXX' => $this->getOption('cxx'), - 'AR' => $this->getOption('ar'), - 'LD' => $this->getOption('ld'), - 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), - ]); + // cross-compiling is not supported yet /*if (php_uname('m') !== $this->arch) { $this->cross_compile_prefix = SystemUtil::getCrossCompilePrefix($this->cc, $this->arch); @@ -141,23 +136,19 @@ class LinuxBuilder extends BuilderBase $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles()))); } // add libstdc++, some extensions or libraries need it - $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lstdc++ ' : ''); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : ''); $this->setOption('extra-libs', $extra_libs); $cflags = $this->arch_c_flags; $use_lld = ''; - if (str_ends_with($this->getOption('cc'), 'clang') && SystemUtil::findCommand('lld')) { + if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) { $use_lld = '-Xcompiler -fuse-ld=lld'; } - $envs = $this->pkgconf_env . ' ' . SystemUtil::makeEnvVarString([ - 'CC' => $this->getOption('cc'), - 'CXX' => $this->getOption('cxx'), - 'AR' => $this->getOption('ar'), - 'LD' => $this->getOption('ld'), + // prepare build php envs + $envs_build_php = SystemUtil::makeEnvVarString([ 'CFLAGS' => $cflags, 'LIBS' => '-ldl -lpthread', - 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), ]); SourcePatcher::patchBeforeBuildconf($this); @@ -185,7 +176,6 @@ class LinuxBuilder extends BuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( - "{$this->getOption('ld_library_path')} " . './configure ' . '--prefix= ' . '--with-valgrind=no ' . @@ -203,7 +193,7 @@ class LinuxBuilder extends BuilderBase $zts . $maxExecutionTimers . $this->makeExtensionArgs() . ' ' . - $envs + $envs_build_php ); SourcePatcher::patchBeforeMake($this); @@ -262,13 +252,14 @@ class LinuxBuilder extends BuilderBase /** * Build phpmicro sapi * - * @throws RuntimeException * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function buildMicro(string $use_lld, string $cflags): void { if ($this->getPHPVersionID() < 80000) { - throw new RuntimeException('phpmicro only support PHP >= 8.0!'); + throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); } if ($this->getExt('phar')) { $this->phar_patched = true; @@ -321,6 +312,11 @@ class LinuxBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_FPM); } + /** + * Build embed sapi + * + * @throws RuntimeException + */ public function buildEmbed(string $use_lld): void { $vars = SystemUtil::makeEnvVarString([ diff --git a/src/SPC/builder/linux/library/LinuxLibraryBase.php b/src/SPC/builder/linux/library/LinuxLibraryBase.php index 89dc46bd..2a496590 100644 --- a/src/SPC/builder/linux/library/LinuxLibraryBase.php +++ b/src/SPC/builder/linux/library/LinuxLibraryBase.php @@ -33,15 +33,4 @@ abstract class LinuxLibraryBase extends LibraryBase { return $this->builder; } - - protected function makeFakePkgconfs(): void - { - $workspace = BUILD_ROOT_PATH; - if ($workspace === '/') { - $workspace = ''; - } - foreach ($this->pkgconfs as $name => $content) { - file_put_contents(BUILD_LIB_PATH . "/pkgconfig/{$name}", "prefix={$workspace}\n" . $content); - } - } } diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index 5a5f69f9..c2d579f5 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -15,7 +15,7 @@ class icu extends LinuxLibraryBase $ldflags = 'LDFLAGS="-static"'; shell()->cd($this->source_dir . '/source') ->exec( - "{$this->builder->configure_env} {$cppflags} {$cxxflags} {$ldflags} " . + "{$cppflags} {$cxxflags} {$ldflags} " . './runConfigureICU Linux ' . '--enable-static ' . '--disable-shared ' . diff --git a/src/SPC/builder/linux/library/libffi.php b/src/SPC/builder/linux/library/libffi.php new file mode 100644 index 00000000..df85ef3e --- /dev/null +++ b/src/SPC/builder/linux/library/libffi.php @@ -0,0 +1,50 @@ +builder->pkgconf_env . ' CFLAGS="' . $this->builder->arch_c_flags . '"'; + + $env .= match ($this->builder->libc) { + 'musl_wrapper' => " CC='{$this->builder->getOption('cc')} --static -idirafter " . BUILD_INCLUDE_PATH . + ($this->builder->getOption('arch') === php_uname('m') ? '-idirafter /usr/include/ ' : '') . + "-idirafter /usr/include/{$this->builder->getOption('arch')}-linux-gnu/'", + 'musl', 'glibc' => " CC='{$this->builder->getOption('cc')}'", + default => throw new RuntimeException('unsupported libc: ' . $this->builder->libc), + };*/ + + shell()->cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static ' . + '--disable-shared ' . + "--host={$this->builder->getOption('arch')}-unknown-linux " . + "--target={$this->builder->getOption('arch')}-unknown-linux " . + '--prefix= ' . // use prefix=/ + "--libdir={$lib}" + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec("make install DESTDIR={$destdir}"); + + if (is_file(BUILD_ROOT_PATH . '/lib64/libffi.a')) { + copy(BUILD_ROOT_PATH . '/lib64/libffi.a', BUILD_ROOT_PATH . '/lib/libffi.a'); + unlink(BUILD_ROOT_PATH . '/lib64/libffi.a'); + } + $this->patchPkgconfPrefix(['libffi.pc']); + } +} diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index d66b3282..3b6b2b6a 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -66,7 +66,7 @@ class libpng extends LinuxLibraryBase ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--disable-shared ' . '--enable-static ' . '--enable-hardware-optimizations ' . diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 4095ee56..82327c58 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -25,7 +25,7 @@ class libxml2 extends LinuxLibraryBase FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} " . ' cmake ' . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . '-DIconv_IS_BUILT_IN=OFF ' . diff --git a/src/SPC/builder/linux/library/nghttp2.php b/src/SPC/builder/linux/library/nghttp2.php index 8246a2eb..86337874 100644 --- a/src/SPC/builder/linux/library/nghttp2.php +++ b/src/SPC/builder/linux/library/nghttp2.php @@ -55,7 +55,7 @@ class nghttp2 extends LinuxLibraryBase shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index af3400b6..5a9c5bfd 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -41,8 +41,8 @@ class openssl extends LinuxLibraryBase $extra = ''; $ex_lib = '-ldl -pthread'; - $env = $this->builder->pkgconf_env . " CFLAGS='{$this->builder->arch_c_flags}'"; - $env .= " CC='{$this->builder->getOption('cc')} -static -idirafter " . BUILD_INCLUDE_PATH . + $env = "CFLAGS='{$this->builder->arch_c_flags}'"; + $env .= " CC='" . getenv('CC') . ' -static -idirafter ' . BUILD_INCLUDE_PATH . ' -idirafter /usr/include/ ' . ' -idirafter /usr/include/' . $this->builder->getOption('arch') . '-linux-gnu/ ' . "' "; @@ -60,11 +60,11 @@ class openssl extends LinuxLibraryBase $ex_lib = trim($ex_lib); - $clang_postfix = SystemUtil::getCCType($this->builder->getOption('cc')) === 'clang' ? '-clang' : ''; + $clang_postfix = SystemUtil::getCCType(getenv('CC')) === 'clang' ? '-clang' : ''; shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} {$env} ./Configure no-shared {$extra} " . + "{$env} ./Configure no-shared {$extra} " . '--prefix=/ ' . '--libdir=lib ' . '-static ' . diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 49643678..774a9172 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -32,9 +32,16 @@ class MacOSBuilder extends BuilderBase // ---------- set necessary options ---------- // set C Compiler (default: clang) - $this->setOptionIfNotExist('cc', 'clang'); + f_putenv('CC=' . $this->getOption('cc', 'clang')); // set C++ Composer (default: clang++) - $this->setOptionIfNotExist('cxx', 'clang++'); + f_putenv('CXX=' . $this->getOption('cxx', 'clang++')); + // set PATH + f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + // set PKG_CONFIG + f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); + // set PKG_CONFIG_PATH + f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/'); + // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); @@ -47,15 +54,6 @@ class MacOSBuilder extends BuilderBase $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch')); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->getOption('arch'), $this->arch_c_flags); - // configure environment - $this->configure_env = SystemUtil::makeEnvVarString([ - 'PKG_CONFIG' => BUILD_ROOT_PATH . '/bin/pkg-config', - 'PKG_CONFIG_PATH' => BUILD_LIB_PATH . '/pkgconfig/', - 'CC' => $this->getOption('cc'), - 'CXX' => $this->getOption('cxx'), - 'CFLAGS' => "{$this->arch_c_flags} -Wimplicit-function-declaration -Os", - 'PATH' => BUILD_ROOT_PATH . '/bin:' . getenv('PATH'), - ]); // create pkgconfig and include dir (some libs cannot create them automatically) f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); @@ -134,7 +132,7 @@ class MacOSBuilder extends BuilderBase // add macOS frameworks $extra_libs .= (empty($extra_libs) ? '' : ' ') . $this->getFrameworks(true); // add libc++, some extensions or libraries need it (C++ cannot be linked statically) - $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCppExtension() ? '-lc++ ' : ''); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : ''); if (!$this->getOption('bloat', false)) { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { @@ -174,8 +172,7 @@ class MacOSBuilder extends BuilderBase ($enableMicro ? '--enable-micro ' : '--disable-micro ') . $json_74 . $zts . - $this->makeExtensionArgs() . ' ' . - $this->configure_env + $this->makeExtensionArgs() ); SourcePatcher::patchBeforeMake($this); @@ -231,12 +228,14 @@ class MacOSBuilder extends BuilderBase /** * Build phpmicro sapi * - * @throws FileSystemException|RuntimeException + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { - throw new RuntimeException('phpmicro only support PHP >= 8.0!'); + throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); } if ($this->getExt('phar')) { $this->phar_patched = true; @@ -285,6 +284,11 @@ class MacOSBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_FPM); } + /** + * Build embed sapi + * + * @throws RuntimeException + */ public function buildEmbed(): void { $vars = SystemUtil::makeEnvVarString([ diff --git a/src/SPC/builder/macos/library/glfw.php b/src/SPC/builder/macos/library/glfw.php index c2ca2e74..91e8cb70 100644 --- a/src/SPC/builder/macos/library/glfw.php +++ b/src/SPC/builder/macos/library/glfw.php @@ -19,7 +19,7 @@ class glfw extends MacOSLibraryBase { // compile! shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw') - ->exec("{$this->builder->configure_env} cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") + ->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconf diff --git a/src/SPC/builder/macos/library/icu.php b/src/SPC/builder/macos/library/icu.php index 11a5663e..14a0ae94 100644 --- a/src/SPC/builder/macos/library/icu.php +++ b/src/SPC/builder/macos/library/icu.php @@ -12,7 +12,7 @@ class icu extends MacOSLibraryBase { $root = BUILD_ROOT_PATH; shell()->cd($this->source_dir . '/source') - ->exec("{$this->builder->configure_env} ./runConfigureICU MacOSX --enable-static --disable-shared --prefix={$root}") + ->exec("./runConfigureICU MacOSX --enable-static --disable-shared --prefix={$root}") ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install'); diff --git a/src/SPC/builder/macos/library/libffi.php b/src/SPC/builder/macos/library/libffi.php index 74bc9ce6..94903f67 100644 --- a/src/SPC/builder/macos/library/libffi.php +++ b/src/SPC/builder/macos/library/libffi.php @@ -20,7 +20,7 @@ class libffi extends MacOSLibraryBase [, , $destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . "--host={$this->builder->getOption('arch')}-apple-darwin " . diff --git a/src/SPC/builder/macos/library/libmemcached.php b/src/SPC/builder/macos/library/libmemcached.php index 6eb906f9..09a600a2 100644 --- a/src/SPC/builder/macos/library/libmemcached.php +++ b/src/SPC/builder/macos/library/libmemcached.php @@ -18,7 +18,7 @@ class libmemcached extends MacOSLibraryBase shell()->cd($this->source_dir) ->exec('chmod +x configure') ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static --disable-shared ' . '--disable-sasl ' . "--prefix={$rootdir}" diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index 868270d3..b41f8510 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -44,7 +44,7 @@ class libpng extends MacOSLibraryBase ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . "--host={$this->builder->getOption('gnu-arch')}-apple-darwin " . '--disable-shared ' . '--enable-static ' . diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index 36f960ea..50cb3a5a 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -25,7 +25,7 @@ class libxml2 extends MacOSLibraryBase FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} " . ' cmake ' . + 'cmake ' . // '--debug-find ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . diff --git a/src/SPC/builder/macos/library/nghttp2.php b/src/SPC/builder/macos/library/nghttp2.php index c1943840..b48cbe72 100644 --- a/src/SPC/builder/macos/library/nghttp2.php +++ b/src/SPC/builder/macos/library/nghttp2.php @@ -53,7 +53,7 @@ class nghttp2 extends MacOSLibraryBase shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} " . ' ./configure ' . + './configure ' . '--enable-static ' . '--disable-shared ' . "--host={$this->builder->getOption('gnu-arch')}-apple-darwin " . diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index 8ac99b7f..c768512d 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -48,7 +48,7 @@ class openssl extends MacOSLibraryBase shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./Configure no-shared {$extra} " . + "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . '--openssldir=/System/Library/OpenSSL ' . diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index 3af58426..2d0d43d2 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -21,9 +21,6 @@ trait UnixBuilderTrait /** @var string cmake toolchain file */ public string $cmake_toolchain_file; - /** @var string configure environments */ - public string $configure_env; - /** * @throws WrongUsageException * @throws FileSystemException @@ -145,7 +142,7 @@ trait UnixBuilderTrait */ public function makeCmakeArgs(): string { - $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . $this->getOption('cc') . ' ' : ''; + $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : ''; return $extra . '-DCMAKE_BUILD_TYPE=Release ' . '-DCMAKE_INSTALL_PREFIX=/ ' . diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index b84fc7ed..92c04de4 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -19,7 +19,7 @@ trait brotli FileSystem::resetDir($this->source_dir . '/build-dir'); shell()->cd($this->source_dir . '/build-dir') ->exec( - $this->builder->configure_env . ' cmake ' . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . '..' diff --git a/src/SPC/builder/unix/library/bzip2.php b/src/SPC/builder/unix/library/bzip2.php index bb4f0d9e..8de623d4 100644 --- a/src/SPC/builder/unix/library/bzip2.php +++ b/src/SPC/builder/unix/library/bzip2.php @@ -9,8 +9,8 @@ trait bzip2 protected function build(): void { shell()->cd($this->source_dir) - ->exec("make {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' clean") - ->exec("make -j{$this->builder->concurrency} {$this->builder->configure_env} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") + ->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean") + ->exec("make -j{$this->builder->concurrency} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") ->exec('cp libbz2.a ' . BUILD_LIB_PATH) ->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH); } diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index c7bbc275..216f42b5 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -52,7 +52,7 @@ trait curl // compile! shell()->cd($this->source_dir . '/build') ->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt') - ->exec("{$this->builder->configure_env} cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..") + ->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..") ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconf diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index ee7bc9aa..8ef3368f 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -27,7 +27,7 @@ trait freetype shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static --disable-shared --without-harfbuzz --prefix= ' . $suggested ) diff --git a/src/SPC/builder/unix/library/gmp.php b/src/SPC/builder/unix/library/gmp.php index bc95a3eb..f1902dde 100644 --- a/src/SPC/builder/unix/library/gmp.php +++ b/src/SPC/builder/unix/library/gmp.php @@ -17,7 +17,7 @@ trait gmp { shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static --disable-shared ' . '--prefix=' ) diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 7e291e8c..40a46992 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; +use SPC\builder\linux\LinuxBuilder; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -17,7 +18,8 @@ trait imagemagick */ protected function build(): void { - $extra = '--without-jxl --without-x --disable-openmp '; + // TODO: imagemagick build with bzip2 failed with bugs, we need to fix it in the future + $extra = '--without-jxl --without-x --disable-openmp --without-bzlib '; $required_libs = ''; $optional_libs = [ 'libzip' => 'zip', @@ -26,6 +28,7 @@ trait imagemagick 'libwebp' => 'webp', 'libxml2' => 'xml', 'zlib' => 'zlib', + 'xz' => 'lzma', 'zstd' => 'zstd', 'freetype' => 'freetype', ]; @@ -38,8 +41,7 @@ trait imagemagick shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} " . - 'LDFLAGS="-static" ' . + ($this->builder instanceof LinuxBuilder ? ('LDFLAGS="-static -L' . BUILD_LIB_PATH . '" ') : '') . "LIBS='{$required_libs}' " . './configure ' . '--enable-static --disable-shared ' . diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index d1ffcbd7..9b4080df 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -17,7 +17,6 @@ trait ldap $alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : ''; shell()->cd($this->source_dir) ->exec( - $this->builder->configure_env . ' ' . $this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) . ' ./configure ' . '--enable-static ' . diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index 56b17bdb..592899b2 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -22,12 +22,7 @@ trait libavif FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec( - "{$this->builder->configure_env} cmake " . - $this->builder->makeCmakeArgs() . ' ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconfig diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index 59e59f53..d9b2d81b 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -21,7 +21,7 @@ trait libevent // Start build shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DCMAKE_BUILD_TYPE=Release ' . diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index dacfab1e..5096e724 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -12,7 +12,7 @@ trait libiconv shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . '--prefix=' diff --git a/src/SPC/builder/unix/library/libjpeg.php b/src/SPC/builder/unix/library/libjpeg.php index 88845c49..df02bd13 100644 --- a/src/SPC/builder/unix/library/libjpeg.php +++ b/src/SPC/builder/unix/library/libjpeg.php @@ -23,7 +23,7 @@ trait libjpeg // Start build shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} cmake {$this->builder->makeCmakeArgs()} " . + "cmake {$this->builder->makeCmakeArgs()} " . '-DENABLE_STATIC=ON ' . '-DENABLE_SHARED=OFF ' . '..' diff --git a/src/SPC/builder/unix/library/libsodium.php b/src/SPC/builder/unix/library/libsodium.php index f12727d7..555b48d6 100644 --- a/src/SPC/builder/unix/library/libsodium.php +++ b/src/SPC/builder/unix/library/libsodium.php @@ -10,7 +10,7 @@ trait libsodium { $root = BUILD_ROOT_PATH; shell()->cd($this->source_dir) - ->exec("{$this->builder->configure_env} ./configure --enable-static --disable-shared --prefix={$root}") + ->exec("./configure --enable-static --disable-shared --prefix={$root}") ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install'); diff --git a/src/SPC/builder/unix/library/libssh2.php b/src/SPC/builder/unix/library/libssh2.php index a207f27b..32d96b9a 100644 --- a/src/SPC/builder/unix/library/libssh2.php +++ b/src/SPC/builder/unix/library/libssh2.php @@ -21,7 +21,7 @@ trait libssh2 FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} " . ' cmake ' . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . '-DBUILD_EXAMPLES=OFF ' . diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index 32aa7201..eef6d039 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -23,7 +23,7 @@ trait libwebp // Start build shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . $this->builder->makeCmakeArgs() . ' ' . '-DBUILD_SHARED_LIBS=OFF ' . '-DWEBP_BUILD_EXTRAS=ON ' . diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 847c30e0..17fb2f1e 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -26,7 +26,6 @@ trait libxslt } shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} " . 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ' . "{$this->builder->getOption('library_path')} " . "{$this->builder->getOption('ld_library_path')} " . diff --git a/src/SPC/builder/unix/library/libyaml.php b/src/SPC/builder/unix/library/libyaml.php index b35cd25f..b1b545cf 100644 --- a/src/SPC/builder/unix/library/libyaml.php +++ b/src/SPC/builder/unix/library/libyaml.php @@ -60,7 +60,7 @@ EOF FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . // '--debug-find ' . '-DCMAKE_BUILD_TYPE=Release ' . '-DBUILD_TESTING=OFF ' . diff --git a/src/SPC/builder/unix/library/libzip.php b/src/SPC/builder/unix/library/libzip.php index f21678ae..83e0600c 100644 --- a/src/SPC/builder/unix/library/libzip.php +++ b/src/SPC/builder/unix/library/libzip.php @@ -29,7 +29,7 @@ trait libzip FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - "{$this->builder->configure_env} " . ' cmake ' . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DENABLE_GNUTLS=OFF ' . '-DENABLE_MBEDTLS=OFF ' . diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index f3ec2636..790c77b6 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -10,7 +10,7 @@ trait ncurses { shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . '--enable-overwrite ' . diff --git a/src/SPC/builder/unix/library/onig.php b/src/SPC/builder/unix/library/onig.php index e9414ab2..b43d14b3 100644 --- a/src/SPC/builder/unix/library/onig.php +++ b/src/SPC/builder/unix/library/onig.php @@ -18,12 +18,7 @@ trait onig [,,$destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) - ->exec( - "{$this->builder->configure_env} " . ' ./configure ' . - '--enable-static ' . - '--disable-shared ' . - '--prefix=' - ) + ->exec('./configure --enable-static --disable-shared --prefix=') ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec("make install DESTDIR={$destdir}"); diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index 822371a8..52ec5e4d 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -8,13 +8,8 @@ trait pkgconfig { protected function build(): void { - $macos_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig/" ' . - "CC='{$this->builder->getOption('cc')}' " . - "CXX='{$this->builder->getOption('cxx')}' " . - "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' "; - $linux_env = 'PKG_CONFIG_PATH="' . BUILD_LIB_PATH . '/pkgconfig" ' . - "CC='{$this->builder->getOption('cc')}' " . - "CXX='{$this->builder->getOption('cxx')}' "; + $macos_env = "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' "; + $linux_env = 'LDFLAGS=--static '; shell()->cd($this->source_dir) ->exec( diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index eaf6710e..235e40f0 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -18,8 +18,7 @@ trait postgresql protected function build(): void { $builddir = BUILD_ROOT_PATH; - $env = $this->builder->configure_env; - $envs = $env; + $envs = ''; $packages = 'openssl zlib readline libxml-2.0 zlib'; $optional_packages = [ 'zstd' => 'libzstd', @@ -34,18 +33,17 @@ trait postgresql } } - $pkgconfig_executable = $builddir . '/bin/pkg-config'; - $output = shell()->execWithResult($env . " {$pkgconfig_executable} --cflags-only-I --static " . $packages); + $output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}"); if (!empty($output[1][0])) { $cppflags = $output[1][0]; $envs .= " CPPFLAGS=\"{$cppflags}\""; } - $output = shell()->execWithResult($env . " {$pkgconfig_executable} --libs-only-L --static " . $packages); + $output = shell()->execWithResult("pkg-config --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 . " {$pkgconfig_executable} --libs-only-l --static " . $packages); + $output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}"); if (!empty($output[1][0])) { $libs = $output[1][0]; $envs .= " LIBS=\"{$libs} -lstdc++\" "; diff --git a/src/SPC/builder/unix/library/readline.php b/src/SPC/builder/unix/library/readline.php index fc865238..4f725129 100644 --- a/src/SPC/builder/unix/library/readline.php +++ b/src/SPC/builder/unix/library/readline.php @@ -17,7 +17,7 @@ trait readline { shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static=yes ' . '--enable-shared=no ' . '--prefix= ' . diff --git a/src/SPC/builder/unix/library/snappy.php b/src/SPC/builder/unix/library/snappy.php index 18f5e78c..d7a5ade0 100644 --- a/src/SPC/builder/unix/library/snappy.php +++ b/src/SPC/builder/unix/library/snappy.php @@ -20,7 +20,7 @@ trait snappy shell()->cd($this->source_dir . '/cmake/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . "{$this->builder->makeCmakeArgs()} " . '-DSNAPPY_BUILD_TESTS=OFF ' . diff --git a/src/SPC/builder/unix/library/sqlite.php b/src/SPC/builder/unix/library/sqlite.php index f9947df7..b706a39f 100644 --- a/src/SPC/builder/unix/library/sqlite.php +++ b/src/SPC/builder/unix/library/sqlite.php @@ -9,7 +9,7 @@ trait sqlite protected function build(): void { shell()->cd($this->source_dir) - ->exec("{$this->builder->configure_env} ./configure --enable-static --disable-shared --prefix=") + ->exec('./configure --enable-static --disable-shared --prefix=') ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index 1f214b3a..7cd7e74b 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -17,7 +17,7 @@ trait xz { shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + './configure ' . '--enable-static ' . '--disable-shared ' . "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . diff --git a/src/SPC/builder/unix/library/zlib.php b/src/SPC/builder/unix/library/zlib.php index 5dd0ee10..b380f8b0 100644 --- a/src/SPC/builder/unix/library/zlib.php +++ b/src/SPC/builder/unix/library/zlib.php @@ -18,7 +18,7 @@ trait zlib [,,$destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) - ->exec("{$this->builder->configure_env} ./configure --static --prefix=") + ->exec('./configure --static --prefix=') ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec("make install DESTDIR={$destdir}"); diff --git a/src/SPC/builder/unix/library/zstd.php b/src/SPC/builder/unix/library/zstd.php index de375b25..399eeedc 100644 --- a/src/SPC/builder/unix/library/zstd.php +++ b/src/SPC/builder/unix/library/zstd.php @@ -19,7 +19,7 @@ trait zstd FileSystem::resetDir($this->source_dir . '/build/cmake/build'); shell()->cd($this->source_dir . '/build/cmake/build') ->exec( - "{$this->builder->configure_env} cmake " . + 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DZSTD_BUILD_STATIC=ON ' . '-DZSTD_BUILD_SHARED=OFF ' . diff --git a/src/SPC/command/BuildCommand.php b/src/SPC/command/BuildCommand.php index 0c985b13..4d3f7d06 100644 --- a/src/SPC/command/BuildCommand.php +++ b/src/SPC/command/BuildCommand.php @@ -19,11 +19,11 @@ abstract class BuildCommand extends BaseCommand $this->addOption('arch', null, InputOption::VALUE_REQUIRED, 'architecture, "x64" or "arm64"', 'x64'); break; case 'Linux': - $this->addOption('no-system-static', null, null, 'do not use system static libraries'); - // no break case 'Darwin': $this->addOption('cc', null, InputOption::VALUE_REQUIRED, 'C compiler'); $this->addOption('cxx', null, InputOption::VALUE_REQUIRED, 'C++ compiler'); + $this->addOption('ar', null, InputOption::VALUE_REQUIRED, 'ar'); + $this->addOption('ld', null, InputOption::VALUE_REQUIRED, 'ld'); $this->addOption('arch', null, InputOption::VALUE_REQUIRED, 'architecture', php_uname('m')); break; }