Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/SPC/builder/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,26 @@ public function buildUnixShared(): void
logger()->info("Extension [{$this->getName()}] patched before shared configure");
}

// Parse and add SPC_EXTRA_PHP_VARS as environment variables
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
if ($phpvars !== '') {
// Parse space-separated key=value pairs
$parts = preg_split('/\s+/', trim($phpvars), -1, PREG_SPLIT_NO_EMPTY);
foreach ($parts as $part) {
if (str_contains($part, '=')) {
[$key, $value] = explode('=', $part, 2);
$env[$key] = $value;
}
}
}

shell()->cd($this->source_dir)
->setEnv($env)
->appendEnv($this->getExtraEnv())
->exec(
'./configure ' . $this->getUnixConfigureArg(true) .
' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' .
"--enable-shared --disable-static {$phpvars}"
'--enable-shared --disable-static'
);

if ($this->patchBeforeSharedMake()) {
Expand Down
18 changes: 15 additions & 3 deletions src/SPC/builder/linux/LinuxBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,27 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void

// prepare build php envs
// $musl_flag = SPCTarget::getLibc() === 'musl' ? ' -D__MUSL__' : ' -U__MUSL__';
$php_configure_env = SystemUtil::makeEnvVarString([
$env_vars = [
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, // . ' -Dsomethinghere', // . $musl_flag,
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
]);
];

// Parse and add SPC_EXTRA_PHP_VARS as environment variables
$phpvars = getenv('SPC_EXTRA_PHP_VARS') ?: '';
if ($phpvars !== '') {
// Parse space-separated key=value pairs
$parts = preg_split('/\s+/', trim($phpvars), -1, PREG_SPLIT_NO_EMPTY);
foreach ($parts as $part) {
if (str_contains($part, '=')) {
[$key, $value] = explode('=', $part, 2);
$env_vars[$key] = $value;
}
}
}

$php_configure_env = SystemUtil::makeEnvVarString($env_vars);

$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
if ($embed_type !== 'static' && SPCTarget::isStatic()) {
Expand All @@ -123,7 +136,6 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
$json_74 .
$zts .
$maxExecutionTimers .
$phpvars . ' ' .
$this->makeStaticExtensionArgs() . ' '
));

Expand Down
Loading