Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
add ZSTD support
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockedPlot7560 committed Jan 26, 2024
1 parent 4a39aae commit c00af11
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 81 deletions.
81 changes: 0 additions & 81 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,63 +71,6 @@ jobs:
workspace.tar.gz
if-no-files-found: error

macos:
name: MacOS (PM ${{ matrix.pm-version-major }})
runs-on: macos-11.0
strategy:
matrix:
pm-version-major: [ 4, 5 ]

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
with:
path: ./download_cache
key: compile-sh-cache-ssl-https-${{ hashFiles('./compile.sh') }}
restore-keys: compile-sh-cache-ssl-https-

- name: Compile PHP
run: |
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
- 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
- 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
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: MacOS-workspace-PM${{ matrix.pm-version-major }}
path: |
workspace.tar.gz
if-no-files-found: error

windows:
name: Windows (PM ${{ matrix.pm-version-major }})
runs-on: windows-2019
Expand Down Expand Up @@ -190,34 +133,11 @@ jobs:
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/[email protected]
with:
artifacts: |
${{ github.workspace }}/Linux-PM*/*.tar.gz
${{ github.workspace }}/MacOS-PM*/*.tar.gz
${{ github.workspace }}/Windows-PM*/*.zip
makeLatest: ${{ github.ref_name == github.event.repository.default_branch }}
name: PHP ${{ steps.version.outputs.PHP_VERSION }} - Latest (Build ${{ github.run_number }})
Expand All @@ -233,7 +153,6 @@ jobs:
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 }})
Expand Down
51 changes: 51 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ OPENSSL_VERSION="3.1.4"
LIBZIP_VERSION="1.10.1"
SQLITE3_VERSION="3440200" #3.44.2
LIBDEFLATE_VERSION="dd12ff2b36d603dbb7fa8838fe7e7176fcbd4f6f" #1.19
LIBZSTD_VER="1.5.5"

EXT_PTHREADS_VERSION="4.2.2"
EXT_PMMPTHREAD_VERSION="6.0.12"
Expand All @@ -28,6 +29,7 @@ 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_ZSTD_VERSION="0.12.3"

function write_out {
echo "[$1] $2"
Expand Down Expand Up @@ -537,6 +539,49 @@ function build_zlib {
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
echo -n " installing..."
make install >> "$DIR/install.log" 2>&1
popd >> "$DIR/install.log" 2>&1
echo " done!"

if [ "$LDORIGIN_MODIFY" != "no" ]; then
LDFLAGS="-Wl,-rpath='\$\$ORIGIN/../lib' -Wl,-rpath-link='\$\$ORIGIN/../lib'";
fi
}

function build_gmp {
export jm_cv_func_working_malloc=yes
export ac_cv_func_malloc_0_nonnull=yes
Expand Down Expand Up @@ -986,6 +1031,7 @@ build_zlib
build_gmp
build_openssl
build_curl
build_zstd
build_yaml
build_leveldb
if [ "$COMPILE_GD" == "yes" ]; then
Expand Down Expand Up @@ -1071,6 +1117,8 @@ get_github_extension "arraydebug" "$EXT_ARRAYDEBUG_VERSION" "pmmp" "ext-arraydeb

get_github_extension "encoding" "$EXT_ENCODING_VERSION" "pmmp" "ext-encoding"

get_github_extension "zstd" "$EXT_ZSTD_VERSION" "kjdev" "php-ext-zstd"

write_library "PHP" "$PHP_VERSION"

write_configure
Expand Down Expand Up @@ -1176,6 +1224,7 @@ $THREAD_EXT_FLAGS \
--with-pdo-sqlite \
--with-pdo-mysql \
--with-pic \
--with-libzstd \
--enable-phar \
--enable-ctype \
--enable-sockets \
Expand All @@ -1189,6 +1238,7 @@ $HAVE_MYSQLI \
--enable-bcmath \
--enable-cli \
--enable-ftp \
--enable-zstd \
--enable-opcache=$HAVE_OPCACHE \
--enable-opcache-jit=$HAVE_OPCACHE_JIT \
--enable-igbinary \
Expand Down Expand Up @@ -1350,6 +1400,7 @@ 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 -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
Expand Down
20 changes: 20 additions & 0 deletions windows-compile-vs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set LIBYAML_VER=0.2.5
set PTHREAD_W32_VER=3.0.0
set LEVELDB_MCPE_VER=1c7564468b41610da4f498430e795ca4de0931ff
set LIBDEFLATE_VER=dd12ff2b36d603dbb7fa8838fe7e7176fcbd4f6f
set LIBZSTD_VER=1.5.5

set PHP_PTHREADS_VER=4.2.2
set PHP_PMMPTHREAD_VER=6.0.12
Expand All @@ -37,6 +38,7 @@ 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_ZSTD_VER=0.12.3

set script_path=%~dp0
set log_file=%script_path%compile.log
Expand Down Expand Up @@ -132,6 +134,22 @@ 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 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 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
Expand Down Expand Up @@ -238,6 +256,7 @@ 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 "zstd" "%PHP_ZSTD_VER%" "kjdev" "php-ext-zstd" || 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
Expand Down Expand Up @@ -282,6 +301,7 @@ call configure^
--enable-opcache^
--enable-opcache-jit=%PHP_JIT_ENABLE_ARG%^
--enable-phar^
--enable-zstd^
--enable-recursionguard=shared^
--enable-sockets^
--enable-tokenizer^
Expand Down

0 comments on commit c00af11

Please sign in to comment.