mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
create helper method to pass environment variables to 'make'
This commit is contained in:
parent
9b9644fe63
commit
c24dc8f518
@ -319,6 +319,18 @@ abstract class BuilderBase
|
|||||||
$this->options[$key] = $value;
|
$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.
|
* Check if all libs are downloaded.
|
||||||
* If not, throw exception.
|
* If not, throw exception.
|
||||||
|
|||||||
@ -45,8 +45,8 @@ class LinuxBuilder extends BuilderBase
|
|||||||
f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}");
|
f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}");
|
||||||
f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}");
|
f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}");
|
||||||
f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}");
|
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("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'));
|
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)
|
// 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");
|
$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')
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
->exec(
|
->exec(
|
||||||
|
"{$this->getOption('ld_library_path')} " .
|
||||||
'./configure ' .
|
'./configure ' .
|
||||||
'--prefix= ' .
|
'--prefix= ' .
|
||||||
'--with-valgrind=no ' .
|
'--with-valgrind=no ' .
|
||||||
|
|||||||
@ -10,7 +10,7 @@ trait bzip2
|
|||||||
{
|
{
|
||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean")
|
->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 libbz2.a ' . BUILD_LIB_PATH)
|
||||||
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
|
->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user