2023-03-15 20:40:49 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use ZM\Logger\ConsoleLogger;
|
|
|
|
|
|
|
|
|
|
define('WORKING_DIR', getcwd());
|
2023-12-24 14:43:47 +08:00
|
|
|
define('ROOT_DIR', dirname(__DIR__, 2));
|
2024-10-04 18:20:25 +08:00
|
|
|
putenv('WORKING_DIR=' . WORKING_DIR);
|
|
|
|
|
putenv('ROOT_DIR=' . ROOT_DIR);
|
2023-03-15 20:40:49 +08:00
|
|
|
|
2023-04-22 21:23:12 +08:00
|
|
|
// CLI start time
|
2023-03-15 20:40:49 +08:00
|
|
|
define('START_TIME', microtime(true));
|
|
|
|
|
|
2024-01-10 21:08:25 +08:00
|
|
|
// for windows, prevent calling Invoke-WebRequest and wsl command
|
|
|
|
|
const SPC_CURL_EXEC = PHP_OS_FAMILY === 'Windows' ? 'curl.exe' : 'curl';
|
|
|
|
|
const SPC_GIT_EXEC = PHP_OS_FAMILY === 'Windows' ? 'git.exe' : 'git';
|
|
|
|
|
|
2023-04-22 21:23:12 +08:00
|
|
|
// dangerous command
|
2023-03-15 20:40:49 +08:00
|
|
|
const DANGER_CMD = [
|
|
|
|
|
'rm',
|
|
|
|
|
'rmdir',
|
|
|
|
|
];
|
|
|
|
|
|
2024-06-09 13:38:50 +02:00
|
|
|
// spc internal extensions
|
|
|
|
|
const SPC_INTERNAL_EXTENSIONS = [
|
|
|
|
|
'core',
|
|
|
|
|
'hash',
|
|
|
|
|
'json',
|
2024-06-30 00:08:11 +08:00
|
|
|
'pcre',
|
2024-06-09 13:38:50 +02:00
|
|
|
'reflection',
|
|
|
|
|
'spl',
|
|
|
|
|
'standard',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// spc extension alias
|
|
|
|
|
const SPC_EXTENSION_ALIAS = [
|
|
|
|
|
'zend opcache' => 'opcache',
|
|
|
|
|
'zend-opcache' => 'opcache',
|
|
|
|
|
'zendopcache' => 'opcache',
|
|
|
|
|
];
|
|
|
|
|
|
2024-07-07 20:45:18 +08:00
|
|
|
// spc lock type
|
|
|
|
|
const SPC_LOCK_SOURCE = 1; // lock source
|
|
|
|
|
const SPC_LOCK_PRE_BUILT = 2; // lock pre-built
|
|
|
|
|
|
2023-04-22 21:23:12 +08:00
|
|
|
// file replace strategy
|
2023-03-15 20:40:49 +08:00
|
|
|
const REPLACE_FILE_STR = 1;
|
|
|
|
|
const REPLACE_FILE_PREG = 2;
|
|
|
|
|
const REPLACE_FILE_USER = 3;
|
|
|
|
|
|
2023-04-22 21:23:12 +08:00
|
|
|
// library build status
|
2024-07-07 20:45:18 +08:00
|
|
|
const LIB_STATUS_OK = 0;
|
|
|
|
|
const LIB_STATUS_ALREADY = 1;
|
|
|
|
|
const LIB_STATUS_BUILD_FAILED = 2;
|
|
|
|
|
const LIB_STATUS_INSTALL_FAILED = 3;
|
2023-03-18 17:32:21 +08:00
|
|
|
|
2023-04-22 21:23:12 +08:00
|
|
|
// build target type
|
2023-08-20 19:51:45 +08:00
|
|
|
const BUILD_TARGET_NONE = 0; // no target
|
|
|
|
|
const BUILD_TARGET_CLI = 1; // build cli
|
|
|
|
|
const BUILD_TARGET_MICRO = 2; // build micro
|
|
|
|
|
const BUILD_TARGET_FPM = 4; // build fpm
|
2023-08-21 09:30:46 +02:00
|
|
|
const BUILD_TARGET_EMBED = 8; // build embed
|
|
|
|
|
const BUILD_TARGET_ALL = 15; // build all
|
2023-04-22 21:23:12 +08:00
|
|
|
|
|
|
|
|
// doctor error fix policy
|
|
|
|
|
const FIX_POLICY_DIE = 1; // die directly
|
|
|
|
|
const FIX_POLICY_PROMPT = 2; // if it can be fixed, ask fix or not
|
|
|
|
|
const FIX_POLICY_AUTOFIX = 3; // if it can be fixed, just fix automatically
|
2023-03-26 22:27:51 +08:00
|
|
|
|
2023-04-29 18:59:47 +08:00
|
|
|
// pkgconf patch policy
|
|
|
|
|
const PKGCONF_PATCH_PREFIX = 1;
|
|
|
|
|
const PKGCONF_PATCH_EXEC_PREFIX = 2;
|
|
|
|
|
const PKGCONF_PATCH_LIBDIR = 4;
|
|
|
|
|
const PKGCONF_PATCH_INCLUDEDIR = 8;
|
2023-09-12 00:09:49 +08:00
|
|
|
const PKGCONF_PATCH_CUSTOM = 16;
|
|
|
|
|
const PKGCONF_PATCH_ALL = 31;
|
2023-04-29 18:59:47 +08:00
|
|
|
|
2023-09-23 14:08:35 +08:00
|
|
|
// autoconf flags
|
|
|
|
|
const AUTOCONF_LIBS = 1;
|
|
|
|
|
const AUTOCONF_CFLAGS = 2;
|
|
|
|
|
const AUTOCONF_CPPFLAGS = 4;
|
|
|
|
|
const AUTOCONF_LDFLAGS = 8;
|
|
|
|
|
const AUTOCONF_ALL = 15;
|
|
|
|
|
|
2023-03-15 20:40:49 +08:00
|
|
|
ConsoleLogger::$date_format = 'H:i:s';
|
2025-01-28 19:37:50 +08:00
|
|
|
ConsoleLogger::$format = '[%date%] [I] %body%';
|