introduce library_path and ld_library_path options to linuxbuilder (some libs require it to load -lstdc++)

This commit is contained in:
DubbleClick 2023-10-17 00:52:49 +02:00
parent a83a457905
commit da1cbeb79c
3 changed files with 26 additions and 5 deletions

View File

@ -434,7 +434,10 @@
"readline"
],
"lib-suggests": [
"icu"
"icu",
"libxslt",
"ldap",
"zstd"
]
},
"pthreads4w": {
@ -464,10 +467,9 @@
"libsnappy.a"
],
"headers-unix": [
"snappy.h",
"snappy-c.h",
"snappy-sinksource.h",
"snappy.h",
"snappy-stubs-internal.h",
"snappy-stubs-public.h"
],
"lib-depends": [

View File

@ -41,10 +41,14 @@ class LinuxBuilder extends BuilderBase
if (SystemUtil::isMuslDist()) {
$this->setOptionIfNotExist('cc', 'gcc');
$this->setOptionIfNotExist('cxx', 'g++');
$this->setOptionIfNotExist('library_path', '');
$this->setOptionIfNotExist('ld_library_path', '');
} else {
$arch = arch2gnu(php_uname('m'));
$this->setOptionIfNotExist('cc', "{$arch}-linux-musl-gcc");
$this->setOptionIfNotExist('cxx', "{$arch}-linux-musl-g++");
$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");
}
// set arch (default: current)
$this->setOptionIfNotExist('arch', php_uname('m'));
@ -174,7 +178,7 @@ class LinuxBuilder extends BuilderBase
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
(!SystemUtil::isMuslDist() ? "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib " : '') .
"{$this->getOption('ld_library_path')} " .
'./configure ' .
'--prefix= ' .
'--with-valgrind=no ' .

View File

@ -4,20 +4,35 @@ declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\builder\linux\library\LinuxLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\exception\WrongUsageException;
trait libxslt
{
/**
* @throws FileSystemException
* @throws RuntimeException
* @throws WrongUsageException
*/
protected function build(): void
{
$required_libs = '';
foreach ($this->getDependencies() as $dep) {
if ($dep instanceof LinuxLibraryBase) {
$required_libs .= ' ' . $dep->getStaticLibFiles();
}
}
shell()->cd($this->source_dir)
->exec(
"{$this->builder->configure_env} ./configure " .
"{$this->builder->configure_env} " .
'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ' .
"{$this->builder->getOption('library_path')} " .
"{$this->builder->getOption('ld_library_path')} " .
'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' .
"LIBS='{$required_libs} -lstdc++' " .
'./configure ' .
'--enable-static --disable-shared ' .
'--without-python ' .
'--without-mem-debug ' .