PocketMine-MP 的自定义 PHP 构建脚本
正在寻找预构建的二进制文件?前往发布
编译.sh
Bash 脚本用于在 MacOS 和 Linux 平台上编译 PHP。确保您有make autoconf automake libtool m4 wget getconf gzip bzip2 bison g++ git cmake pkg-config re2c ca-certificates
。
建议
- 如果您打算仅在构建它的机器上使用编译后的二进制文件,请删除
-t
选项以获得最佳性能 - 这将允许脚本针对当前机器而不是通用机器进行优化。 - 除非提供
-g
标志,否则不包括ext-gd2
,因为 PocketMine-MP 不需要它。但是,如果您的插件需要它,请不要忘记使用-g
启用它。 - 如果您要重新编译多次(例如,为了改进脚本),
-c
和-l
选项可用于指定缓存文件夹以加快重新编译速度。
常见陷阱
- 避免在包含空格的目录树中使用脚本。有些库不喜欢尝试构建在包含空格的目录树中,例如
/home/user/my folder/pocketmine-mp/
可能会遇到问题。 - 避免目录树包含特殊(非英语)符号。例如,
Développement
可能会导致问题。
附加说明
Mac OSX(本机编译)
- 大多数依赖项可以使用 Homebrew 安装
- 您还需要
glibtool
(GNU libtool、xcode libtool 不起作用)
Android 64 位(交叉编译)
- Android 交叉编译仅支持 aarch64 目标。
- 需要
aarch64-linux-musl
工具链。您可以使用 https://github.com/pmmp/musl-cross-make 编译和安装它(PMMP 分支包括用于 DNS 解析器配置路径的 musl-libc 补丁并增加 LevelDB 的堆栈大小限制)
脚本标志 | 描述 |
---|
-c | 使用指定的文件夹来缓存下载的 tarball、zipball 等。 |
-d | 使用调试符号进行编译并禁用优化(缓慢,但对于调试段错误很有用) |
-D | 使用单独的调试符号进行编译,但启用优化(用于分布式二进制文件) |
-g | 将编译GD2 |
-j | 将创建线程设置为 # |
-l | 使用指定的文件夹来缓存编译工件(对于快速重建和测试很有用) |
-n | 编译完成后不要删除源 |
-s | 将静态编译所有内容 |
-t | 设定目标 |
-v | 在 PHP 中启用 Valgrind 支持 |
-x | 指定我们正在进行交叉编译 |
-P | 编译指定主要 PocketMine-MP 版本的扩展(可以是4 或5 ) |
例子:
目标 | 论点 |
---|
linux64 | -t linux64 -j4 -P5 |
linux64、PM4 | -t linux64 -j4 -P4 |
mac64 | -t mac-x86-64 -j4 -P5 |
android-aarch64 | -t android-aarch64 -x -j4 -P5 |
windows-compile-vs.bat
批处理脚本利用 Windows 上的 Visual Studio 从源代码编译 PHP 二进制文件。确保您的 PATH 中安装了 Visual Studio 2019、 git
、 7z
和wget
。
该脚本不接受参数,但以下环境变量会产生影响:
多变的 | 描述 |
---|
PHP_DEBUG_BUILD | 禁用优化并使用详细的调试信息构建 PHP(对于调试段错误很有用) |
SOURCES_PATH | 下载的源码放在哪里进行编译 |
VS_EDITION | 安装的 Visual Studio 版本,默认设置为Community |
PM_VERSION_MAJOR | 用于构建扩展的 PocketMine-MP 主要版本(默认为 4,可以是4 或5 ) |
对于开发人员:版本信息来源
图书馆
包装名称 | 版本信息网址 | 需要用于 | 笔记 |
---|
兹库 | https://github.com/madler/zlib/tags | 压缩 | |
良好生产规范 | https://gmplib.org/ | Bedrock 数据包加密的大整数数学 | 托管在 DependencyMirror 以避免服务中断 |
卷曲 | https://github.com/curl/curl/releases | 网络请求 | |
利比亚 | https://github.com/yaml/libyaml/releases | 解析 YAML 配置文件 | |
水平数据库 | https://github.com/pmmp/leveldb/commits/mojang-兼容/ | 基岩世界支持 | 基于 google/leveldb 的自定义版本,只需进行最少的更改即可支持 MCPE 世界 |
库文件 | https://gitlab.gnome.org/GNOME/libxml2/-/releases | UPnP 的 XML 解析支持 | 托管在 DependencyMirror 以避免服务中断 |
库文件 | https://sourceforge.net/projects/libpng/files/libpng16/ | php-gd,仅使用插件 | 托管在 DependencyMirror 以避免服务中断 |
库文件 | https://ijg.org/ | php-gd,仅使用插件 | 托管在 DependencyMirror 以避免服务中断 |
开放式SSL | https://github.com/openssl/openssl/releases | 基岩数据包加密,安全 Web 请求 | |
解压缩 | https://github.com/nih-at/libzip/releases | 资源包 | |
sqlite3 | https://sqlite.org/download.html | 仅限插件使用 | 托管在 DependencyMirror 以避免服务中断 |
解压缩 | https://github.com/ebiggers/libdeflate/blob/master/NEWS.md | 网络使用中 zlib 的更快替代方案 | |
pthreads4w | https://sourceforge.net/projects/pthreads4w/files/ | Windows 上的 ext-pmmpthread 需要 | 托管在 DependencyMirror 以避免服务中断 |
PHP 和扩展
包装名称 | 版本信息网址 | 需要用于 | 笔记 |
---|
PHP | https://www.php.net/releases/?json&version=8.2 | 一切 | 将 8.2 替换为您选择的版本 |
线程 | https://github.com/pmmp/ext-pmmpthread/releases | PHP 线程 | |
yaml | https://github.com/php/pecl-file_formats-yaml/tags | YAML配置解析 | 是的,- 和 _ 的混合是故意的。别问我。 |
水平数据库 | https://github.com/pmmp/php-leveldb/commits/pmmp-mojang-兼容/ | 基岩世界支持 | 自定义版本提供LEVELDB_ZLIB_RAW_COMPRESSION 支持 |
chunkutils2 | https://github.com/pmmp/ext-chunkutils2/releases | PalettedBlockArray 和其他低级内容 | |
调试 | https://github.com/xdebug/xdebug/releases | 调试 | 生产不需要 |
二进制 | https://github.com/igbinary/igbinary/releases | 更快的序列化,主要用于在线程之间移动内容 | 非必要,必要时可以放弃 |
加密货币 | https://github.com/bukka/php-crypto/tags | 基岩数据包加密 | |
递归卫士 | https://github.com/pmmp/ext-recursionguard/releases | 调试 | 生产不需要 |
解压缩 | https://github.com/pmmp/ext-libdeflate/releases | 更快的网络压缩 | 非必需但比 zlib 提供显着的性能优势 |
莫顿 | https://github.com/pmmp/ext-morton | 将 X/Z 和 X/Y/Z 坐标打包为适合 PHP 数组键的格式的整数 | 性能所需 |
xx哈希值 | https://github.com/pmmp/ext-xxhash/releases | 目前未使用 | 在最新版本的 PHP 中可以被hash() 取代,但这个扩展具有更好的性能 |
数组调试 | https://github.com/pmmp/ext-arraydebug/tags | 调试数组哈希冲突 | |
编码 | https://github.com/pmmp/ext-encoding/releases | 目前未使用 | 实验性的,旨在取代BinaryUtils 但从未完成 |
杂项
包装名称 | 版本信息网址 | 需要用于 | 笔记 |
---|
php-sdk-二进制工具 | https://github.com/php/php-sdk-binary-tools/releases | 在 Windows 上构建 PHP | |