TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

2.0 KiB

跨平台支持

TypePHP 目标 Windows / Linux / macOS 三大桌面平台,通过 Platform 抽象隔离系统差异(编译器名、目标扩展名、PHP embed 库查找等)。

Sources: src/Translator.php · src/Platform/

平台抽象

PlatformFactory::create() 按 OS 返回具体 Platform 对象(Windows / Linux / macOS)。detectPlatform()Translator 构造时调用,得到平台名 + 后端名(如 Windows + MSVC)。

Sources: src/Translator.php

各平台要点

平台 默认后端 链接产物 特殊点
Linux GCC/Clang ELF 可执行 / .so 推荐 Ubuntu 22.04,需 libphp.so
macOS Clang Mach-O / .dylib strip 可选
Windows MSVC PE .exe / .dll 需 Windows SDK + php8ts.lib;资源文件编译

Windows 分支会额外 detectPhpLibs() 探测 embed 与 core 的 .lib,并把 isZts、SDK 路径注入 Windows 对象。

Sources: src/Translator.php · README.md

Windows 资源文件

bin 模式在 Windows 下编译 .rc(图标、版本信息、UAC 等,由 project.ymlresource 配置),生成的 .resbuild() 链接时并入。资源文件生成见 Generator/ResourceFileGeneratorBuild/ResourceCompilationTrait

Sources: project.yml · src/Translator.php · src/Build/ResourceCompilationTrait.php

libphp.so 自动安装

Linux 缺 libphp.so 时,tpc.php 可交互式下载 PHP 源码并自动构建,详见 docs/LIBPHP_INSTALLER.md;安装器逻辑在 src/Installer/

Sources: README.md · src/Installer/

相关阅读

  • 后端命令如何生成 → 编译器后端
  • 链接与资源并入 → 构建流水线
  • 二进制打包(UPX/strip) → README 的 Release packaging 段