Skip to content

Repository files navigation

Custom PHP build scripts for PocketMine-MP

Build status

Looking for prebuilt binaries? Head over to releases

compile.sh

Bash script used to compile PHP on MacOS and Linux platforms. Make sure you have make autoconf automake libtool m4 wget getconf gzip bzip2 bison g++ git cmake pkg-config re2c ca-certificates.

Recommendations

  • If you're going to use the compiled binary only on the machine you're build it on, remove the -t option for best performance - this will allow the script to optimize for the current machine rather than a generic one.
  • ext-gd2 is NOT included unless the -g flag is provided, as PocketMine-MP doesn't need it. However, if your plugins need it, don't forget to enable it using -g.
  • The -c and -l options can be used to specify cache folders to speed up recompiling if you're recompiling many times (e.g. to improve the script).

Common pitfalls

  • Avoid using the script in directory trees containing spaces. Some libraries don't like trying to be built in directory trees containing spaces, e.g. /home/user/my folder/pocketmine-mp/ might experience problems.
  • Avoid directory trees containing special (non-English) symbols. For example, Développement might cause issues.

Additional notes

Mac OSX (native compile)

  • Most dependencies can be installed using Homebrew
  • You will additionally need glibtool (GNU libtool, xcode libtool won't work)

Android 64-bit (cross-compile)

  • Only aarch64 targets are supported for Android cross-compile.
  • The aarch64-linux-musl toolchain is required. You can compile and install it using https://github.com/pmmp/musl-cross-make (PMMP fork includes musl-libc patches for DNS resolver config path and increasing stack size limit for LevelDB)
Script flagsDescription
-cUses the folder specified for caching downloaded tarballs, zipballs etc.
-dCompiles with debugging symbols and disables optimizations (slow, but useful for debugging segfaults)
-DCompiles with separated debugging symbols, but leaves optimizations enabled (used for distributed binaries)
-gWill compile GD2
-jSet make threads to #
-lUses the folder specified for caching compilation artifacts (useful for rapid rebuild and testing)
-nDon't remove sources after completing compilation
-sWill compile everything statically
-tSet target
-vEnable Valgrind support in PHP
-xSpecifies we are doing cross-compile
-PCompiles extensions for the major PocketMine-MP version specified (can be 4 or 5)

Example:

TargetArguments
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

Batch script utilizing Visual Studio on Windows to compile PHP binaries from sources. Ensure you have Visual Studio 2019, git, 7z and wget installed in your PATH.

This script doesn't accept parameters, but the following environment variables are influential:

VariableDescription
PHP_DEBUG_BUILDDisables optimisations and builds PHP with detailed debugging information (useful for debugging segfaults)
SOURCES_PATHWhere to put the downloaded sources for compilation
VS_EDITIONEdition of Visual Studio installed, set to Community by default
PM_VERSION_MAJORMajor version of PocketMine-MP to build extensions for (defaults to 4, can be 4 or 5)

For developers: Version info sources

Libraries

Name of packageVersion info URLNeeded forNotes
zlibhttps://github.com/madler/zlib/tagsCompression
gmphttps://gmplib.org/Big integer math for Bedrock packet encryptionHosted at DependencyMirror to avoid service outages
curlhttps://github.com/curl/curl/releasesWeb requests
libyamlhttps://github.com/yaml/libyaml/releasesParsing YAML config files
leveldbhttps://github.com/pmmp/leveldb/commits/mojang-compatible/Bedrock world supportCustom version based on google/leveldb with minimum required changes to support MCPE worlds
libxmlhttps://gitlab.gnome.org/GNOME/libxml2/-/releasesXML parsing support for UPnPHosted at DependencyMirror to avoid service outages
libpnghttps://sourceforge.net/projects/libpng/files/libpng16/php-gd, plugin use onlyHosted at DependencyMirror to avoid service outages
libjpeghttps://ijg.org/php-gd, plugin use onlyHosted at DependencyMirror to avoid service outages
opensslhttps://github.com/openssl/openssl/releasesBedrock packet encryption, secure web requests
libziphttps://github.com/nih-at/libzip/releasesResource packs
sqlite3https://sqlite.org/download.htmlPlugin use onlyHosted at DependencyMirror to avoid service outages
libdeflatehttps://github.com/ebiggers/libdeflate/blob/master/NEWS.mdFaster alternative to zlib for network use
pthreads4whttps://sourceforge.net/projects/pthreads4w/files/Needed by ext-pmmpthread on WindowsHosted at DependencyMirror to avoid service outages

PHP & extensions

Name of packageVersion info URLNeeded forNotes
PHPhttps://www.php.net/releases/?json&version=8.2EverythingReplace 8.2 with your chosen version
pmmpthreadhttps://github.com/pmmp/ext-pmmpthread/releasesPHP threading
yamlhttps://github.com/php/pecl-file_formats-yaml/tagsYAML config parsingYes, the mix of - and _ is intentional. Don't ask me.
leveldbhttps://github.com/pmmp/php-leveldb/commits/pmmp-mojang-compatible/Bedrock world supportCustom version to provide LEVELDB_ZLIB_RAW_COMPRESSION support
chunkutils2https://github.com/pmmp/ext-chunkutils2/releasesPalettedBlockArray and other low-level stuff
xdebughttps://github.com/xdebug/xdebug/releasesDebuggingNot needed for production
igbinaryhttps://github.com/igbinary/igbinary/releasesFaster serialization, mostly for moving stuff between threadsNon-essential, could be ditched if necessary
cryptohttps://github.com/bukka/php-crypto/tagsBedrock packet encryption
recursionguardhttps://github.com/pmmp/ext-recursionguard/releasesDebuggingNot needed for production
libdeflatehttps://github.com/pmmp/ext-libdeflate/releasesFaster network compressionNon-essential but provides significant performance advantage over zlib
mortonhttps://github.com/pmmp/ext-mortonPacking X/Z and X/Y/Z coordinates into ints in a format suitable for PHP array keysNeeded for performance
xxhashhttps://github.com/pmmp/ext-xxhash/releasesNot currently usedCould be replaced by hash() in recent versions of PHP but this extension has much better performance
arraydebughttps://github.com/pmmp/ext-arraydebug/tagsDebugging array hash collisions
encodinghttps://github.com/pmmp/ext-encoding/releasesNot currently usedExperimental, intended to replace BinaryUtils but never finished

Misc

Name of packageVersion info URLNeeded forNotes
php-sdk-binary-toolshttps://github.com/php/php-sdk-binary-tools/releasesBuilding PHP on Windows

About

Compile scripts used to build PHP for PocketMine-MP on multiple platforms

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages