From c24dc8f5186fbe9687874939ee8f6793cbc29488 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 24 Oct 2023 12:21:36 +0200 Subject: [PATCH] create helper method to pass environment variables to 'make' --- src/SPC/builder/BuilderBase.php | 12 ++++++++++++ src/SPC/builder/linux/LinuxBuilder.php | 5 +++-- src/SPC/builder/unix/library/bzip2.php | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index eb18f485a..6e46886f9 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -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. diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 1aa6cdc9a..73d47acc6 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -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"); @@ -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 ' . diff --git a/src/SPC/builder/unix/library/bzip2.php b/src/SPC/builder/unix/library/bzip2.php index 8de623d46..71990125f 100644 --- a/src/SPC/builder/unix/library/bzip2.php +++ b/src/SPC/builder/unix/library/bzip2.php @@ -10,7 +10,7 @@ protected function build(): void { 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); }