create helper method to pass environment variables to 'make'

This commit is contained in:
DubbleClick 2023-10-24 12:21:36 +02:00
parent 9b9644fe63
commit c24dc8f518
3 changed files with 16 additions and 3 deletions

View File

@ -319,6 +319,18 @@ abstract class BuilderBase
$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.

View File

@ -45,8 +45,8 @@ class LinuxBuilder extends BuilderBase
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");
@ -176,6 +176,7 @@ class LinuxBuilder extends BuilderBase
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
"{$this->getOption('ld_library_path')} " .
'./configure ' .
'--prefix= ' .
'--with-valgrind=no ' .

View File

@ -10,7 +10,7 @@ trait bzip2
{
shell()->cd($this->source_dir)
->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean")
->exec("make -j{$this->builder->concurrency} PREFIX='" . BUILD_ROOT_PATH . "' 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);
}