Skip to content

Commit a95d034

Browse files
henderkesmhpcccrazywhalecc
authored
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 <[email protected]> Co-authored-by: crazywhalecc <[email protected]>
1 parent 29ea46b commit a95d034

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ public function __construct(array $options = [])
2929
// check musl-cross make installed if we use musl-cross-make
3030
$arch = arch2gnu(php_uname('m'));
3131

32-
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
33-
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
34-
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
35-
3632
GlobalEnvManager::init($this);
3733

34+
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
35+
if (!filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN)) {
36+
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
37+
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
38+
}
39+
3840
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')) {
3941
throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)');
4042
}

src/SPC/util/GlobalEnvManager.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ public static function init(?BuilderBase $builder = null): void
5757
self::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++");
5858
self::putenv("SPC_LINUX_DEFAULT_AR={$arch}-linux-musl-ar");
5959
}
60-
self::putenv("SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD=LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
61-
if (getenv('SPC_NO_MUSL_PATH') !== 'yes') {
62-
self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH'));
63-
}
6460
}
6561

6662
// Init env.ini file, read order:
@@ -91,6 +87,11 @@ public static function init(?BuilderBase $builder = null): void
9187
'BSD' => self::applyConfig($ini['freebsd']),
9288
default => null,
9389
};
90+
91+
if (PHP_OS_FAMILY === 'Linux' && !filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN)) {
92+
self::putenv("SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD=LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
93+
self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH'));
94+
}
9495
}
9596

9697
public static function putenv(string $val): void

0 commit comments

Comments
 (0)