Skip to content

Commit c02cc68

Browse files
committed
fix: snappy build in windows
1 parent 0b33408 commit c02cc68

File tree

2 files changed

+75
-10
lines changed

2 files changed

+75
-10
lines changed

Diff for: compile.sh

+49-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ LIBDEFLATE_VERSION="275aa5141db6eda3587214e0f1d3a134768f557d" #1.20
1616
LIBRDKAFKA_VER="2.1.1"
1717
LIBZSTD_VER="1.5.5"
1818
LIBGRPC_VER="1.58.1"
19+
LIBSNAPPY_VER="1.2.1"
1920
SASL2_VERSION="2.1.28"
2021

2122
EXT_PMMPTHREAD_VERSION="6.1.0"
@@ -25,7 +26,7 @@ EXT_CHUNKUTILS2_VERSION="0.3.5"
2526
EXT_XDEBUG_VERSION="3.3.1"
2627
EXT_IGBINARY_VERSION="3.2.15"
2728
EXT_CRYPTO_VERSION="abbe7cbf869f96e69f2ce897271a61d32f43c7c0"
28-
EXT_SNAPPY_VERSION="0.2.1"
29+
EXT_SNAPPY_VERSION="ab8b2b7375641f47deb21d8e8ba1a00ea5364cf6"
2930
EXT_RECURSIONGUARD_VERSION="0.1.0"
3031
EXT_LIBDEFLATE_VERSION="0.2.1"
3132
EXT_MORTON_VERSION="0.1.2"
@@ -554,6 +555,50 @@ download_github_src "php/php-src" "php-$PHP_VERSION" "php" | tar -zx >> "$DIR/in
554555
mv php-src-php-$PHP_VERSION php
555556
write_done
556557

