Skip to content

Commit

Permalink
Merge pull request #907 from jingjingxyk/experiment-feature
Browse files Browse the repository at this point in the history
Experiment feature
  • Loading branch information
jingjingxyk authored Jan 12, 2025
2 parents 898791d + 009d49c commit 9c48726
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/windows-cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
cp -f /cygdrive/c/setup.exe /cygdrive/c/cygwin/bin/setup-x86_64.exe
bash ./sapi/scripts/cygwin/install-cygwin.sh
- name: Install Cygwin Packages
- name: Install Cygwin Packages with powershell
if: 1
run: |
Copy-Item -Path "C:\setup.exe" -Destination "${{ github.workspace }}\setup-x86_64.exe"
Expand Down
49 changes: 46 additions & 3 deletions sapi/quickstart/windows/cygwin-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,57 @@

## [windows cygwin 环境 构建步骤](../../../../docs/Cygwin.md)

## 双击如下两个脚本,自动下载cygwin 和 cygwin安装依赖库
## 自动下载cygwin 和 cygwin安装依赖库

```shell

# 自动下载 cygwin
sapi\quickstart\windows\cygwin-build\download-cygwin.bat
.\sapi\quickstart\windows\cygwin-build\download-cygwin.bat
# 自动安装 依赖包
sapi\quickstart\windows\cygwin-build\install-cygwin.bat
.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat


```

### 使用镜像 安装 cygwin 环境依赖包

```
.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat --mirror china
```

### PowerShell 环境中调用批处理命令

```powershell
cmd /c .\sapi\quickstart\windows\cygwin-build\install-cygwin.bat --mirror china
```

## 进入cygwin 环境

```
C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -
# 进入项目所在目录 (USER=Administrator)
cd /cygdrive/c/users/${USER}/swoole-cli
```

### cygwin mirror

https://cygwin.com/mirrors.html

### 搜索包

https://cygwin.com/cgi-bin2/package-grep.cgi?grep=openssl

### windows 软连接例子

```bash

mklink composer composer.phar

```

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
26 changes: 16 additions & 10 deletions sapi/quickstart/windows/cygwin-build/install-cygwin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,37 @@ cd /d ..\..\..\..\
set "__PROJECT__=%cd%"
cd /d %__PROJECT__%\
echo %cd%
:: package separate with commas


set SITE="https://mirrors.kernel.org/sourceware/cygwin/"

set "SITE=https://mirrors.kernel.org/sourceware/cygwin/"

:getopt
if /i "%1" equ "--mirror" (
if /i "%2" equ "china" (
set SITE="https://mirrors.ustc.edu.cn/cygwin/"
set "SITE=https://mirrors.ustc.edu.cn/cygwin/"
)
)
shift

if not (%1)==() goto getopt

if "%GITHUB_ACTIONS%"=="" (
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site %SITE%
)
set "OPTIONS= --quiet-mode --disable-buggy-antivirus --site %SITE% "
set "PACKAGES="

setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils
if defined GITHUB_ACTIONS (
set "OPTIONS= %OPTIONS% --no-desktop --no-shortcuts --no-startmenu "
)

setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages zip unzip
:: package separate with commas
set "PACKAGES=make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils"
set "PACKAGES=%PACKAGES%,zip,unzip"
set "PACKAGES=%PACKAGES%,libpq5,libpq-devel"
set "PACKAGES=%PACKAGES%,libzstd-devel"

setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libpq5 libpq-devel
set "OPTIONS=%OPTIONS% --packages %PACKAGES%"
echo %OPTIONS%

setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libzstd-devel
start /b /wait setup-x86_64.exe %OPTIONS%

endlocal
21 changes: 21 additions & 0 deletions sapi/quickstart/windows/cygwin-build/uninstall-cygwin.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@echo off


setlocal enableextensions enabledelayedexpansion

echo %~dp0
cd /d %~dp0
cd /d ..\..\..\..\

set "__PROJECT__=%cd%"
cd /d %__PROJECT__%\
echo %cd%


SET DIRECTORY_NAME="c:\cygwin64"
C:\windows\system32\TAKEOWN /f %DIRECTORY_NAME% /r /d y
C:\windows\system32\ICACLS %DIRECTORY_NAME% /grant administrators:F /t

rmdir /s %DIRECTORY_NAME%

endlocal
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__}
14 changes: 9 additions & 5 deletions sapi/scripts/cygwin/install-cygwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ while [ $# -gt 0 ]; do
done

# setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,zip,unzip
#setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://mirrors.ustc.edu.cn/cygwin/ --packages
# setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://mirrors.ustc.edu.cn/cygwin/ --packages libzstd-devel

setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,zip,unzip
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages zip unzip icu libicu-devel
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages libpq5 libpq-devel
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages libzstd-devel
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE

## 多个包之间,用逗号分隔
PACKAGES="make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,zip,unzip"
PACKAGES="${PACKAGES},zip,unzip,icu,libicu-devel"
PACKAGES="${PACKAGES},libpq5 libpq-devel"
PACKAGES="${PACKAGES},libzstd-devel"
setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages $PACKAGES

0 comments on commit 9c48726

Please sign in to comment.