Skip to content

Commit

Permalink
merge code
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Jan 12, 2025
2 parents f48ce7c + c391aaa commit 009d49c
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 58 deletions.
4 changes: 2 additions & 2 deletions sapi/quickstart/windows/cygwin-build/download-cygwin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ cd /d ..\..\..\..\
set "__PROJECT__=%cd%"
echo %cd%

md %__PROJECT__%\var\windows-cygwin-build-deps\
md %__PROJECT__%\var\cygwin-build\

cd /d %__PROJECT__%\var\windows-cygwin-build-deps\
cd /d %__PROJECT__%\var\cygwin-build\

curl.exe -fSLo setup-x86_64.exe https://cygwin.com/setup-x86_64.exe

Expand Down
123 changes: 67 additions & 56 deletions sapi/scripts/cygwin/cygwin-config-ext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ __PROJECT__=$(
)
cd ${__PROJECT__}

ROOT=${__PROJECT__}

SWOOLE_VERSION=v6.0.0

while [ $# -gt 0 ]; do
case "$1" in
--swoole-version)
Expand All @@ -26,82 +23,96 @@ while [ $# -gt 0 ]; do
esac
shift $(($# > 0 ? 1 : 0))
done

PHP_VERSION=$(cat ${__PROJECT__}/sapi/PHP-VERSION.conf)

REDIS_VERSION=5.3.7
MONGODB_VERSION=1.14.2
YAML_VERSION=2.2.2
IMAGICK_VERSION=3.7.0

if [ ! -d pool/ext ]; then
mkdir -p pool/ext
mkdir -p pool/ext
mkdir -p pool/lib
mkdir -p pool/php-tar

WORK_TEMP_DIR=${__PROJECT__}/var/cygwin-build/
EXT_TEMP_CACHE_DIR=${WORK_TEMP_DIR}/pool/ext/
mkdir -p ${WORK_TEMP_DIR}
mkdir -p ${EXT_TEMP_CACHE_DIR}
test -d ${WORK_TEMP_DIR}/ext/ && rm -rf ${WORK_TEMP_DIR}/ext/
mkdir -p ${WORK_TEMP_DIR}/ext/

cd ${__PROJECT__}/pool/ext
if [ ! -f redis-${REDIS_VERSION}.tgz ]; then
curl -fSLo ${EXT_TEMP_CACHE_DIR}/redis-${REDIS_VERSION}.tgz https://pecl.php.net/get/redis-${REDIS_VERSION}.tgz
mv ${EXT_TEMP_CACHE_DIR}/redis-${REDIS_VERSION}.tgz ${__PROJECT__}/pool/ext
fi
mkdir -p ${WORK_TEMP_DIR}/ext/redis/
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/redis/ -xf redis-${REDIS_VERSION}.tgz

cd pool/ext
: <<EOF
# mongodb 扩展 不支持 cygwin 环境下构建
# 详见: https://github.com/mongodb/mongo-php-driver/issues/1381
if [ ! -d $ROOT/ext/redis ]; then
if [ ! -f redis-${REDIS_VERSION}.tgz ]; then
curl -fSLo redis-${REDIS_VERSION}.tgz https://pecl.php.net/get/redis-${REDIS_VERSION}.tgz
fi
tar xvf redis-${REDIS_VERSION}.tgz
mv redis-${REDIS_VERSION} $ROOT/ext/redis
cd ${__PROJECT__}/pool/ext
if [ ! -f mongodb-${MONGODB_VERSION}.tgz ]; then
curl -fSLo ${EXT_TEMP_CACHE_DIR}/mongodb-${MONGODB_VERSION}.tgz https://pecl.php.net/get/mongodb-${MONGODB_VERSION}.tgz
mv ${EXT_TEMP_CACHE_DIR}/redis-${REDIS_VERSION}.tgz ${__PROJECT__}/pool/ext
fi
mkdir -p ${WORK_TEMP_DIR}/ext/mongodb/
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/mongodb/ -xf redis-${REDIS_VERSION}.tgz
if [ ! -d $ROOT/ext/mongodb ]; then
if [ ! -f mongodb-${MONGODB_VERSION}.tgz ]; then
curl -fSLo mongodb-${MONGODB_VERSION}.tgz https://pecl.php.net/get/mongodb-${MONGODB_VERSION}.tgz
fi
tar xvf mongodb-${MONGODB_VERSION}.tgz
mv mongodb-${MONGODB_VERSION} $ROOT/ext/mongodb
fi
EOF

if [ ! -d $ROOT/ext/yaml ]; then
if [ ! -f yaml-${YAML_VERSION}.tgz ]; then
curl -fSLo yaml-${YAML_VERSION}.tgz https://pecl.php.net/get/yaml-${YAML_VERSION}.tgz
fi
tar xvf yaml-${YAML_VERSION}.tgz
mv yaml-${YAML_VERSION} $ROOT/ext/yaml
cd ${__PROJECT__}/pool/ext
if [ ! -f yaml-${YAML_VERSION}.tgz ]; then
curl -fSLo ${EXT_TEMP_CACHE_DIR}/yaml-${YAML_VERSION}.tgz https://pecl.php.net/get/yaml-${YAML_VERSION}.tgz
mv ${EXT_TEMP_CACHE_DIR}/yaml-${YAML_VERSION}.tgz ${__PROJECT__}/pool/ext
fi
mkdir -p ${WORK_TEMP_DIR}/ext/yaml/
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/yaml/ -xf yaml-${YAML_VERSION}.tgz

if [ ! -d $ROOT/ext/imagick ]; then
if [ ! -f imagick-${IMAGICK_VERSION}.tgz ]; then
curl -fSLo imagick-${IMAGICK_VERSION}.tgz https://pecl.php.net/get/imagick-${IMAGICK_VERSION}.tgz
fi
tar xvf imagick-${IMAGICK_VERSION}.tgz
mv imagick-${IMAGICK_VERSION} $ROOT/ext/imagick
cd ${__PROJECT__}/pool/ext
if [ ! -f imagick-${IMAGICK_VERSION}.tgz ]; then
curl -fSLo ${EXT_TEMP_CACHE_DIR}/imagick-${IMAGICK_VERSION}.tgz https://pecl.php.net/get/imagick-${IMAGICK_VERSION}.tgz
mv ${EXT_TEMP_CACHE_DIR}/imagick-${IMAGICK_VERSION}.tgz ${__PROJECT__}/pool/ext
fi
mkdir -p ${WORK_TEMP_DIR}/ext/imagick/
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/imagick/ -xf imagick-${IMAGICK_VERSION}.tgz

cd ${__PROJECT__}/pool/ext
if [ ! -f swoole-${SWOOLE_VERSION}.tgz ]; then
test -d /tmp/swoole && rm -rf /tmp/swoole
git clone -b ${SWOOLE_VERSION} https://github.com/swoole/swoole-src.git /tmp/swoole
cd /tmp/swoole
tar -czvf $ROOT/pool/ext/swoole-${SWOOLE_VERSION}.tgz .
cd $ROOT/pool/ext/
test -d ${WORK_TEMP_DIR}/swoole && rm -rf ${WORK_TEMP_DIR}/swoole
git clone -b ${SWOOLE_VERSION} https://github.com/swoole/swoole-src.git ${WORK_TEMP_DIR}/swoole
cd ${WORK_TEMP_DIR}/swoole
tar -czvf ${EXT_TEMP_CACHE_DIR}/swoole-${SWOOLE_VERSION}.tgz .
mv ${EXT_TEMP_CACHE_DIR}/swoole-${SWOOLE_VERSION}.tgz ${__PROJECT__}/pool/ext
cd ${__PROJECT__}/pool/ext
fi
mkdir -p swoole-${SWOOLE_VERSION}
tar --strip-components=1 -C swoole-${SWOOLE_VERSION} -xf swoole-${SWOOLE_VERSION}.tgz
test -d $ROOT/ext/swoole && rm -rf $ROOT/ext/swoole
mv swoole-${SWOOLE_VERSION} $ROOT/ext/swoole
mkdir -p ${WORK_TEMP_DIR}/ext/swoole/
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/swoole/ -xf swoole-${SWOOLE_VERSION}.tgz

cd $ROOT
# downgload php-src source code
cd ${__PROJECT__}
# clean extension folder
NO_BUILT_IN_EXTENSIONS=$(ls ${WORK_TEMP_DIR}/ext/)
for EXT_NAME in $NO_BUILT_IN_EXTENSIONS; do
echo "EXTENSION_NAME: $EXT_NAME "
test -d ${__PROJECT__}/ext/${EXT_NAME} && rm -rf ${__PROJECT__}/ext/${EXT_NAME}
done

# download php-src source code
cd ${__PROJECT__}/pool/php-tar
if [ ! -f php-${PHP_VERSION}.tar.gz ]; then
curl -fSLo php-${PHP_VERSION}.tar.gz https://github.com/php/php-src/archive/refs/tags/php-${PHP_VERSION}.tar.gz
fi
test -d php-src && rm -rf php-src
mkdir -p php-src
tar --strip-components=1 -C php-src -xf php-${PHP_VERSION}.tar.gz
test -d ${WORK_TEMP_DIR}/php-src && rm -rf ${WORK_TEMP_DIR}/php-src
mkdir -p ${WORK_TEMP_DIR}/php-src
tar --strip-components=1 -C ${WORK_TEMP_DIR}/php-src -xf php-${PHP_VERSION}.tar.gz

cd $ROOT
cd ${__PROJECT__}
# copy extension
# cp -rf var/cygwin-build/ext/* ext/
cp -rf ${WORK_TEMP_DIR}/ext/* ${__PROJECT__}/ext/

if [ ! -d $ROOT/ext/pgsql ]; then
mv $ROOT/php-src/ext/pgsql $ROOT/ext/pgsql
fi
# extension hook

cd $ROOT
# cp -f $ROOT/php-src/Zend/zend_vm_gen.php $ROOT/Zend/
ls -lha $ROOT/Zend/zend_vm_gen.php
ls -lh $ROOT
ls -lh $ROOT/ext/
cd $ROOT
cd ${__PROJECT__}
42 changes: 42 additions & 0 deletions sapi/scripts/cygwin/cygwin-pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -exu
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
__PROJECT__=$(
cd ${__DIR__}/../../../
pwd
)
cd ${__PROJECT__}

cd ${__PROJECT__}/
ldd ${__PROJECT__}/bin/swoole-cli.exe

cd ${__PROJECT__}
APP_VERSION=$(${__PROJECT__}/bin/swoole-cli.exe -v | head -n 1 | awk '{ print $2 }')
NAME="swoole-cli-v${APP_VERSION}-cygwin-x64"

test -d /tmp/${NAME} && rm -rf /tmp/${NAME}
mkdir -p /tmp/${NAME}
mkdir -p /tmp/${NAME}/etc/

cd ${__PROJECT__}/
ldd ${__PROJECT__}/bin/swoole-cli.exe | grep -v '/cygdrive/' | awk '{print $3}'
ldd ${__PROJECT__}/bin/swoole-cli.exe | grep -v '/cygdrive/' | awk '{print $3}' | xargs -I {} cp {} /tmp/${NAME}/

ls -lh /tmp/${NAME}/

cp -f ${__PROJECT__}/bin/swoole-cli.exe /tmp/${NAME}/
# cp -f ${__PROJECT__}/bin/LICENSE /tmp/${NAME}/
# cp -f ${__PROJECT__}/bin/credits.html /tmp/${NAME}/

cp -rL /etc/pki/ /tmp/${NAME}/etc/

cd /tmp/${NAME}/

test -f ${__PROJECT__}/${NAME}.zip && rm -f ${__PROJECT__}/${NAME}.zip
zip -r ${__PROJECT__}/${NAME}.zip .

cd ${__PROJECT__}

0 comments on commit 009d49c

Please sign in to comment.