Skip to content

Commit

Permalink
Merge remote-tracking branch 'DubbleClick/cplus' into cplus
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/SPC/builder/unix/library/bzip2.php
  • Loading branch information
crazywhalecc committed Oct 26, 2023
2 parents 8dcec73 + c24dc8f commit e00908d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
12 changes: 12 additions & 0 deletions src/SPC/builder/BuilderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,18 @@ public function setOption(string $key, mixed $value): void
$this->options[$key] = $value;
}

public function getEnvString(array $vars = ['cc', 'cxx', 'ar', 'ld']): string
{
$env = [];
foreach ($vars as $var) {
$var = strtoupper($var);
if (getenv($var) !== false) {
$env[] = "{$var}=" . getenv($var);
}
}
return implode(' ', $env);
}

/**
* Check if all libs are downloaded.
* If not, throw exception.
Expand Down
5 changes: 3 additions & 2 deletions src/SPC/builder/linux/LinuxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function __construct(array $options = [])
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'));
f_putenv("LD={$this->getOption('ld', '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");
Expand Down Expand Up @@ -176,6 +176,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void

shell()->cd(SOURCE_PATH . '/php-src')
->exec(
"{$this->getOption('ld_library_path')} " .
'./configure ' .
'--prefix= ' .
'--with-valgrind=no ' .
Expand Down
7 changes: 1 addition & 6 deletions src/SPC/builder/unix/library/bzip2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@ trait bzip2
{
protected function build(): void
{
$cc = getenv('CC');
$ar = getenv('AR');
if ($ar === false) {
$ar = 'ar';
}
shell()->cd($this->source_dir)
->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean")
->exec("make -j{$this->builder->concurrency} PREFIX='" . BUILD_ROOT_PATH . "' CC={$cc} AR={$ar} libbz2.a")
->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a")
->exec('cp libbz2.a ' . BUILD_LIB_PATH)
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
}
Expand Down

0 comments on commit e00908d

Please sign in to comment.