Skip to content

Commit

Permalink
introduce library_path and ld_library_path options to linuxbuilder (s…
Browse files Browse the repository at this point in the history
…ome libs require it to load -lstdc++)
  • Loading branch information
DubbleClick committed Oct 17, 2023
1 parent 6a3c5af commit e06bab3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
8 changes: 5 additions & 3 deletions config/lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@
"readline"
],
"lib-suggests": [
"icu"
"icu",
"libxslt",
"ldap",
"zstd"
]
},
"pthreads4w": {
Expand Down Expand Up @@ -463,10 +466,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": [
Expand Down
6 changes: 5 additions & 1 deletion src/SPC/builder/linux/LinuxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ public function __construct(array $options = [])
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'));
Expand Down Expand Up @@ -174,7 +178,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void

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 ' .
Expand Down
17 changes: 16 additions & 1 deletion src/SPC/builder/unix/library/libxslt.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,35 @@

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 ' .
Expand Down

0 comments on commit e06bab3

Please sign in to comment.