allow patching of extra_libs before make on linux too

This commit is contained in:
DubbleClick
2023-10-16 14:08:22 +02:00
parent 830f379bf6
commit 46b0ecf3fa

View File

@@ -203,22 +203,22 @@ class LinuxBuilder extends BuilderBase
if ($enableCli) { if ($enableCli) {
logger()->info('building cli'); logger()->info('building cli');
$this->buildCli($extra_libs, $use_lld); $this->buildCli($use_lld);
} }
if ($enableFpm) { if ($enableFpm) {
logger()->info('building fpm'); logger()->info('building fpm');
$this->buildFpm($extra_libs, $use_lld); $this->buildFpm($use_lld);
} }
if ($enableMicro) { if ($enableMicro) {
logger()->info('building micro'); logger()->info('building micro');
$this->buildMicro($extra_libs, $use_lld, $cflags); $this->buildMicro($use_lld, $cflags);
} }
if ($enableEmbed) { if ($enableEmbed) {
logger()->info('building embed'); logger()->info('building embed');
if ($enableMicro) { if ($enableMicro) {
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la');
} }
$this->buildEmbed($extra_libs, $use_lld); $this->buildEmbed($use_lld);
} }
if (php_uname('m') === $this->getOption('arch')) { if (php_uname('m') === $this->getOption('arch')) {
@@ -232,11 +232,11 @@ class LinuxBuilder extends BuilderBase
* @throws RuntimeException * @throws RuntimeException
* @throws FileSystemException * @throws FileSystemException
*/ */
public function buildCli(string $extra_libs, string $use_lld): void public function buildCli(string $use_lld): void
{ {
$vars = SystemUtil::makeEnvVarString([ $vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)),
'EXTRA_LIBS' => $extra_libs, 'EXTRA_LIBS' => $this->getOption('extra-libs', ''),
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static",
]); ]);
shell()->cd(SOURCE_PATH . '/php-src') shell()->cd(SOURCE_PATH . '/php-src')
@@ -256,7 +256,7 @@ class LinuxBuilder extends BuilderBase
* @throws RuntimeException * @throws RuntimeException
* @throws FileSystemException * @throws FileSystemException
*/ */
public function buildMicro(string $extra_libs, string $use_lld, string $cflags): void public function buildMicro(string $use_lld, string $cflags): void
{ {
if ($this->getPHPVersionID() < 80000) { if ($this->getPHPVersionID() < 80000) {
throw new RuntimeException('phpmicro only support PHP >= 8.0!'); throw new RuntimeException('phpmicro only support PHP >= 8.0!');
@@ -269,7 +269,7 @@ class LinuxBuilder extends BuilderBase
$enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '';
$vars = SystemUtil::makeEnvVarString([ $vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $enable_fake_cli, 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $enable_fake_cli,
'EXTRA_LIBS' => $extra_libs, 'EXTRA_LIBS' => $this->getOption('extra-libs', ''),
'EXTRA_LDFLAGS_PROGRAM' => "{$cflags} {$use_lld} -all-static", 'EXTRA_LDFLAGS_PROGRAM' => "{$cflags} {$use_lld} -all-static",
]); ]);
shell()->cd(SOURCE_PATH . '/php-src') shell()->cd(SOURCE_PATH . '/php-src')
@@ -293,11 +293,11 @@ class LinuxBuilder extends BuilderBase
* @throws FileSystemException * @throws FileSystemException
* @throws RuntimeException * @throws RuntimeException
*/ */
public function buildFpm(string $extra_libs, string $use_lld): void public function buildFpm(string $use_lld): void
{ {
$vars = SystemUtil::makeEnvVarString([ $vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)),
'EXTRA_LIBS' => $extra_libs, 'EXTRA_LIBS' => $this->getOption('extra-libs', ''),
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static",
]); ]);
@@ -312,11 +312,11 @@ class LinuxBuilder extends BuilderBase
$this->deployBinary(BUILD_TARGET_FPM); $this->deployBinary(BUILD_TARGET_FPM);
} }
public function buildEmbed(string $extra_libs, string $use_lld): void public function buildEmbed(string $use_lld): void
{ {
$vars = SystemUtil::makeEnvVarString([ $vars = SystemUtil::makeEnvVarString([
'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)), 'EXTRA_CFLAGS' => '-g -Os -fno-ident ' . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)),
'EXTRA_LIBS' => $extra_libs, 'EXTRA_LIBS' => $this->getOption('extra-libs', ''),
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static", 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static",
]); ]);