From de670779240bc6ebc2dedd7847778bcd73f88479 Mon Sep 17 00:00:00 2001 From: larryTheCoder Date: Thu, 29 Jun 2023 02:27:45 +0800 Subject: [PATCH] Add our own flavour --- .github/workflows/main.yml | 100 ++++----- .gitignore | 3 + README.md | 1 + compile.sh | 437 ++++++++++++++++++++++++++++++++++++- windows-compile-vs.bat | 123 ++++++++++- 5 files changed, 597 insertions(+), 67 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 947a6817..29deb2e1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,7 +25,7 @@ jobs: - name: Install tools and dependencies run: | sudo apt-get update - sudo apt-get install make autoconf automake libtool libtool-bin m4 wget libc-bin gzip bzip2 bison g++ git re2c + sudo apt-get install make autoconf automake libtool libtool-bin m4 curl libc-bin gzip bzip2 bison g++ git re2c ca-certificates - name: Prepare compile.sh download cache id: download-cache @@ -40,12 +40,14 @@ jobs: # Used "set -ex" instead of hashbang since script isn't executed with hashbang set -ex trap "exit 1" ERR - ./compile.sh -t linux64 -j 4 -g -P ${{ matrix.pm-version-major }} -c ./download_cache -D + ./compile.sh -t linux64 -j 4 -g -F -P ${{ matrix.pm-version-major }} -c ./download_cache -D - name: Create tarball run: | - tar -czf ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin - tar -czf ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}-debugging-symbols.tar.gz bin-debug + tar -czf ./PHP-Linux-x86_64.tar.gz bin + tar -czf ./PHP-Linux-x86_64-debugging-symbols.tar.gz bin-debug + cp ./PHP-Linux-x86_64.tar.gz ./PHP_Linux-x86_64.tar.gz + zip -r ./Linux.zip ./PHP_Linux-x86_64.tar.gz - name: Upload artifacts uses: actions/upload-artifact@v4 @@ -53,7 +55,8 @@ jobs: with: name: Linux-PM${{ matrix.pm-version-major }} path: | - ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}*.tar.gz + ./Linux.zip + ./PHP-Linux-x86_64*.tar.gz install.log compile.sh if-no-files-found: error @@ -80,10 +83,10 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Install tools and dependencies run: brew install libtool autoconf automake pkg-config bison re2c - + - name: Prepare compile.sh download cache id: download-cache uses: actions/cache@v3 @@ -97,20 +100,20 @@ jobs: export PATH="/usr/local/opt/bison/bin:$PATH" set -ex trap "exit 1" ERR - ./compile.sh -t mac-x86-64 -j4 -g -P ${{ matrix.pm-version-major }} -c ./download_cache -D - + ./compile.sh -t mac-x86-64 -j4 -g -F -P ${{ matrix.pm-version-major }} -c ./download_cache -D + - name: Create tarball run: | - tar -czf ./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin - tar -czf ./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}-debugging-symbols.tar.gz bin-debug - + tar -czf ./PHP-MacOS-x86_64.tar.gz bin + tar -czf ./PHP-MacOS-x86_64-debugging-symbols.tar.gz bin-debug + - name: Upload artifacts uses: actions/upload-artifact@v4 if: always() with: name: MacOS-PM${{ matrix.pm-version-major }} path: | - ./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}*.tar.gz + ./PHP-MacOS-x86_64*.tar.gz install.log compile.sh if-no-files-found: error @@ -137,10 +140,10 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Install tools and dependencies run: choco install wget --no-progress - + - name: Compile PHP run: .\windows-compile-vs.bat env: @@ -151,8 +154,8 @@ jobs: - name: Rename artifacts run: | mkdir temp - move php-debug-pack-*.zip temp/PHP-Windows-x64-PM${{ matrix.pm-version-major }}-debugging-symbols.zip - move php-*.zip temp/PHP-Windows-x64-PM${{ matrix.pm-version-major }}.zip + move php-debug-pack-*.zip temp/PHP-Windows-x64-debugging-symbols.zip + move php-*.zip temp/PHP-Windows-x64.zip move temp\*.zip . - name: Upload artifacts @@ -174,71 +177,50 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Set version information id: version run: | echo PHP_VERSION=$(echo ${{ github.ref_name }} | cut -d / -f2) >> $GITHUB_OUTPUT - + - name: Update latest tag target run: | - git tag -f php-${{ steps.version.outputs.PHP_VERSION }}-latest - git push -f origin php-${{ steps.version.outputs.PHP_VERSION }}-latest + git tag -f ${{ steps.version.outputs.PHP_VERSION }} + git push -f origin ${{ steps.version.outputs.PHP_VERSION }} + git tag -f ${{ steps.version.outputs.PHP_VERSION }}-pm5 + git push -f origin ${{ steps.version.outputs.PHP_VERSION }}-pm5 - name: Download artifacts uses: actions/download-artifact@v4 with: path: ${{ github.workspace }} - - name: Generate release notes - run: | - echo "Last updated on **$(date -u +'%Y-%m-%d at %H:%M:%S %Z')**" > changelog.md - echo -e "\n\n" >> changelog.md - echo "Built by: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> changelog.md - if [[ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]]; then - echo -e "\n\n\n" >> changelog.md - if [[ "${{ github.ref_name }}" == *"preview" ]]; then - echo "# :warning: :radioactive: EXPERIMENTAL!!! :radioactive: :warning:" >> changelog.md - echo "### Your server and/or plugins may crash or misbehave with this release!" >> changelog.md - echo "### Consider downloading the [recommended release](${{ github.server_url }}/${{ github.repository }}/releases/latest) instead." >> changelog.md - else - echo ":warning: WARNING! :warning:" >> changelog.md - echo "Some plugins might not work properly on this version yet." >> changelog.md - echo "If you have problems, try the [recommended release](${{ github.server_url }}/${{ github.repository }}/releases/latest) instead." >> changelog.md - fi - else - echo ":white_check_mark: This version is recommended for production servers." >> changelog.md - fi - echo -e "\n\n\n" >> changelog.md - echo ":information_source: **Linux/MacOS users**: Please see [this page](https://doc.pmmp.io/en/rtfd/faq/installation/opcache.so.html) to fix extension loading errors. Also, check out the [PocketMine-MP Linux/MacOS installer](https://doc.pmmp.io/en/rtfd/installation/get-dot-pmmp-dot-io.html)." >> changelog.md - - name: Update latest branch release uses: ncipollo/release-action@v1.13.0 with: artifacts: | - ${{ github.workspace }}/Linux-PM*/*.tar.gz - ${{ github.workspace }}/MacOS-PM*/*.tar.gz - ${{ github.workspace }}/Windows-PM*/*.zip + ${{ github.workspace }}/Linux-PM4/Linux.zip + ${{ github.workspace }}/MacOS-PM4/PHP-*.tar.gz + ${{ github.workspace }}/Windows-PM4/PHP-*.zip makeLatest: ${{ github.ref_name == github.event.repository.default_branch }} - name: PHP ${{ steps.version.outputs.PHP_VERSION }} - Latest (Build ${{ github.run_number }}) - tag: php-${{ steps.version.outputs.PHP_VERSION }}-latest + name: PHP ${{ steps.version.outputs.PHP_VERSION }} for PM4 + tag: ${{ steps.version.outputs.PHP_VERSION }} commit: ${{ github.sha }} allowUpdates: true - bodyFile: ${{ github.workspace }}/changelog.md removeArtifacts: true prerelease: ${{ endsWith(github.ref_name, '-preview') }} - - name: Publish unique release + - name: Update latest branch release uses: ncipollo/release-action@v1.13.0 with: artifacts: | - ${{ github.workspace }}/Linux-PM*/*.tar.gz - ${{ github.workspace }}/MacOS-PM*/*.tar.gz - ${{ github.workspace }}/Windows-PM*/*.zip - makeLatest: false - name: PHP ${{ steps.version.outputs.PHP_VERSION }} (Build ${{ github.run_number }}) - tag: php-${{ steps.version.outputs.PHP_VERSION }}-build-${{ github.run_number }} + ${{ github.workspace }}/Linux-PM5/Linux.zip + ${{ github.workspace }}/MacOS-PM5/PHP-*.tar.gz + ${{ github.workspace }}/Windows-PM5/PHP-*.zip + makeLatest: ${{ github.ref_name == github.event.repository.default_branch }} + name: PHP ${{ steps.version.outputs.PHP_VERSION }} for PM5 + tag: ${{ steps.version.outputs.PHP_VERSION }}-pm5 commit: ${{ github.sha }} - bodyFile: ${{ github.workspace }}/changelog.md - prerelease: ${{ endsWith(github.ref_name, '-preview') }} - + allowUpdates: true + removeArtifacts: true + prerelease: ${{ endsWith(github.ref_name, '-preview') }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 224d8c03..7288e420 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ bin/ +bin-debug/ install_data/ +download_cache/ +test.dSYM/ install.log temp_data/ compile.log diff --git a/README.md b/README.md index efed0663..2140f816 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Bash script used to compile PHP on MacOS and Linux platforms. Make sure you have | -d | Compiles with debugging symbols and disables optimizations (slow, but useful for debugging segfaults) | | -D | Compiles with separated debugging symbols, but leaves optimizations enabled (used for distributed binaries) | | -g | Will compile GD2 | +| -F | Will compile FFI | | -j | Set make threads to # | | -l | Uses the folder specified for caching compilation artifacts (useful for rapid rebuild and testing) | | -n | Don't remove sources after completing compilation | diff --git a/compile.sh b/compile.sh index 3a415d49..9caa87ae 100755 --- a/compile.sh +++ b/compile.sh @@ -13,6 +13,11 @@ OPENSSL_VERSION="3.1.4" LIBZIP_VERSION="1.10.1" SQLITE3_VERSION="3440200" #3.44.2 LIBDEFLATE_VERSION="dd12ff2b36d603dbb7fa8838fe7e7176fcbd4f6f" #1.19 +LIBRDKAFKA_VER="2.1.1" +LIBZSTD_VER="1.5.5" +LIBGRPC_VER="1.58.1" +LIBFFI_VER="3.4.4" +SASL2_VERSION="2.1.28" EXT_PTHREADS_VERSION="4.2.2" EXT_PMMPTHREAD_VERSION="6.0.12" @@ -28,6 +33,11 @@ EXT_MORTON_VERSION="0.1.2" EXT_XXHASH_VERSION="0.2.0" EXT_ARRAYDEBUG_VERSION="0.2.0" EXT_ENCODING_VERSION="0.2.3" +EXT_RDKAFKA_VERSION="6.0.3" +EXT_ZSTD_VERSION="0.12.3" +EXT_GRPC_VERSION="1.57.3" +EXT_VANILLAGENERATOR_PM4_VERSION="56fc48ea1367e1d08b228dfa580b513fbec8ca31" +EXT_VANILLAGENERATOR_PM5_VERSION="abd059fd2ca79888aab3b9c5070d83ceea55fada" function write_out { echo "[$1] $2" @@ -145,6 +155,7 @@ FLAGS_LTO="" HAVE_OPCACHE_JIT="no" COMPILE_GD="no" +COMPILE_FFI="no" PM_VERSION_MAJOR="" @@ -152,7 +163,7 @@ DOWNLOAD_INSECURE="no" DOWNLOAD_CACHE="" SEPARATE_SYMBOLS="no" -while getopts "::t:j:sdDxfgnva:P:c:l:Ji" OPTION; do +while getopts "::t:j:sdDFxfgnva:P:c:l:Ji" OPTION; do case $OPTION in l) @@ -200,6 +211,10 @@ while getopts "::t:j:sdDxfgnva:P:c:l:Ji" OPTION; do f) write_out "deprecated" "The -f flag is deprecated, as optimizations are now enabled by default unless -d (debug mode) is specified" ;; + F) + write_out "opt" "Will enable FFI" + COMPILE_FFI="yes" + ;; g) write_out "opt" "Will enable GD2" COMPILE_GD="yes" @@ -278,6 +293,7 @@ function download_file { echo "Cache hit for URL: $url" >> "$DIR/install.log" else echo "Downloading file to cache: $url" >> "$DIR/install.log" + rm -f "$DOWNLOAD_CACHE/$prefix-"* >> "$DIR/install.log" 2>&1 _download_file "$1" > "$DOWNLOAD_CACHE/$cached_filename" 2>> "$DIR/install.log" fi cat "$DOWNLOAD_CACHE/$cached_filename" 2>> "$DIR/install.log" @@ -298,6 +314,39 @@ function download_github_src { download_file "https://github.com/$1/archive/$2.tar.gz" "$3" } +function git_download_file { + local url="$1" + local prefix="$2" + local git_branch="$3" + local git_path="$4" + local base_name=${git_path##*/} + local cached_filename="$prefix-$base_name.tar.gz" + + if [[ "$DOWNLOAD_CACHE" != "" ]]; then + if [[ ! -d "$DOWNLOAD_CACHE" ]]; then + mkdir "$DOWNLOAD_CACHE" >> "$DIR/install.log" 2>&1 + fi + if [[ -f "$DOWNLOAD_CACHE/$cached_filename" ]]; then + echo "Cache hit for git repository URL: $url" >> "$DIR/install.log" + tar xzf "$DOWNLOAD_CACHE/$cached_filename" $git_path >> "$DIR/install.log" 2>&1 + else + echo "Downloading git repository to cache: $url" >> "$DIR/install.log" + git clone -b "$git_branch" --depth=1 $url $git_path >> "$DIR/install.log" 2>&1 + pushd $git_path >> "$DIR/install.log" 2>&1 + git submodule update --depth=1 --init >> "$DIR/install.log" 2>&1 + popd >> "$DIR/install.log" 2>&1 + rm -f "$DOWNLOAD_CACHE/$prefix-"* >> "$DIR/install.log" 2>&1 + tar czf "$DOWNLOAD_CACHE/$cached_filename" $git_path >> "$DIR/install.log" 2>&1 + fi + else + echo "Downloading non-cached git repository: $url" >> "$DIR/install.log" + git clone -b "$git_branch" --depth=1 $url $git_path >> "$DIR/install.log" 2>&1 + pushd $git_path >> "$DIR/install.log" 2>&1 + git submodule update --depth=1 --init >> "$DIR/install.log" 2>&1 + popd >> "$DIR/install.log" 2>&1 + fi +} + GMP_ABI="" TOOLCHAIN_PREFIX="" OPENSSL_TARGET="" @@ -423,8 +472,10 @@ fi [ -z "$mtune" ] && mtune=native; [ -z "$CFLAGS" ] && CFLAGS=""; -if [ "$DO_STATIC" == "no" ]; then - [ -z "$LDFLAGS" ] && LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'"; +LDORIGIN_MODIFY="no" +if [ "$DO_STATIC" == "no" ] && [ -z "$LDFLAGS" ]; then + LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'"; + LDORIGIN_MODIFY="yes" fi [ -z "$CONFIGURE_FLAGS" ] && CONFIGURE_FLAGS=""; @@ -504,6 +555,232 @@ download_github_src "php/php-src" "php-$PHP_VERSION" "php" | tar -zx >> "$DIR/in mv php-src-php-$PHP_VERSION php write_done +function build_sasl2 { + write_library sasl2 "$SASL2_VERSION" + local sasl2_dir="./sasl2-$SASL2_VERSION" + + if cant_use_cache "$sasl2_dir"; then + rm -rf "$sasl2_dir" + write_download + download_file "https://github.com/cyrusimap/cyrus-sasl/archive/cyrus-sasl-$SASL2_VERSION.tar.gz" "sasl2" | tar -zx >> "$DIR/install.log" 2>&1 + mv cyrus-sasl-cyrus-sasl-$SASL2_VERSION "$sasl2_dir" + echo -n "checking... " + cd "$sasl2_dir" + if [ "$DO_STATIC" == "yes" ]; then + local EXTRA_FLAGS="--enable-shared=no --enable-static=yes" + else + local EXTRA_FLAGS="--enable-shared=yes --enable-static=no" + fi + NOCONFIGURE="no" ./autogen.sh >> "$DIR/install.log" 2>&1 + LDFLAGS="$LDFLAGS -L${INSTALL_DIR}/lib" CPPFLAGS="$CPPFLAGS -I${INSTALL_DIR}/include" RANLIB=$RANLIB ./configure \ + --prefix="$INSTALL_DIR" \ + --with-openssl="$INSTALL_DIR" \ + --libdir="$INSTALL_DIR/lib" \ + $EXTRA_FLAGS \ + $CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1 + + echo -n "compiling... " + make -j $THREADS >> "$DIR/install.log" 2>&1 && mark_cache + else + write_caching + cd "$sasl2_dir" + fi + write_install + if [ "$(uname -s)" == "Darwin" ]; then + make install-am >> "$DIR/install.log" 2>&1 + else + make install >> "$DIR/install.log" 2>&1 + fi + cd .. + write_done +} + +function build_zstd { + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$ORIGIN/../lib' -Wl,-rpath-link='\$ORIGIN/../lib'"; + fi + + write_library zstd "$LIBZSTD_VER" + local zstd_dir="./zstd-$LIBZSTD_VER" + + if cant_use_cache "$zstd_dir"; then + rm -rf "$zstd_dir" + write_download + download_file "https://github.com/facebook/zstd/archive/v$LIBZSTD_VER.tar.gz" "zstd" | tar -zx >> "$DIR/install.log" 2>&1 + echo -n " checking..." + pushd $zstd_dir/build/cmake >> "$DIR/install.log" 2>&1 + if [ "$DO_STATIC" != "yes" ]; then + local EXTRA_FLAGS="-DBUILD_SHARED_LIBS=ON" + else + local EXTRA_FLAGS="" + fi + cmake . \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ + -DCMAKE_PREFIX_PATH="$INSTALL_DIR" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_BUILD_TYPE=Release \ + $CMAKE_GLOBAL_EXTRA_FLAGS \ + $EXTRA_FLAGS \ + >> "$DIR/install.log" 2>&1 + write_compile + make -j $THREADS >> "$DIR/install.log" 2>&1 && mark_cache + else + write_caching + pushd "$zstd_dir" + fi + write_install + make install >> "$DIR/install.log" 2>&1 + popd >> "$DIR/install.log" 2>&1 + write_done + + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'"; + fi +} + +function build_libffi { + write_library libffi "$LIBFFI_VER" + local libffi_dir="./libffi-$LIBFFI_VER" + + if cant_use_cache "$libffi_dir"; then + rm -rf "$libffi_dir" + write_download + download_file "https://github.com/libffi/libffi/releases/download/v$LIBFFI_VER/libffi-$LIBFFI_VER.tar.gz" "libffi" | tar -zx >> "$DIR/install.log" 2>&1 + echo -n " checking..." + pushd $libffi_dir >> "$DIR/install.log" 2>&1 + if [ "$DO_STATIC" != "yes" ]; then + local EXTRA_FLAGS="--enable-shared --disable-static" + else + local EXTRA_FLAGS="--enable-shared --enable-static" + fi + ./configure \ + --prefix="$INSTALL_DIR" \ + --libdir="$INSTALL_DIR/lib" \ + $EXTRA_FLAGS \ + $CONFIGURE_FLAGS >> "$DIR/install.log" 2>&1 + write_compile + make -j $THREADS >> "$DIR/install.log" 2>&1 && mark_cache + else + write_caching + pushd "$libffi_dir" + fi + + write_install + make install_sw >> "$DIR/install.log" 2>&1 + cd .. + write_done +} + +function build_grpc { + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$ORIGIN/../lib' -Wl,-rpath-link='\$ORIGIN/../lib'"; + fi + + write_library libgrpc "$LIBGRPC_VER" + local grpc_dir="./grpc-$LIBGRPC_VER" + + if cant_use_cache "$grpc_dir"; then + rm -rf "$grpc_dir" + write_download + git_download_file "https://github.com/grpc/grpc.git" "grpc" "v$LIBGRPC_VER" $grpc_dir >> "$DIR/install.log" 2>&1 + echo -n " checking..." + pushd $grpc_dir >> "$DIR/install.log" 2>&1 + if [ "$DO_STATIC" != "yes" ]; then + local EXTRA_FLAGS="-DBUILD_SHARED_LIBS=ON" + else + local EXTRA_FLAGS="" + fi + mkdir -p cmake/build + pushd cmake/build >> "$DIR/install.log" 2>&1 + cmake ../.. \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ + -DCMAKE_PREFIX_PATH="$INSTALL_DIR" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_BUILD_TYPE=Release \ + -DgRPC_INSTALL=ON \ + -DgRPC_SSL_PROVIDER="package" \ + -DgRPC_ZLIB_PROVIDER="package" \ + -DgRPC_BUILD_CSHARP_EXT=OFF \ + -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF \ + -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF \ + $CMAKE_GLOBAL_EXTRA_FLAGS \ + $EXTRA_FLAGS \ + >> "$DIR/install.log" 2>&1 + write_compile + make -j $THREADS >> "$DIR/install.log" 2>&1 && mark_cache + else + write_caching + pushd "$grpc_dir/cmake/build" + fi + + write_install + make install >> "$DIR/install.log" 2>&1 + popd >> "$DIR/install.log" 2>&1 + popd >> "$DIR/install.log" 2>&1 + + echo -n " copying..." + cp -R $grpc_dir/third_party/protobuf/php/ext/google/protobuf $BUILD_DIR/php/ext/protobuf >> "$DIR/install.log" 2>&1 + cp -R $grpc_dir/third_party/protobuf/third_party $BUILD_DIR/php/ext/protobuf/third_party >> "$DIR/install.log" 2>&1 + + write_done + + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'"; + fi +} + +function build_kafka { + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$ORIGIN/../lib' -Wl,-rpath-link='\$ORIGIN/../lib'"; + fi + + write_library librdkafka "$LIBRDKAFKA_VER" + local librdkafka_dir="./librdkafka-$LIBRDKAFKA_VER" + + if cant_use_cache "$librdkafka_dir"; then + rm -rf "$librdkafka_dir" + write_download + download_file "https://github.com/confluentinc/librdkafka/archive/v$LIBRDKAFKA_VER.tar.gz" "librdkafka" | tar -zx >> "$DIR/install.log" 2>&1 + pushd "$librdkafka_dir" >> "$DIR/install.log" 2>&1 + echo -n " checking..." + + if [ "$DO_STATIC" != "yes" ]; then + local EXTRA_FLAGS="-DBUILD_SHARED_LIBS=ON" + else + local EXTRA_FLAGS="" + fi + + cmake . \ + -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ + -DCMAKE_PREFIX_PATH="$INSTALL_DIR" \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DWITH_ZSTD=ON \ + -DWITH_SSL=ON \ + -DWITH_CURL=OFF \ + -DENABLE_LZ4_EXT=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + $CMAKE_GLOBAL_EXTRA_FLAGS \ + $EXTRA_FLAGS \ + >> "$DIR/install.log" 2>&1 + + echo -n " compiling..." + make -j $THREADS >> "$DIR/install.log" 2>&1 && mark_cache + else + write_caching + pushd "$librdkafka_dir" >> "$DIR/install.log" 2>&1 + fi + write_install + make install >> "$DIR/install.log" 2>&1 + popd >> "$DIR/install.log" 2>&1 + write_done + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'"; + fi +} + function build_zlib { if [ "$DO_STATIC" == "yes" ]; then local EXTRA_FLAGS="--static" @@ -604,7 +881,6 @@ function build_openssl { --libdir="$INSTALL_DIR/lib" \ no-asm \ no-hw \ - no-engine \ $EXTRA_FLAGS >> "$DIR/install.log" 2>&1 write_compile @@ -716,6 +992,9 @@ function build_yaml { } function build_leveldb { + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$ORIGIN/../lib' -Wl,-rpath-link='\$ORIGIN/../lib'"; + fi write_library leveldb "$LEVELDB_VERSION" local leveldb_dir="./leveldb-$LEVELDB_VERSION" if cant_use_cache "$leveldb_dir"; then @@ -756,6 +1035,9 @@ function build_leveldb { make install >> "$DIR/install.log" 2>&1 cd .. write_done + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'"; + fi } function build_libpng { @@ -867,6 +1149,9 @@ function build_libxml2 { } function build_libzip { + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$ORIGIN/../lib' -Wl,-rpath-link='\$ORIGIN/../lib'"; + fi #libzip if [ "$DO_STATIC" == "yes" ]; then local CMAKE_LIBZIP_EXTRA_FLAGS="-DBUILD_SHARED_LIBS=OFF" @@ -908,6 +1193,9 @@ function build_libzip { make install >> "$DIR/install.log" 2>&1 cd .. write_done + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'"; + fi } function build_sqlite3 { @@ -946,6 +1234,9 @@ function build_sqlite3 { } function build_libdeflate { + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$ORIGIN/../lib' -Wl,-rpath-link='\$ORIGIN/../lib'"; + fi write_library libdeflate "$LIBDEFLATE_VERSION" local libdeflate_dir="./libdeflate-$LIBDEFLATE_VERSION" @@ -978,6 +1269,9 @@ function build_libdeflate { make install >> "$DIR/install.log" 2>&1 cd .. write_done + if [ "$LDORIGIN_MODIFY" != "no" ]; then + LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'"; + fi } cd "$LIB_BUILD_DIR" @@ -986,6 +1280,10 @@ build_zlib build_gmp build_openssl build_curl +build_sasl2 +build_zstd +build_kafka +build_grpc build_yaml build_leveldb if [ "$COMPILE_GD" == "yes" ]; then @@ -998,6 +1296,13 @@ else HAS_LIBJPEG="" fi +if [ "$COMPILE_FFI" == "yes" ]; then + build_libffi + HAS_FFI="--with-ffi" +else + HAS_FFI="" +fi + build_libxml2 build_libzip build_sqlite3 @@ -1071,6 +1376,108 @@ get_github_extension "arraydebug" "$EXT_ARRAYDEBUG_VERSION" "pmmp" "ext-arraydeb get_github_extension "encoding" "$EXT_ENCODING_VERSION" "pmmp" "ext-encoding" +get_github_extension "grpc" "$EXT_GRPC_VERSION" "larryTheCoder" "php-grpc" + +if [ "$PM_VERSION_MAJOR" -ge 5 ]; then + get_github_extension "vanillagenerator" "$EXT_VANILLAGENERATOR_PM5_VERSION" "NetherGamesMC" "ext-vanillagenerator" +else + get_github_extension "vanillagenerator" "$EXT_VANILLAGENERATOR_PM4_VERSION" "NetherGamesMC" "ext-vanillagenerator" +fi + +get_github_extension "rdkafka" "$EXT_RDKAFKA_VERSION" "arnaud-lb" "php-rdkafka" + +get_github_extension "zstd" "$EXT_ZSTD_VERSION" "kjdev" "php-ext-zstd" + +if [ "$(uname -s)" == "Darwin" ]; then + echo "[rdkafka] Implementing quick patch for MacOS support." + + rm $BUILD_DIR/php/ext/rdkafka/config.m4 2>&1 + + echo 'PHP_ARG_WITH(rdkafka, for rdkafka support,' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '[ --with-rdkafka Include rdkafka support])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo 'if test "$PHP_RDKAFKA" != "no"; then' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' SEARCH_PATH="/usr/local /usr" # you might want to change this' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' SEARCH_FOR="/include/librdkafka/rdkafka.h" # you most likely want to change this' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' if test -r $PHP_RDKAFKA/$SEARCH_FOR; then # path given as parameter' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' RDKAFKA_DIR=$PHP_RDKAFKA' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' else # search default path list' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_CHECKING([for librdkafka/rdkafka.h" in default path])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' for i in $SEARCH_PATH ; do' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' if test -r $i/$SEARCH_FOR; then' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' RDKAFKA_DIR=$i' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_RESULT(found in $i)' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' fi' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' done' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' fi' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' if test -z "$RDKAFKA_DIR"; then' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_RESULT([not found])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_ERROR([Please reinstall the rdkafka distribution])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' fi' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' PHP_ADD_INCLUDE($RDKAFKA_DIR/include)' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' SOURCES="rdkafka.c metadata.c metadata_broker.c metadata_topic.c metadata_partition.c metadata_collection.c conf.c topic.c queue.c message.c fun.c kafka_consumer.c topic_partition.c"' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' LIBNAME=rdkafka' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' LIBSYMBOL=rd_kafka_new' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' [' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $RDKAFKA_DIR/$PHP_LIBDIR, RDKAFKA_SHARED_LIBADD)' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_DEFINE(HAVE_RDKAFKALIB,1,[ ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_ERROR([wrong rdkafka lib version or lib not found])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' -L$RDKAFKA_DIR/$PHP_LIBDIR -lm' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ORIG_LDFLAGS="$LDFLAGS"' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ORIG_CPPFLAGS="$CPPFLAGS"' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' LDFLAGS="-L$RDKAFKA_DIR/$PHP_LIBDIR -lm"' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' CPPFLAGS="-I$RDKAFKA_DIR/include"' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_CHECKING([for librdkafka version])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_EGREP_CPP(yes,[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '#include ' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '#if RD_KAFKA_VERSION >= 0x000b0000' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' yes' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '#endif' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_RESULT([>= 0.11.0])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_ERROR([librdkafka version 0.11.0 or greater required.])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_CHECK_LIB($LIBNAME,[rd_kafka_message_headers],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_DEFINE(HAVE_RD_KAFKA_MESSAGE_HEADERS,1,[ ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_WARN([no rd_kafka_message_headers, headers support will not be available])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_CHECK_LIB($LIBNAME,[rd_kafka_purge],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_DEFINE(HAS_RD_KAFKA_PURGE,1,[ ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_WARN([purge is not available])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_CHECK_LIB($LIBNAME,[rd_kafka_msg_partitioner_murmur2],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_DEFINE(HAS_RD_KAFKA_PARTITIONER_MURMUR2,1,[ ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ],[' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' AC_MSG_WARN([murmur2 partitioner is not available])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' ])' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' LDFLAGS="$ORIG_LDFLAGS"' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' CPPFLAGS="$ORIG_CPPFLAGS"' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' PHP_SUBST(RDKAFKA_SHARED_LIBADD)' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo '' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo ' PHP_NEW_EXTENSION(rdkafka, $SOURCES, $ext_shared)' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 + echo 'fi' >> "$BUILD_DIR/php/ext/rdkafka/config.m4" 2>&1 +fi + write_library "PHP" "$PHP_VERSION" write_configure @@ -1152,6 +1559,8 @@ RANLIB=$RANLIB CFLAGS="$CFLAGS $FLAGS_LTO" CXXFLAGS="$CXXFLAGS $FLAGS_LTO" LDFLA --with-libdeflate \ $HAS_LIBJPEG \ $HAS_GD \ +$HAS_FFI \ +--with-rdkafka="$INSTALL_DIR" \ --with-leveldb="$INSTALL_DIR" \ --without-readline \ $HAS_DEBUG \ @@ -1176,6 +1585,7 @@ $THREAD_EXT_FLAGS \ --with-pdo-sqlite \ --with-pdo-mysql \ --with-pic \ +--with-libzstd \ --enable-phar \ --enable-ctype \ --enable-sockets \ @@ -1189,6 +1599,10 @@ $HAVE_MYSQLI \ --enable-bcmath \ --enable-cli \ --enable-ftp \ +--enable-grpc="$INSTALL_DIR" \ +--enable-protobuf \ +--enable-zstd \ +--enable-vanillagenerator \ --enable-opcache=$HAVE_OPCACHE \ --enable-opcache-jit=$HAVE_OPCACHE_JIT \ --enable-igbinary \ @@ -1266,6 +1680,7 @@ echo "error_reporting=-1" >> "$INSTALL_DIR/bin/php.ini" echo "display_errors=1" >> "$INSTALL_DIR/bin/php.ini" echo "display_startup_errors=1" >> "$INSTALL_DIR/bin/php.ini" echo "recursionguard.enabled=0 ;disabled due to minor performance impact, only enable this if you need it for debugging" >> "$INSTALL_DIR/bin/php.ini" +echo "extension_dir=./$INSTALL_DIR/lib/php/extensions/no-debug-zts-20220829" >> "$INSTALL_DIR/bin/php.ini" if [ "$HAVE_OPCACHE" == "yes" ]; then echo "zend_extension=opcache.so" >> "$INSTALL_DIR/bin/php.ini" @@ -1350,15 +1765,27 @@ if [ "$DO_CLEANUP" == "yes" ]; then rm -f "$INSTALL_DIR/bin/curl-config"* >> "$DIR/install.log" 2>&1 rm -f "$INSTALL_DIR/bin/c_rehash"* >> "$DIR/install.log" 2>&1 rm -f "$INSTALL_DIR/bin/openssl"* >> "$DIR/install.log" 2>&1 + rm -f "$INSTALL_DIR/bin/zstd"* >> "$DIR/install.log" 2>&1 + rm -f "$INSTALL_DIR/bin/grpc_cpp_plugin" >> "$DIR/install.log" 2>&1 rm -r -f "$INSTALL_DIR/man" >> "$DIR/install.log" 2>&1 rm -r -f "$INSTALL_DIR/share/man" >> "$DIR/install.log" 2>&1 rm -r -f "$INSTALL_DIR/php" >> "$DIR/install.log" 2>&1 rm -r -f "$INSTALL_DIR/misc" >> "$DIR/install.log" 2>&1 rm -r -f "$INSTALL_DIR/lib/"*.a >> "$DIR/install.log" 2>&1 rm -r -f "$INSTALL_DIR/lib/"*.la >> "$DIR/install.log" 2>&1 - rm -r -f "$INSTALL_DIR/include" >> "$DIR/install.log" 2>&1 + mv "$INSTALL_DIR/include" "$INSTALL_DIR/include_copy" >> "$DIR/install.log" 2>&1 + mkdir "$INSTALL_DIR/include" >> "$DIR/install.log" 2>&1 + mv "$INSTALL_DIR/include_copy/google" "$INSTALL_DIR/include/google" >> "$DIR/install.log" 2>&1 + mv "$INSTALL_DIR/include_copy/grpc" "$INSTALL_DIR/include/grpc" >> "$DIR/install.log" 2>&1 + mv "$INSTALL_DIR/include_copy/grpc++" "$INSTALL_DIR/include/grpc++" >> "$DIR/install.log" 2>&1 + mv "$INSTALL_DIR/include_copy/grpcpp" "$INSTALL_DIR/include/grpcpp" >> "$DIR/install.log" 2>&1 + rm -r -f "$INSTALL_DIR/include_copy" >> "$DIR/install.log" 2>&1 fi +echo "[INFO] Checking PHP build works..." +$INSTALL_DIR/bin/php --version >>"%log_file%" 2>&1 +$INSTALL_DIR/bin/php -m >>"%log_file%" 2>&1 + date >> "$DIR/install.log" 2>&1 write_out "PocketMine" "You should start the server now using \"./start.sh\"." write_out "PocketMine" "If it doesn't work, please send the \"install.log\" file to the Bug Tracker." diff --git a/windows-compile-vs.bat b/windows-compile-vs.bat index 78c754dc..eef6abbc 100644 --- a/windows-compile-vs.bat +++ b/windows-compile-vs.bat @@ -22,6 +22,9 @@ set LIBYAML_VER=0.2.5 set PTHREAD_W32_VER=3.0.0 set LEVELDB_MCPE_VER=1c7564468b41610da4f498430e795ca4de0931ff set LIBDEFLATE_VER=dd12ff2b36d603dbb7fa8838fe7e7176fcbd4f6f +set LIBRDKAFKA_VER=2.1.1 +set LIBZSTD_VER=1.5.5 +set LIBGRPC_VER=1.56.2 set PHP_PTHREADS_VER=4.2.2 set PHP_PMMPTHREAD_VER=6.0.12 @@ -37,6 +40,11 @@ set PHP_XXHASH_VER=0.2.0 set PHP_XDEBUG_VER=3.3.0 set PHP_ARRAYDEBUG_VER=0.2.0 set PHP_ENCODING_VER=0.2.3 +set PHP_VANILLAGENERATOR_PM4_VER=56fc48ea1367e1d08b228dfa580b513fbec8ca31 +set PHP_VANILLAGENERATOR_PM5_VER=2.1.7 +set PHP_LIBKAFKA_VER=6.0.3 +set PHP_ZSTD_VER=0.12.3 +SET PHP_GRPC_VER=1.57.3 set script_path=%~dp0 set log_file=%script_path%compile.log @@ -132,6 +140,99 @@ call bin\phpsdk_deps.bat -u -t %VC_VER% -b %PHP_MAJOR_VER% -a %ARCH% -f -d %DEPS call :pm-echo "Getting additional dependencies..." cd /D "%DEPS_DIR%" +call :pm-echo "Downloading grpc/grpc version %LIBGRPC_VER%..." +git clone -b v%LIBGRPC_VER% --depth=1 https://github.com/grpc/grpc >>"%log_file%" 2>&1 || exit 1 +cd /D grpc + +call :pm-echo "Updating submodules..." +git submodule update --depth=1 --init >>"%log_file%" 2>&1 || exit 1 + +call :pm-echo "Generating build configuration..." +cd cmake +md build +cd build +cmake -GNinja^ + -DCMAKE_PREFIX_PATH="%DEPS_DIR%"^ + -DCMAKE_INSTALL_PREFIX="%DEPS_DIR%"^ + -DCMAKE_BUILD_TYPE="%MSBUILD_CONFIGURATION%"^ + -DZLIB_LIBRARY="%DEPS_DIR%\lib\zlib_a.lib"^ + -DgRPC_BUILD_CSHARP_EXT=OFF^ + -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF^ + -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF^ + -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF^ + -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF^ + -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF^ + -DgRPC_SSL_PROVIDER="package"^ + -DgRPC_ZLIB_PROVIDER="package"^ + ..\.. >>"%log_file%" 2>&1 || exit 1 + +call :pm-echo "Compiling..." +cmake --build . >> "%log_file%" 2>&1 || exit 1 +call :pm-echo "Installing files..." +cmake -P cmake_install.cmake >> "%log_file%" 2>&1 || exit 1 +cd /D "%DEPS_DIR%" + +call :pm-echo "Moving php-gRPC extension source..." + +move grpc\third_party\protobuf\php\ext\google\protobuf ..\php-src\ext\protobuf >> "%log_file%" 2>&1 || exit 1 +move grpc\third_party\protobuf\third_party ..\php-src\ext\protobuf\third_party >> "%log_file%" 2>&1 || exit 1 +cd ..\php-src\ext\protobuf + +call :pm-echo "Generating files..." +echo|(set /p="ARG_ENABLE("protobuf", "Enable Protobuf extension", "yes");" & echo.) >> config.w32 +echo|(set /p="" & echo.) >> config.w32 +echo|(set /p="if (PHP_PROTOBUF != "no") {" & echo.) >> config.w32 +echo|(set /p=" EXTENSION("protobuf", "arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c", PHP_PROTOBUF_SHARED, "");" & echo.) >> config.w32 +echo|(set /p="" & echo.) >> config.w32 +echo|(set /p=" ADD_SOURCES(configure_module_dirname + "/third_party/utf8_range", "naive.c range2-neon.c range2-sse.c", "protobuf");" & echo.) >> config.w32 +echo|(set /p="" & echo.) >> config.w32 +echo|(set /p=" AC_DEFINE('HAVE_PROTOBUF', 1, '');" & echo.) >> config.w32 +echo|(set /p="}" & echo.) >> config.w32 + +cd /D "%DEPS_DIR%" + +call :pm-echo "Downloading zstd version %LIBZSTD_VER%..." +call :get-zip "https://github.com/facebook/zstd/archive/v%LIBZSTD_VER%.zip" || exit 1 +move zstd-%LIBZSTD_VER% zstd >> "%log_file%" 2>&1 +cd zstd/build/cmake +call :pm-echo "Generating build configuration..." +cmake -G "%CMAKE_TARGET%" -A "%ARCH%"^ + -DCMAKE_PREFIX_PATH="%DEPS_DIR%"^ + -DCMAKE_INSTALL_PREFIX="%DEPS_DIR%"^ + -DBUILD_SHARED_LIBS=ON^ + . >>"%log_file%" 2>&1 || exit 1 +call :pm-echo "Compiling..." +msbuild ALL_BUILD.vcxproj /p:Configuration=%MSBUILD_CONFIGURATION% /m >>"%log_file%" 2>&1 || exit 1 +call :pm-echo "Installing files..." +msbuild INSTALL.vcxproj /p:Configuration=%MSBUILD_CONFIGURATION% /m >>"%log_file%" 2>&1 || exit 1 +cd /D "%DEPS_DIR%" + +call :pm-echo "Downloading librdkafka version %LIBRDKAFKA_VER%..." +call :get-zip https://github.com/confluentinc/librdkafka/archive/v%LIBRDKAFKA_VER%.zip || exit 1 +move librdkafka-* librdkafka >>"%log_file%" 2>&1 +cd /D librdkafka + +call :pm-echo "Generating build configuration..." + +cmake -G "%CMAKE_TARGET%" -A "%ARCH%"^ + -DCMAKE_PREFIX_PATH="%DEPS_DIR%"^ + -DCMAKE_INSTALL_PREFIX="%DEPS_DIR%"^ + -DBUILD_SHARED_LIBS=ON^ + . >>"%log_file%" 2>&1 || exit 1 + +call :pm-echo "Compiling..." +msbuild ALL_BUILD.vcxproj /p:Configuration=%MSBUILD_CONFIGURATION% >>"%log_file%" 2>&1 || exit 1 +call :pm-echo "Installing files..." +msbuild INSTALL.vcxproj /p:Configuration=%MSBUILD_CONFIGURATION% /m >>"%log_file%" 2>&1 || exit 1 + +cd /D "%DEPS_DIR%" + +REM for no reason, php-rdkafka check for librdkafka and not rdkafka +REM move them to the appropriate location for php-rdkafka compatibility. +call :pm-echo "Moving libraries files for php-rdkafka compatibility..." +move "lib\rdkafka.lib" "lib\librdkafka.lib" >>"%log_file%" 2>&1 +move "lib\rdkafka++.lib" "lib\librdkafka++.lib" >>"%log_file%" 2>&1 + call :pm-echo "Downloading LibYAML version %LIBYAML_VER%..." call :get-zip https://github.com/yaml/libyaml/archive/%LIBYAML_VER%.zip || exit 1 move libyaml-%LIBYAML_VER% libyaml >>"%log_file%" 2>&1 @@ -221,10 +322,12 @@ cd /D php-src\ext set THREAD_EXT_FLAGS="" if "%PM_VERSION_MAJOR%" geq "5" ( - call :get-extension-zip-from-github "pmmpthread" "%PHP_PMMPTHREAD_VER%" "pmmp" "ext-pmmpthread" || exit 1 + call :get-extension-zip-from-github "pmmpthread" "%PHP_PMMPTHREAD_VER%" "pmmp" "ext-pmmpthread" || exit 1 + call :get-extension-zip-from-github "vanillagenerator" "%PHP_VANILLAGENERATOR_PM5_VER%" "NetherGamesMC" "ext-vanillagenerator" || exit 1 set THREAD_EXT_FLAGS="--with-pmmpthread=shared" ) else ( - call :get-extension-zip-from-github "pthreads" "%PHP_PTHREADS_VER%" "pmmp" "ext-pmmpthread" || exit 1 + call :get-extension-zip-from-github "pthreads" "%PHP_PTHREADS_VER%" "pmmp" "ext-pmmpthread" || exit 1 + call :get-extension-zip-from-github "vanillagenerator" "%PHP_VANILLAGENERATOR_PM4_VER%" "NetherGamesMC" "ext-vanillagenerator" || exit 1 set THREAD_EXT_FLAGS="--with-pthreads=shared" ) call :get-extension-zip-from-github "yaml" "%PHP_YAML_VER%" "php" "pecl-file_formats-yaml" || exit 1 @@ -238,6 +341,9 @@ call :get-extension-zip-from-github "xxhash" "%PHP_XXHASH_VER%" call :get-extension-zip-from-github "xdebug" "%PHP_XDEBUG_VER%" "xdebug" "xdebug" || exit 1 call :get-extension-zip-from-github "arraydebug" "%PHP_ARRAYDEBUG_VER%" "pmmp" "ext-arraydebug" || exit 1 call :get-extension-zip-from-github "encoding" "%PHP_ENCODING_VER%" "pmmp" "ext-encoding" || exit 1 +call :get-extension-zip-from-github "rdkafka" "%PHP_LIBKAFKA_VER%" "arnaud-lb" "php-rdkafka" || exit 1 +call :get-extension-zip-from-github "zstd" "%PHP_ZSTD_VER%" "kjdev" "php-ext-zstd" || exit 1 +call :get-extension-zip-from-github "grpc" "%PHP_GRPC_VER%" "larryTheCoder" "php-grpc" || exit 1 call :pm-echo " - crypto: downloading %PHP_CRYPTO_VER%..." git clone https://github.com/bukka/php-crypto.git crypto >>"%log_file%" 2>&1 || exit 1 @@ -282,6 +388,10 @@ call configure^ --enable-opcache^ --enable-opcache-jit=%PHP_JIT_ENABLE_ARG%^ --enable-phar^ + --enable-vanillagenerator=shared^ + --enable-zstd^ + --enable-grpc=shared^ + --enable-protobuf=shared^ --enable-recursionguard=shared^ --enable-sockets^ --enable-tokenizer^ @@ -312,6 +422,7 @@ call configure^ --with-xdebug-compression^ --with-xml^ --with-yaml^ + --with-rdkafka=shared^ --with-pdo-mysql^ --with-pdo-sqlite^ --without-readline >>"%log_file%" 2>&1 || call :pm-fatal-error "Error configuring PHP" @@ -332,7 +443,9 @@ rmdir /s /q "%SOURCES_PATH%\php-src\%ARCH%\Release_TS\php-%PHP_DISPLAY_VER%\lib\ call :pm-echo "Copying artifacts..." cd /D "%outpath%" -mkdir bin +mkdir bin bin\grpc +move "%DEPS_DIR%\grpc\cmake\build\grpc_php_plugin.exe" "bin\grpc\grpc_php_plugin.exe" +move "%DEPS_DIR%\grpc\cmake\build\third_party\protobuf\protoc.exe" "bin\grpc\protoc.exe" move "%SOURCES_PATH%\php-src\%ARCH%\%OUT_PATH_REL%_TS\php-%PHP_DISPLAY_VER%" bin\php cd /D bin\php @@ -369,6 +482,10 @@ if "%PM_VERSION_MAJOR%" geq "5" ( (echo ;Optional extensions, supplied for plugin use)>>"%php_ini%" (echo extension=php_fileinfo.dll)>>"%php_ini%" (echo extension=php_gd.dll)>>"%php_ini%" +(echo extension=php_grpc.dll)>>"%php_ini%" +(echo extension=php_protobuf.dll)>>"%php_ini%" +(echo extension=php_vanillagenerator.dll)>>"%php_ini%" +(echo extension=php_rdkafka.dll)>>"%php_ini%" (echo extension=php_mysqli.dll)>>"%php_ini%" (echo extension=php_sqlite3.dll)>>"%php_ini%" (echo ;Optional extensions, supplied for debugging)>>"%php_ini%"