diff --git a/.github/workflows/main-pm-matrix.yml b/.github/workflows/main-pm-matrix.yml index f7363d26..745234f2 100644 --- a/.github/workflows/main-pm-matrix.yml +++ b/.github/workflows/main-pm-matrix.yml @@ -20,94 +20,7 @@ on: required: true type: boolean -env: - MUSL_CROSS_MAKE_VERSION: 7b9487e56efc83c419a397af7df7f119001dc51c - jobs: - android: - name: Android arm64 - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - - 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 - - - name: Prepare compile.sh download cache - id: download-cache - uses: actions/cache@v4 - with: - path: ./download_cache - key: compile-sh-cache-ssl-https-${{ hashFiles('./compile.sh') }} - restore-keys: compile-sh-cache-ssl-https- - - - name: Fetch compiler cache - id: compiler-cache - uses: actions/cache@v4 - with: - path: ${{ github.workspace }}/compiler - key: musl-cross-make-${{ env.MUSL_CROSS_MAKE_VERSION }} - restore-keys: musl-cross-make- - - - name: Checkout musl-cross-make - if: steps.compiler-cache.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - with: - repository: pmmp/musl-cross-make - path: musl-cross-make - ref: ${{ env.MUSL_CROSS_MAKE_VERSION }} - - - name: Build compiler - if: steps.compiler-cache.outputs.cache-hit != 'true' - working-directory: musl-cross-make - run: | - echo "TARGET = aarch64-linux-musl" > config.mak - make -j$(nproc) - make install - mv ./output "${{ github.workspace }}/compiler" - - - name: Compile PHP - run: | - export PATH="${{ github.workspace }}/compiler/bin:$PATH" - - # Used "set -ex" instead of hashbang since script isn't executed with hashbang - set -ex - trap "exit 1" ERR - ./compile.sh -t android-aarch64 -x -j 4 -g -P ${{ inputs.pm-version-major }} -c ./download_cache -D -z ${{ inputs.php-version-base }} - - - - name: Create tarball - run: | - tar -czf ./PHP-${{ inputs.php-version-base }}-Android-arm64-PM${{ inputs.pm-version-major }}.tar.gz bin - tar -czf ./Z-PHP-${{ inputs.php-version-base }}-Android-arm64-PM${{ inputs.pm-version-major }}-debugging-symbols.tar.gz bin-debug - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - if: always() - with: - name: PHP-${{ inputs.php-version-base }}-Android-PM${{ inputs.pm-version-major }} - path: | - ./*PHP-${{ inputs.php-version-base }}-Android-arm64-PM${{ inputs.pm-version-major }}*.tar.gz - install.log - compile.sh - if-no-files-found: error - - - name: Prepare workspace for upload - if: failure() - run: tar -czf workspace.tar.gz install_data - - - name: Upload workspace - uses: actions/upload-artifact@v4 - if: failure() - with: - name: PHP-${{ inputs.php-version-base }}-Android-workspace-PM${{ inputs.pm-version-major }} - path: | - workspace.tar.gz - if-no-files-found: error - linux: name: Linux runs-on: ubuntu-20.04 @@ -133,7 +46,7 @@ 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 ${{ inputs.pm-version-major }} -c ./download_cache -D -z ${{ inputs.php-version-base }} + ./compile.sh -t linux64 -j 4 -g -F -P ${{ inputs.pm-version-major }} -c ./download_cache -D -z ${{ inputs.php-version-base }} - name: Create tarball run: | @@ -273,7 +186,7 @@ jobs: publish: name: Publish binaries - needs: [linux, macos, windows, android] + needs: [linux, macos, windows] runs-on: ubuntu-20.04 if: ${{ github.ref_name == 'stable' && github.ref_type == 'branch' && !contains(github.event.head_commit.message, '[no release]') }} concurrency: release-${{ inputs.php-version-base }}-pm${{ inputs.pm-version-major }} @@ -331,7 +244,7 @@ jobs: echo DATE=$(date -u +'%d %b %Y') >> $GITHUB_OUTPUT - name: Update recommended PM release - uses: ncipollo/release-action@v1.14.0 + uses: ncipollo/release-action@v1.16.0 if: ${{ inputs.special-release != 'none' }} with: artifacts: | @@ -348,7 +261,7 @@ jobs: prerelease: ${{ inputs.pm-preview == 'true' }} - name: Update php-version PM release - uses: ncipollo/release-action@v1.14.0 + uses: ncipollo/release-action@v1.16.0 with: artifacts: | ${{ github.workspace }}/*PHP-*-PM*/*.tar.gz diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c1a7378..78823ead 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,11 +17,9 @@ jobs: strategy: matrix: include: - - pm-version-major: 5 - php-version-base: "8.2" - special-release: default-latest #default = best for PM5, latest = display as latest on GitHub - pm-version-major: 5 php-version-base: "8.3" + special-release: default-latest #default = best for PM5, latest = display as latest on GitHub uses: ./.github/workflows/main-pm-matrix.yml with: @@ -53,7 +51,7 @@ jobs: echo -e "\n\n\n" >> changelog.md - name: Create release - uses: ncipollo/release-action@v1.14.0 + uses: ncipollo/release-action@v1.16.0 with: artifacts: | ${{ github.workspace }}/*PHP-*-PM*/*.tar.gz diff --git a/README.md b/README.md index c3a2fbf0..874b08c1 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,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 b45dc73d..67b5ddaf 100755 --- a/compile.sh +++ b/compile.sh @@ -4,7 +4,6 @@ PHP_VERSIONS=("8.2.27" "8.3.15") #### NOTE: Tags with "v" prefixes behave weirdly in the GitHub API. They'll be stripped in some places but not others. #### Use commit hashes to avoid this. - ZLIB_VERSION="1.3.1" GMP_VERSION="6.3.0" CURL_VERSION="curl-8_9_1" @@ -17,6 +16,11 @@ OPENSSL_VERSION="3.4.0" LIBZIP_VERSION="1.10.1" SQLITE3_VERSION="3450200" #3.45.2 LIBDEFLATE_VERSION="78051988f96dc8d8916310d8b24021f01bd9e102" #1.23 - see above note about "v" prefixes +LIBRDKAFKA_VER="2.1.1" +LIBZSTD_VER="1.5.6" +LIBGRPC_VER="1.58.1" +LIBSNAPPY_VER="1.2.1" +SASL2_VERSION="2.1.28" EXT_PMMPTHREAD_VERSION="6.1.0" EXT_YAML_VERSION="2.2.4" @@ -25,12 +29,17 @@ EXT_CHUNKUTILS2_VERSION="0.3.5" EXT_XDEBUG_VERSION="3.3.2" EXT_IGBINARY_VERSION="3.2.16" EXT_CRYPTO_VERSION="abbe7cbf869f96e69f2ce897271a61d32f43c7c0" #release not tagged +EXT_SNAPPY_VERSION="ab8b2b7375641f47deb21d8e8ba1a00ea5364cf6" EXT_RECURSIONGUARD_VERSION="0.1.0" EXT_LIBDEFLATE_VERSION="0.2.1" EXT_MORTON_VERSION="0.1.2" EXT_XXHASH_VERSION="0.2.0" EXT_ARRAYDEBUG_VERSION="0.2.0" EXT_ENCODING_VERSION="0.4.0" +EXT_RDKAFKA_VERSION="6.0.3" +EXT_ZSTD_VERSION="0.14.0" +EXT_GRPC_VERSION="1.57.3" +EXT_VANILLAGENERATOR_VERSION="abd059fd2ca79888aab3b9c5070d83ceea55fada" function write_out { echo "[$1] $2" @@ -149,6 +158,7 @@ FLAGS_LTO="" HAVE_OPCACHE_JIT="no" COMPILE_GD="no" +COMPILE_FFI="no" PM_VERSION_MAJOR="" @@ -158,7 +168,7 @@ SEPARATE_SYMBOLS="no" PHP_VERSION_BASE="auto" -while getopts "::t:j:sdDxfgnva:P:c:l:Jiz:" OPTION; do +while getopts "::t:j:sdDFxfgnva:P:c:l:Jiz:" OPTION; do case $OPTION in l) @@ -206,6 +216,10 @@ while getopts "::t:j:sdDxfgnva:P:c:l:Jiz:" 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" @@ -354,6 +368,38 @@ 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 + 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="" @@ -480,8 +526,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=""; @@ -561,6 +609,239 @@ 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_snappy { + write_library snappy "$LIBSNAPPY_VER" + local snappy_dir="./snappy-$LIBSNAPPY_VER" + + if cant_use_cache "$snappy_dir"; then + rm -rf "$snappy_dir" + write_download + git_download_file "https://github.com/google/snappy.git" "snappy" "$LIBSNAPPY_VER" $snappy_dir >> "$DIR/install.log" 2>&1 + echo -n " checking..." + pushd $snappy_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 \ + $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 + + 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_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" @@ -661,7 +942,6 @@ function build_openssl { --libdir="$INSTALL_DIR/lib" \ no-asm \ no-hw \ - no-engine \ $EXTRA_FLAGS >> "$DIR/install.log" 2>&1 write_compile @@ -773,6 +1053,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 @@ -813,6 +1096,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 { @@ -924,6 +1210,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" @@ -965,6 +1254,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 { @@ -1003,6 +1295,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" @@ -1035,14 +1330,22 @@ 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" +build_snappy 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 @@ -1055,6 +1358,12 @@ else HAS_LIBJPEG="" fi +if [ "$COMPILE_FFI" == "yes" ]; then + HAS_FFI="--with-ffi" +else + HAS_FFI="" +fi + build_libxml2 build_libzip build_sqlite3 @@ -1109,6 +1418,8 @@ git submodule update --init --recursive >> "$DIR/install.log" 2>&1 cd "$BUILD_DIR" write_done +get_github_extension "snappy" "$EXT_SNAPPY_VERSION" "kjdev" "php-ext-snappy" + get_github_extension "leveldb" "$EXT_LEVELDB_VERSION" "pmmp" "php-leveldb" get_github_extension "chunkutils2" "$EXT_CHUNKUTILS2_VERSION" "pmmp" "ext-chunkutils2" @@ -1123,6 +1434,104 @@ 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" + +get_github_extension "vanillagenerator" "$EXT_VANILLAGENERATOR_VERSION" "NetherGamesMC" "ext-vanillagenerator" + +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 @@ -1204,7 +1613,10 @@ 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" \ +--with-snappy-includedir="$INSTALL_DIR" \ --without-readline \ $HAS_DEBUG \ --enable-chunkutils2 \ @@ -1228,6 +1640,7 @@ $HAS_DEBUG \ --with-pdo-sqlite \ --with-pdo-mysql \ --with-pic \ +--with-libzstd \ --enable-phar \ --enable-ctype \ --enable-sockets \ @@ -1241,6 +1654,11 @@ $HAVE_MYSQLI \ --enable-bcmath \ --enable-cli \ --enable-ftp \ +--enable-grpc="$INSTALL_DIR" \ +--enable-protobuf \ +--enable-zstd \ +--enable-snappy \ +--enable-vanillagenerator \ --enable-opcache=$HAVE_OPCACHE \ --enable-opcache-jit=$HAVE_OPCACHE_JIT \ --enable-igbinary \ @@ -1318,6 +1736,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-20230831" >> "$INSTALL_DIR/bin/php.ini" if [ "$HAVE_OPCACHE" == "yes" ]; then echo "zend_extension=opcache.so" >> "$INSTALL_DIR/bin/php.ini" @@ -1402,13 +1821,21 @@ 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 date >> "$DIR/install.log" 2>&1 diff --git a/windows-compile-vs.ps1 b/windows-compile-vs.ps1 index 2288e0ee..63add2bc 100644 --- a/windows-compile-vs.ps1 +++ b/windows-compile-vs.ps1 @@ -13,6 +13,10 @@ $LIBYAML_VER="0.2.5" $PTHREAD_W32_VER="3.0.0" $LEVELDB_MCPE_VER="1c7564468b41610da4f498430e795ca4de0931ff" #release not tagged $LIBDEFLATE_VER="78051988f96dc8d8916310d8b24021f01bd9e102" #1.23 - see above note about "v" prefixes +$LIBRDKAFKA_VER="2.1.1" +$LIBZSTD_VER="1.5.6" +$LIBGRPC_VER="1.56.2" +$LIBSNAPPY_VER="1.2.1" $PHP_PMMPTHREAD_VER="6.1.0" $PHP_YAML_VER="2.2.4" @@ -20,6 +24,7 @@ $PHP_CHUNKUTILS2_VER="0.3.5" $PHP_IGBINARY_VER="3.2.16" $PHP_LEVELDB_VER="317fdcd8415e1566fc2835ce2bdb8e19b890f9f3" #release not tagged $PHP_CRYPTO_VER="abbe7cbf869f96e69f2ce897271a61d32f43c7c0" #release not tagged +$PHP_SNAPPY_VER="ab8b2b7375641f47deb21d8e8ba1a00ea5364cf6" $PHP_RECURSIONGUARD_VER="0.1.0" $PHP_MORTON_VER="0.1.2" $PHP_LIBDEFLATE_VER="0.2.1" @@ -27,6 +32,10 @@ $PHP_XXHASH_VER="0.2.0" $PHP_XDEBUG_VER="3.3.2" $PHP_ARRAYDEBUG_VER="0.2.0" $PHP_ENCODING_VER="0.4.0" +$PHP_VANILLAGENERATOR_VER="2.1.7" +$PHP_LIBKAFKA_VER="6.0.3" +$PHP_ZSTD_VER="0.13.0" +$PHP_GRPC_VER="1.57.3" function pm-echo { param ([string] $message) @@ -294,6 +303,134 @@ function download-php-deps { write-done } +function build-snappy { + write-library "snappy" $LIBSNAPPY_VER + write-download + (& cmd.exe /c "git clone -b $LIBSNAPPY_VER https://github.com/google/snappy snappy 2>&1") >> $log_file + Push-Location snappy + + (& cmd.exe /c "git submodule update --depth=1 --init 2>&1") >> $log_file + + write-configure + sdk-command "cmake -GNinja^` + -DCMAKE_PREFIX_PATH=`"$DEPS_DIR`"^` + -DCMAKE_INSTALL_PREFIX=`"$DEPS_DIR`"^` + -DCMAKE_BUILD_TYPE=`"$MSBUILD_CONFIGURATION`"^` + . || exit 1" + + write-compile + sdk-command "cmake --build . || exit 1" + write-install + sdk-command "cmake -P cmake_install.cmake || exit 1" + write-done + Pop-Location +} + +function build-grpc { + write-library "grpc" $LIBGRPC_VER + write-download + (& cmd.exe /c "git clone -b v$LIBGRPC_VER --depth=1 https://github.com/grpc/grpc grpc 2>&1") >> $log_file + Push-Location grpc + + (& cmd.exe /c "git submodule update --depth=1 --init 2>&1") >> $log_file + + write-configure + sdk-command "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`"^` + . || exit 1" + + write-compile + sdk-command "cmake --build . || exit 1" + write-install + sdk-command "cmake -P cmake_install.cmake || exit 1" + + Move-Item "third_party\protobuf\php\ext\google\protobuf" "$SOURCES_PATH\php-src\ext\protobuf" >> $log_file 2>&1 + Move-Item "third_party\protobuf\third_party" "$SOURCES_PATH\php-src\ext\protobuf\third_party" >> $log_file 2>&1 + +@" +ARG_ENABLE("protobuf", "Enable Protobuf extension", "yes"); + +if (PHP_PROTOBUF != "no") { + EXTENSION("protobuf", "arena.c array.c convert.c def.c map.c message.c names.c php-upb.c protobuf.c", PHP_PROTOBUF_SHARED, ""); + + ADD_SOURCES(configure_module_dirname + "/third_party/utf8_range", "naive.c range2-neon.c range2-sse.c", "protobuf"); + + AC_DEFINE('HAVE_PROTOBUF', 1, ''); +} +"@ | Out-File -Encoding ascii -FilePath $SOURCES_PATH\php-src\ext\protobuf\config.w32 + + write-done + Pop-Location +} + +function build-zstd { + write-library "zstd" $LIBZSTD_VER + write-download + $file = download-file "https://github.com/facebook/zstd/archive/v$LIBZSTD_VER.zip" "zstd" + write-extracting + unzip-file $file $pwd + Move-Item "zstd-$LIBZSTD_VER" libzstd >> $log_file 2>&1 + Push-Location libzstd + + write-configure + sdk-command "cmake -G `"$CMAKE_TARGET`" -A `"$ARCH`"^` + -DCMAKE_PREFIX_PATH=`"$DEPS_DIR`"^` + -DCMAKE_INSTALL_PREFIX=`"$DEPS_DIR`"^` + -DBUILD_SHARED_LIBS=ON^` + `"$pwd\build\cmake`" || exit 1" + write-compile + sdk-command "msbuild ALL_BUILD.vcxproj /p:Configuration=$MSBUILD_CONFIGURATION /m || exit 1" + write-install + sdk-command "msbuild INSTALL.vcxproj /p:Configuration=$MSBUILD_CONFIGURATION /m || exit 1" + write-done + Pop-Location +} + +function build_rdkafka { + write-library "librdkafka" $LIBRDKAFKA_VER + write-download + $file = download-file "https://github.com/confluentinc/librdkafka/archive/v$LIBRDKAFKA_VER.zip" "librdkafka" + write-extracting + unzip-file $file $pwd + Move-Item "librdkafka-$LIBRDKAFKA_VER" librdkafka >> $log_file 2>&1 + Push-Location librdkafka + + write-configure + sdk-command "cmake -G `"$CMAKE_TARGET`" -A `"$ARCH`"^` + -DCMAKE_PREFIX_PATH=`"$DEPS_DIR`"^` + -DCMAKE_INSTALL_PREFIX=`"$DEPS_DIR`"^` + -DBUILD_SHARED_LIBS=ON^` + -DWITH_ZSTD=ON^` + -DWITH_SSL=ON^` + -DWITH_CURL=OFF^` + -DENABLE_LZ4_EXT=OFF^` + `"$pwd`" || exit 1" + + write-compile + sdk-command "msbuild ALL_BUILD.vcxproj /p:Configuration=$MSBUILD_CONFIGURATION /m || exit 1" + write-install + sdk-command "msbuild INSTALL.vcxproj /p:Configuration=$MSBUILD_CONFIGURATION /m || exit 1" + + # for no reason, php-rdkafka check for librdkafka and not rdkafka + # move them to the appropriate location for php-rdkafka compatibility. + Move-Item "$DEPS_DIR\lib\rdkafka.lib" "$DEPS_DIR\lib\librdkafka.lib" >> $log_file 2>&1 + Move-Item "$DEPS_DIR\lib\rdkafka++.lib" "$DEPS_DIR\lib\librdkafka++.lib" >> $log_file 2>&1 + + write-done + Pop-Location +} + function build-yaml { write-library "yaml" $LIBYAML_VER write-download @@ -427,6 +564,7 @@ function get-github-extension { function download-php-extensions { Push-Location "$SOURCES_PATH\php-src\ext" >> $log_file 2>&1 get-github-extension "pmmpthread" $PHP_PMMPTHREAD_VER "pmmp" "ext-pmmpthread" + get-github-extension "vanillagenerator" $PHP_VANILLAGENERATOR_VER "NetherGamesMC" "ext-vanillagenerator" get-github-extension "yaml" $PHP_YAML_VER "php" "pecl-file_formats-yaml" get-github-extension "chunkutils2" $PHP_CHUNKUTILS2_VER "pmmp" "ext-chunkutils2" get-github-extension "igbinary" $PHP_IGBINARY_VER "igbinary" "igbinary" @@ -438,6 +576,14 @@ function download-php-extensions { get-github-extension "xdebug" $PHP_XDEBUG_VER "xdebug" "xdebug" get-github-extension "arraydebug" $PHP_ARRAYDEBUG_VER "pmmp" "ext-arraydebug" get-github-extension "encoding" $PHP_ENCODING_VER "pmmp" "ext-encoding" + get-github-extension "rdkafka" $PHP_LIBKAFKA_VER "arnaud-lb" "php-rdkafka" + get-github-extension "zstd" $PHP_ZSTD_VER "kjdev" "php-ext-zstd" + get-github-extension "grpc" $PHP_GRPC_VER "larryTheCoder" "php-grpc" + + # Vanilla generator depend on this folder, the compiler will not be able + # to find these dependencies if the folder name were to change + Move-Item "ext-chunkutils2-$PHP_CHUNKUTILS2_VER" "chunkutils2" -Force + Move-Item "ext-morton-$PHP_MORTON_VER" "morton" -Force write-library "php-ext crypto" $PHP_CRYPTO_VER write-download @@ -449,6 +595,19 @@ function download-php-extensions { write-done Pop-Location + write-library "php-ext snappy" $PHP_SNAPPY_VER + write-download + (& cmd.exe /c "git clone https://github.com/kjdev/php-ext-snappy.git snappy 2>&1") >> $log_file + Push-Location snappy + write-status "preparing" + (& cmd.exe /c "git checkout $PHP_SNAPPY_VER 2>&1") >> $log_file + (& cmd.exe /c "git submodule update --init --recursive 2>&1") >> $log_file + Push-Location snappy + (& cmd.exe /c "git checkout $LIBSNAPPY_VER 2>&1") >> $log_file + Pop-Location + write-done + Pop-Location + Pop-Location } @@ -463,6 +622,7 @@ $DEPS_DIR="$SOURCES_PATH\deps" #custom libs depend on some standard libs, so prepare these first #a bit annoying because this part of the build is slow and makes it take longer to find problems download-php-deps +download-php $LIB_BUILD_DIR="$SOURCES_PATH\deps_build" @@ -470,6 +630,10 @@ mkdir $LIB_BUILD_DIR >> $log_file 2>&1 cd $LIB_BUILD_DIR >> $log_file 2>&1 +build-snappy +build-grpc +build-zstd +build_rdkafka build-pthreads4w build-yaml #these two both need zlib from the standard deps @@ -478,7 +642,6 @@ build-libdeflate cd $SOURCES_PATH >> $log_file 2>&1 -download-php download-php-extensions cd "$SOURCES_PATH\php-src" @@ -512,6 +675,11 @@ sdk-command "configure^` --enable-opcache^` --enable-opcache-jit=$PHP_JIT_ENABLE_ARG^` --enable-phar^` + --enable-vanillagenerator=shared^` + --enable-zstd^` + --enable-snappy^` + --enable-grpc=shared^` + --enable-protobuf=shared^` --enable-recursionguard=shared^` --enable-sockets^` --enable-tokenizer^` @@ -524,6 +692,7 @@ sdk-command "configure^` --with-crypto=shared^` --with-curl^` --with-dom^` + --with-ffi^` --with-gd=shared^` --with-gmp^` --with-iconv^` @@ -543,6 +712,7 @@ sdk-command "configure^` --with-xdebug-compression^` --with-xml^` --with-yaml^` + --with-rdkafka=shared^` --with-pdo-mysql^` --with-pdo-sqlite^` --without-readline" @@ -566,6 +736,10 @@ Remove-Item -Recurse bin -ErrorAction Continue >> $log_file 2>&1 mkdir bin >> $log_file 2>&1 Move-Item "$SOURCES_PATH\php-src\$ARCH\$($OUT_PATH_REL)_TS\php-$PHP_DISPLAY_VER" bin\php +mkdir bin\grpc >> $log_file 2>&1 +Move-Item "$LIB_BUILD_DIR\grpc\grpc_php_plugin.exe" "bin\grpc\grpc_php_plugin.exe" >> $log_file 2>&1 +Move-Item "$LIB_BUILD_DIR\grpc\third_party\protobuf\protoc.exe" "bin\grpc\protoc.exe" >> $log_file 2>&1 + $php_exe = "$outpath\bin\php\php.exe" if (!(Test-Path $php_exe)) { @@ -603,6 +777,10 @@ append-file-utf8 "opcache.cache_id=PHP_BINARY ;prevent sharing SHM between diffe append-file-utf8 ";Optional extensions, supplied for plugin use" $php_ini append-file-utf8 "extension=php_fileinfo.dll" $php_ini append-file-utf8 "extension=php_gd.dll" $php_ini +append-file-utf8 "extension=php_grpc.dll" $php_ini +append-file-utf8 "extension=php_protobuf.dll" $php_ini +append-file-utf8 "extension=php_vanillagenerator.dll" $php_ini +append-file-utf8 "extension=php_rdkafka.dll" $php_ini append-file-utf8 "extension=php_mysqli.dll" $php_ini append-file-utf8 "extension=php_sqlite3.dll" $php_ini append-file-utf8 ";Optional extensions, supplied for debugging" $php_ini