558+
function build_snappy {
559+
echo -n ${pwd}
560+
561+
write_library snappy "$LIBSNAPPY_VER"
562+
local snappy_dir="./snappy-$LIBSNAPPY_VER"
563+
564+
if cant_use_cache "$snappy_dir"; then
565+
rm -rf "$snappy_dir"
566+
write_download
567+
git_download_file "https://github.com/google/snappy.git" "snappy" "$LIBSNAPPY_VER" $snappy_dir >> "$DIR/install.log" 2>&1
568+
echo -n " checking..."
569+
pushd $snappy_dir >> "$DIR/install.log" 2>&1
570+
if [ "$DO_STATIC" != "yes" ]; then
571+
local EXTRA_FLAGS="-DBUILD_SHARED_LIBS=ON"
572+
else
573+
local EXTRA_FLAGS=""
574+
fi
575+
mkdir -p cmake/build
576+
pushd cmake/build >> "$DIR/install.log" 2>&1
577+
cmake ../.. \
578+
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
579+
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
580+
-DCMAKE_INSTALL_LIBDIR=lib \
581+
-DCMAKE_BUILD_TYPE=Release \
582+
$CMAKE_GLOBAL_EXTRA_FLAGS \
583+
$EXTRA_FLAGS \
584+
>> "$DIR/install.log" 2>&1
585+
write_compile
586+
make -j $THREADS >> "$DIR/install.log" 2>&1 && mark_cache
587+
else
588+
write_caching
589+
pushd "$grpc_dir/cmake/build"
590+
fi
591+
592+
write_install
593+
make install >> "$DIR/install.log" 2>&1
594+
popd >> "$DIR/install.log" 2>&1
595+
popd >> "$DIR/install.log" 2>&1
596+
597+
echo -n ${pwd}
598+
599+
write_done
600+
}
601+
557602
function build_sasl2 {
558603
write_library sasl2 "$SASL2_VERSION"
559604
local sasl2_dir="./sasl2-$SASL2_VERSION"
@@ -1242,6 +1287,7 @@ function build_libdeflate {
12421287

12431288
cd "$LIB_BUILD_DIR"
12441289

1290+
build_snappy
12451291
build_zlib
12461292
build_gmp
12471293
build_openssl
@@ -1322,13 +1368,7 @@ git submodule update --init --recursive >> "$DIR/install.log" 2>&1
13221368
cd "$BUILD_DIR"
13231369
write_done
13241370

1325-
echo -n " snappy: downloading $EXT_SNAPPY_VERSION..."
1326-
git clone https://github.com/kjdev/php-ext-snappy.git "$BUILD_DIR/php/ext/snappy" >> "$DIR/install.log" 2>&1
1327-
cd "$BUILD_DIR/php/ext/snappy"
1328-
git checkout "$EXT_SNAPPY_VERSION" >> "$DIR/install.log" 2>&1
1329-
git submodule update --init --recursive >> "$DIR/install.log" 2>&1
1330-
cd "$BUILD_DIR"
1331-
write_done
1371+
get_github_extension "snappy" "$EXT_SNAPPY_VERSION" "kjdev" "php-ext-snappy"
13321372

13331373
get_github_extension "leveldb" "$EXT_LEVELDB_VERSION" "pmmp" "php-leveldb"
13341374

@@ -1526,6 +1566,7 @@ $HAS_GD \
15261566
$HAS_FFI \
15271567
--with-rdkafka="$INSTALL_DIR" \
15281568
--with-leveldb="$INSTALL_DIR" \
1569+
--with-snappy-includedir="$INSTALL_DIR" \
15291570
--without-readline \
15301571
$HAS_DEBUG \
15311572
--enable-chunkutils2 \

Diff for: windows-compile-vs.bat

+26-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ set LEVELDB_MCPE_VER=1c7564468b41610da4f498430e795ca4de0931ff
2424
set LIBDEFLATE_VER=dd12ff2b36d603dbb7fa8838fe7e7176fcbd4f6f
2525
set LIBRDKAFKA_VER=2.1.1
2626
set LIBZSTD_VER=1.5.5
27+
set LIBSNAPPY_VER=1.2.1
2728
set LIBGRPC_VER=1.56.2
2829

2930
set PHP_PMMPTHREAD_VER=6.1.0
@@ -32,7 +33,7 @@ set PHP_CHUNKUTILS2_VER=0.3.5
3233
set PHP_IGBINARY_VER=3.2.15
3334
set PHP_LEVELDB_VER=317fdcd8415e1566fc2835ce2bdb8e19b890f9f3
3435
set PHP_CRYPTO_VER=abbe7cbf869f96e69f2ce897271a61d32f43c7c0
35-
set PHP_SNAPPY_VER=0.2.1
36+
set PHP_SNAPPY_VER=ab8b2b7375641f47deb21d8e8ba1a00ea5364cf6
3637
set PHP_RECURSIONGUARD_VER=0.1.0
3738
set PHP_MORTON_VER=0.1.2
3839
set PHP_LIBDEFLATE_VER=0.2.1
@@ -143,6 +144,27 @@ call bin\phpsdk_deps.bat -u -t %VC_VER% -b %PHP_MAJOR_VER% -a %ARCH% -f -d %DEPS
143144
call :pm-echo "Getting additional dependencies..."
144145
cd /D "%DEPS_DIR%"
145146

147+
call :pm-echo "Downloading google/snappy version %LIBSNAPPY_VER%..."
148+
git clone -b %LIBSNAPPY_VER% https://github.com/google/snappy >>"%log_file%" 2>&1 || exit 1
149+
cd /D snappy
150+
151+
call :pm-echo "Updating submodules..."
152+
git submodule update --depth=1 --init >>"%log_file%" 2>&1 || exit 1
153+
154+
md build
155+
cd build
156+
cmake -GNinja^
157+
-DCMAKE_PREFIX_PATH="%DEPS_DIR%"^
158+
-DCMAKE_INSTALL_PREFIX="%DEPS_DIR%"^
159+
-DCMAKE_BUILD_TYPE="%MSBUILD_CONFIGURATION%"^
160+
.. >>"%log_file%" 2>&1 || exit 1
161+
162+
call :pm-echo "Compiling..."
163+
cmake --build . >> "%log_file%" 2>&1 || exit 1
164+
call :pm-echo "Installing files..."
165+
cmake -P cmake_install.cmake >> "%log_file%" 2>&1 || exit 1
166+
cd /D "%DEPS_DIR%"
167+
146168
call :pm-echo "Downloading grpc/grpc version %LIBGRPC_VER%..."
147169
git clone -b v%LIBGRPC_VER% --depth=1 https://github.com/grpc/grpc >>"%log_file%" 2>&1 || exit 1
148170
cd /D grpc
@@ -352,7 +374,9 @@ git clone https://github.com/kjdev/php-ext-snappy.git snappy >>"%log_file%" 2>&1
352374
cd /D snappy
353375
git checkout %PHP_SNAPPY_VER% >>"%log_file%" 2>&1 || exit 1
354376
git submodule update --init --recursive >>"%log_file%" 2>&1 || exit 1
355-
cd /D ..
377+
cd /D snappy
378+
git checkout %LIBSNAPPY_VER% >>"%log_file%" 2>&1 || exit 1
379+
cd /D ..\..
356380

357381
cd /D ..\..
358382

0 commit comments

Comments
 (0)