fix SPC_NO_MUSL_PATH not working in .env.ini

This commit is contained in:
Marc Henderkes
2025-03-04 07:21:35 +01:00
parent 34934368a2
commit 2868cb02f7
2 changed files with 11 additions and 8 deletions

View File

@@ -29,12 +29,14 @@ class LinuxBuilder extends UnixBuilderBase
// check musl-cross make installed if we use musl-cross-make
$arch = arch2gnu(php_uname('m'));
// 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('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
GlobalEnvManager::init($this);
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
if (getenv('SPC_NO_MUSL_PATH') !== '1') {
$this->setOptionIfNotExist('library_path', 'LIBRARY_PATH=/usr/local/musl/lib');
$this->setOptionIfNotExist('ld_library_path', 'LD_LIBRARY_PATH=/usr/local/musl/lib');
}
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc") && (getenv('SPC_NO_MUSL_PATH') !== 'yes')) {
throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)');
}

View File

@@ -57,10 +57,6 @@ class GlobalEnvManager
self::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++");
self::putenv("SPC_LINUX_DEFAULT_AR={$arch}-linux-musl-ar");
}
self::putenv("SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD=LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
if (getenv('SPC_NO_MUSL_PATH') !== 'yes') {
self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH'));
}
}
// Init env.ini file, read order:
@@ -91,6 +87,11 @@ class GlobalEnvManager
'BSD' => self::applyConfig($ini['freebsd']),
default => null,
};
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_NO_MUSL_PATH') !== '1') {
self::putenv("SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD=LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH'));
}
}
public static function putenv(string $val): void