getExecutableExtension(); } /** * 获取构建前的运行库检查告警 */ public function getBuildLibraryWarnings( string $phpDir, string $phpxDir, string $buildMode, bool $checkPhpxRuntime = true, ): array { if ($buildMode !== 'bin' && $buildMode !== 'lib') { return []; } $ext = ltrim($this->getSharedLibraryExtension(), '.'); $warnings = []; if (!is_file($phpDir . '/lib/libphp.' . $ext)) { $warnings[] = [ 'warning' => "The `libphp.{$ext}` is not found", 'info' => 'Run tpc.php in an interactive terminal to build it automatically, or set PHP_HOME', ]; } if (!is_file($phpxDir . '/lib/libphpx.' . $ext)) { $warnings[] = [ 'warning' => "The `libphpx.{$ext}` is not found", 'info' => 'Run tpc.php in an interactive terminal to build it automatically, or set PHPX_HOME', ]; } return $warnings; } /** * 当前平台是否适合使用 pcntl_fork 并行编译 */ public function supportsPcntlParallelCompile(): bool { return true; } public function getIntegerLiteralSuffix(): string { return 'LL'; } /** * 规范化路径 */ public function normalizePath(string $path): string { return str_replace('/', $this->getPathSeparator(), $path); } /** * 组合路径 */ public function joinPath(string ...$parts): string { return implode($this->getPathSeparator(), $parts); } public function removeCommonPrefix(string $short, string $long): string { $separator = $this->getPathSeparator(); if ($separator === '\\') { $short = str_replace('/', '\\', $short); $long = str_replace('/', '\\', $long); } $short = rtrim($short, $separator); $long = rtrim($long, $separator); $shortParts = explode($separator, $short); $longParts = explode($separator, $long); $prefixLen = 0; $len = min(count($shortParts), count($longParts)); for ($i = 0; $i < $len; $i++) { if ($shortParts[$i] === $longParts[$i]) { $prefixLen++; } else { break; } } return implode($separator, array_slice($longParts, $prefixLen)); } /** * 获取默认的 RPATH 路径列表(仅 macOS 需要) * * @param string|null $phpxDir phpx 目录路径 * @param string|null $phpDir PHP 目录路径 * @return array RPATH 路径数组 */ public function getDefaultRpaths(?string $phpxDir = null, ?string $phpDir = null): array { // 默认返回空数组,由子类重写 return []; } }