2024-10-01 15:37:37 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use SPC\builder\freebsd\SystemUtil as BSDSystemUtil;
|
|
|
|
|
use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
|
|
|
|
|
use SPC\builder\macos\SystemUtil as MacOSSystemUtil;
|
|
|
|
|
use SPC\builder\windows\SystemUtil as WindowsSystemUtil;
|
2025-08-01 10:58:31 +08:00
|
|
|
use SPC\ConsoleApplication;
|
2024-10-01 15:37:37 +08:00
|
|
|
use SPC\store\FileSystem;
|
|
|
|
|
use SPC\util\GlobalEnvManager;
|
|
|
|
|
|
2025-08-01 10:58:31 +08:00
|
|
|
// static-php-cli version string
|
|
|
|
|
const SPC_VERSION = ConsoleApplication::VERSION;
|
2025-05-15 23:30:07 +07:00
|
|
|
// output path for everything, other paths are defined relative to this by default
|
2024-10-01 15:37:37 +08:00
|
|
|
define('BUILD_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot')));
|
2025-05-15 23:30:07 +07:00
|
|
|
// output path for header files for development
|
2024-10-01 15:37:37 +08:00
|
|
|
define('BUILD_INCLUDE_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_INCLUDE_PATH')) ? $a : (BUILD_ROOT_PATH . '/include')));
|
2025-05-15 23:30:07 +07:00
|
|
|
// output path for libraries and for libphp.so, if building shared embed
|
2024-10-01 15:37:37 +08:00
|
|
|
define('BUILD_LIB_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_LIB_PATH')) ? $a : (BUILD_ROOT_PATH . '/lib')));
|
2025-05-15 23:30:07 +07:00
|
|
|
// output path for binaries
|
2024-10-01 15:37:37 +08:00
|
|
|
define('BUILD_BIN_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_BIN_PATH')) ? $a : (BUILD_ROOT_PATH . '/bin')));
|
2025-05-15 23:30:07 +07:00
|
|
|
// output path for shared extensions
|
|
|
|
|
define('BUILD_MODULES_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_MODULES_PATH')) ? $a : (BUILD_ROOT_PATH . '/modules')));
|
|
|
|
|
|
2024-10-01 15:37:37 +08:00
|
|
|
define('PKG_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('PKG_ROOT_PATH')) ? $a : (WORKING_DIR . '/pkgroot')));
|
|
|
|
|
define('SOURCE_PATH', FileSystem::convertPath(is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source')));
|
|
|
|
|
define('DOWNLOAD_PATH', FileSystem::convertPath(is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads')));
|
|
|
|
|
define('CPU_COUNT', match (PHP_OS_FAMILY) {
|
|
|
|
|
'Windows' => (string) WindowsSystemUtil::getCpuCount(),
|
|
|
|
|
'Darwin' => (string) MacOSSystemUtil::getCpuCount(),
|
|
|
|
|
'Linux' => (string) LinuxSystemUtil::getCpuCount(),
|
|
|
|
|
'BSD' => (string) BSDSystemUtil::getCpuCount(),
|
|
|
|
|
default => 1,
|
|
|
|
|
});
|
|
|
|
|
define('GNU_ARCH', arch2gnu(php_uname('m')));
|
|
|
|
|
define('MAC_ARCH', match ($_im8a = arch2gnu(php_uname('m'))) {
|
|
|
|
|
'aarch64' => 'arm64',
|
|
|
|
|
default => $_im8a
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// deprecated variables
|
|
|
|
|
define('SEPARATED_PATH', [
|
|
|
|
|
'/' . pathinfo(BUILD_LIB_PATH)['basename'], // lib
|
|
|
|
|
'/' . pathinfo(BUILD_INCLUDE_PATH)['basename'], // include
|
|
|
|
|
BUILD_ROOT_PATH,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// add these to env vars with same name
|
2025-08-01 10:58:31 +08:00
|
|
|
GlobalEnvManager::putenv('SPC_VERSION=' . SPC_VERSION);
|
2024-10-01 15:37:37 +08:00
|
|
|
GlobalEnvManager::putenv('BUILD_ROOT_PATH=' . BUILD_ROOT_PATH);
|
|
|
|
|
GlobalEnvManager::putenv('BUILD_INCLUDE_PATH=' . BUILD_INCLUDE_PATH);
|
|
|
|
|
GlobalEnvManager::putenv('BUILD_LIB_PATH=' . BUILD_LIB_PATH);
|
|
|
|
|
GlobalEnvManager::putenv('BUILD_BIN_PATH=' . BUILD_BIN_PATH);
|
|
|
|
|
GlobalEnvManager::putenv('PKG_ROOT_PATH=' . PKG_ROOT_PATH);
|
|
|
|
|
GlobalEnvManager::putenv('SOURCE_PATH=' . SOURCE_PATH);
|
|
|
|
|
GlobalEnvManager::putenv('DOWNLOAD_PATH=' . DOWNLOAD_PATH);
|
|
|
|
|
GlobalEnvManager::putenv('CPU_COUNT=' . CPU_COUNT);
|
2025-03-14 18:22:50 +08:00
|
|
|
GlobalEnvManager::putenv('SPC_ARCH=' . php_uname('m'));
|
2024-10-01 15:37:37 +08:00
|
|
|
GlobalEnvManager::putenv('GNU_ARCH=' . GNU_ARCH);
|
|
|
|
|
GlobalEnvManager::putenv('MAC_ARCH=' . MAC_ARCH);
|