Skip to content

Commit

Permalink
fix: snappy build in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
larryTheCoder committed Jun 21, 2024
1 parent 0b33408 commit c02cc68
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 10 deletions.
57 changes: 49 additions & 8 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LIBDEFLATE_VERSION="275aa5141db6eda3587214e0f1d3a134768f557d" #1.20
LIBRDKAFKA_VER="2.1.1"
LIBZSTD_VER="1.5.5"
LIBGRPC_VER="1.58.1"
LIBSNAPPY_VER="1.2.1"
SASL2_VERSION="2.1.28"

EXT_PMMPTHREAD_VERSION="6.1.0"
Expand All @@ -25,7 +26,7 @@ EXT_CHUNKUTILS2_VERSION="0.3.5"
EXT_XDEBUG_VERSION="3.3.1"
EXT_IGBINARY_VERSION="3.2.15"
EXT_CRYPTO_VERSION="abbe7cbf869f96e69f2ce897271a61d32f43c7c0"
EXT_SNAPPY_VERSION="0.2.1"
EXT_SNAPPY_VERSION="ab8b2b7375641f47deb21d8e8ba1a00ea5364cf6"
EXT_RECURSIONGUARD_VERSION="0.1.0"
EXT_LIBDEFLATE_VERSION="0.2.1"
EXT_MORTON_VERSION="0.1.2"
Expand Down Expand Up @@ -554,6 +555,50 @@ 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 {
echo -n ${pwd}

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

echo -n ${pwd}

write_done
}

function build_sasl2 {
write_library sasl2 "$SASL2_VERSION"
local sasl2_dir="./sasl2-$SASL2_VERSION"
Expand Down Expand Up @@ -1242,6 +1287,7 @@ function build_libdeflate {

cd "$LIB_BUILD_DIR"

build_snappy
build_zlib
build_gmp
build_openssl
Expand Down Expand Up @@ -1322,13 +1368,7 @@ git submodule update --init --recursive >> "$DIR/install.log" 2>&1
cd "$BUILD_DIR"
write_done

echo -n " snappy: downloading $EXT_SNAPPY_VERSION..."
git clone https://github.com/kjdev/php-ext-snappy.git "$BUILD_DIR/php/ext/snappy" >> "$DIR/install.log" 2>&1
cd "$BUILD_DIR/php/ext/snappy"
git checkout "$EXT_SNAPPY_VERSION" >> "$DIR/install.log" 2>&1
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"

Expand Down Expand Up @@ -1526,6 +1566,7 @@ $HAS_GD \
$HAS_FFI \
--with-rdkafka="$INSTALL_DIR" \
--with-leveldb="$INSTALL_DIR" \
--with-snappy-includedir="$INSTALL_DIR" \
--without-readline \
$HAS_DEBUG \
--enable-chunkutils2 \
Expand Down
28 changes: 26 additions & 2 deletions windows-compile-vs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ set LEVELDB_MCPE_VER=1c7564468b41610da4f498430e795ca4de0931ff
set LIBDEFLATE_VER=dd12ff2b36d603dbb7fa8838fe7e7176fcbd4f6f
set LIBRDKAFKA_VER=2.1.1
set LIBZSTD_VER=1.5.5
set LIBSNAPPY_VER=1.2.1
set LIBGRPC_VER=1.56.2

set PHP_PMMPTHREAD_VER=6.1.0
Expand All @@ -32,7 +33,7 @@ set PHP_CHUNKUTILS2_VER=0.3.5
set PHP_IGBINARY_VER=3.2.15
set PHP_LEVELDB_VER=317fdcd8415e1566fc2835ce2bdb8e19b890f9f3
set PHP_CRYPTO_VER=abbe7cbf869f96e69f2ce897271a61d32f43c7c0
set PHP_SNAPPY_VER=0.2.1
set PHP_SNAPPY_VER=ab8b2b7375641f47deb21d8e8ba1a00ea5364cf6
set PHP_RECURSIONGUARD_VER=0.1.0
set PHP_MORTON_VER=0.1.2
set PHP_LIBDEFLATE_VER=0.2.1
Expand Down Expand Up @@ -143,6 +144,27 @@ 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 google/snappy version %LIBSNAPPY_VER%..."
git clone -b %LIBSNAPPY_VER% https://github.com/google/snappy >>"%log_file%" 2>&1 || exit 1
cd /D snappy

call :pm-echo "Updating submodules..."
git submodule update --depth=1 --init >>"%log_file%" 2>&1 || exit 1

md build
cd build
cmake -GNinja^
-DCMAKE_PREFIX_PATH="%DEPS_DIR%"^
-DCMAKE_INSTALL_PREFIX="%DEPS_DIR%"^
-DCMAKE_BUILD_TYPE="%MSBUILD_CONFIGURATION%"^
.. >>"%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 "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
Expand Down Expand Up @@ -352,7 +374,9 @@ git clone https://github.com/kjdev/php-ext-snappy.git snappy >>"%log_file%" 2>&1
cd /D snappy
git checkout %PHP_SNAPPY_VER% >>"%log_file%" 2>&1 || exit 1
git submodule update --init --recursive >>"%log_file%" 2>&1 || exit 1
cd /D ..
cd /D snappy
git checkout %LIBSNAPPY_VER% >>"%log_file%" 2>&1 || exit 1
cd /D ..\..

cd /D ..\..

Expand Down

0 comments on commit c02cc68

Please sign in to comment.