mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +08:00
fix SPC_NO_MUSL_PATH not working in .env.ini (#612)
* fix SPC_NO_MUSL_PATH not working in .env.ini * use filter var instead of assuming var was defined in .env.ini * CS fix and composer update * update composer.lock * fix LIBRARY_PATH and LD_LIBRARY_PATH * Revert composer lock and cs-fixer options * filter validate boolean --------- Co-authored-by: Marc Henderkes <m.henderkes@pc-college.de> Co-authored-by: crazywhalecc <jesse2061@outlook.com>
This commit is contained in:
parent
29ea46bd17
commit
a95d034e98
@ -29,12 +29,14 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
// check musl-cross make installed if we use musl-cross-make
|
// check musl-cross make installed if we use musl-cross-make
|
||||||
$arch = arch2gnu(php_uname('m'));
|
$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);
|
GlobalEnvManager::init($this);
|
||||||
|
|
||||||
|
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
|
||||||
|
if (!filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN)) {
|
||||||
|
$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\"");
|
||||||
|
}
|
||||||
|
|
||||||
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')) {
|
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)');
|
throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,10 +57,6 @@ class GlobalEnvManager
|
|||||||
self::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++");
|
self::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++");
|
||||||
self::putenv("SPC_LINUX_DEFAULT_AR={$arch}-linux-musl-ar");
|
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:
|
// Init env.ini file, read order:
|
||||||
@ -91,6 +87,11 @@ class GlobalEnvManager
|
|||||||
'BSD' => self::applyConfig($ini['freebsd']),
|
'BSD' => self::applyConfig($ini['freebsd']),
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (PHP_OS_FAMILY === 'Linux' && !filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN)) {
|
||||||
|
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
|
public static function putenv(string $val): void
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user