diff --git a/src/SPC/builder/windows/SystemUtil.php b/src/SPC/builder/windows/SystemUtil.php index e1794f94..4d3d38ff 100644 --- a/src/SPC/builder/windows/SystemUtil.php +++ b/src/SPC/builder/windows/SystemUtil.php @@ -21,7 +21,7 @@ class SystemUtil if (!$paths) { $paths = explode(PATH_SEPARATOR, getenv('Path')); if ($include_sdk_bin) { - $paths[] = PHP_SDK_PATH . '\bin'; + $paths[] = getenv('PHP_SDK_PATH') . '\bin'; } } foreach ($paths as $path) { diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 1c1646d7..ecccce19 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -38,7 +38,7 @@ class WindowsBuilder extends BuilderBase // ---------- set necessary options ---------- // set sdk (require visual studio 16 or 17) $vs = SystemUtil::findVisualStudio()['version']; - $this->sdk_prefix = PHP_SDK_PATH . "\\phpsdk-{$vs}-x64.bat -t"; + $this->sdk_prefix = getenv('PHP_SDK_PATH') . "\\phpsdk-{$vs}-x64.bat -t"; // set zts $this->zts = $this->getOption('enable-zts', false); diff --git a/src/SPC/doctor/item/WindowsToolCheckList.php b/src/SPC/doctor/item/WindowsToolCheckList.php index b66737cc..bfeb063e 100644 --- a/src/SPC/doctor/item/WindowsToolCheckList.php +++ b/src/SPC/doctor/item/WindowsToolCheckList.php @@ -37,10 +37,10 @@ class WindowsToolCheckList #[AsCheckItem('if php-sdk-binary-tools are downloaded', limit_os: 'Windows', level: 997)] public function checkSDK(): ?CheckResult { - if (!file_exists(PHP_SDK_PATH . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) { + if (!file_exists(getenv('PHP_SDK_PATH') . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) { return CheckResult::fail('php-sdk-binary-tools not downloaded', 'install-php-sdk'); } - return CheckResult::ok(PHP_SDK_PATH); + return CheckResult::ok(getenv('PHP_SDK_PATH')); } #[AsCheckItem('if git associated command exists', limit_os: 'Windows', level: 996)] @@ -81,8 +81,8 @@ class WindowsToolCheckList public function installPhpSdk(): bool { try { - FileSystem::removeDir(PHP_SDK_PATH); - cmd(true)->exec('git.exe clone --depth 1 https://github.com/php/php-sdk-binary-tools.git ' . PHP_SDK_PATH); + FileSystem::removeDir(getenv('PHP_SDK_PATH')); + cmd(true)->exec('git.exe clone --depth 1 https://github.com/php/php-sdk-binary-tools.git ' . getenv('PHP_SDK_PATH')); } catch (RuntimeException) { return false; } diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index cbf6107e..4b5b32d6 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -428,7 +428,7 @@ class FileSystem { $replacement = [ '{pkg_root_path}' => PKG_ROOT_PATH, - '{php_sdk_path}' => defined('PHP_SDK_PATH') ? PHP_SDK_PATH : WORKING_DIR . '/php-sdk-binary-tools', + '{php_sdk_path}' => getenv('PHP_SDK_PATH') ? getenv('PHP_SDK_PATH') : WORKING_DIR . '/php-sdk-binary-tools', '{working_dir}' => WORKING_DIR, '{download_path}' => DOWNLOAD_PATH, '{source_path}' => SOURCE_PATH, @@ -480,7 +480,7 @@ class FileSystem }; } elseif (PHP_OS_FAMILY === 'Windows') { // use php-sdk-binary-tools/bin/7za.exe - $_7z = self::convertPath(PHP_SDK_PATH . '/bin/7za.exe'); + $_7z = self::convertPath(getenv('PHP_SDK_PATH') . '/bin/7za.exe'); // Windows notes: I hate windows tar....... // When extracting .tar.gz like libxml2, it shows a symlink error and returns code[1]. diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 8bbe863a..230ad2e8 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -46,7 +46,7 @@ class GlobalEnvManager // Define env vars for linux if (PHP_OS_FAMILY === 'Linux') { - $arch = GNU_ARCH; + $arch = arch2gnu(php_uname('m')); if (SystemUtil::isMuslDist()) { self::putenv('SPC_LINUX_DEFAULT_CC=gcc'); self::putenv('SPC_LINUX_DEFAULT_CXX=g++');