diff --git a/.github/workflows/windows-cygwin.yml b/.github/workflows/windows-cygwin.yml index 1dccb971bd..8fbe287dd2 100644 --- a/.github/workflows/windows-cygwin.yml +++ b/.github/workflows/windows-cygwin.yml @@ -15,6 +15,7 @@ jobs: systeminfo systeminfo | findstr /B /C:"OS Name" /C:"OS Version" systeminfo | findstr /B /C:"Manufacturer" /C:"Product" /C:"Version" + set - name: Prepare git run: | @@ -52,7 +53,8 @@ jobs: # platform: x64 # packages: make wget tar libtool re2c 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 openssl-devel zip unzip - - name: Install Cygwin Packages + - name: Install Cygwin Packages with bash + if: 0 shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | ls -lah /cygdrive/c/ @@ -62,11 +64,19 @@ jobs: bash ./sapi/scripts/cygwin/install-cygwin.sh + - name: Install Cygwin Packages + if: 1 + run: | + Copy-Item -Path "C:\setup.exe" -Destination "${{ github.workspace }}\setup-x86_64.exe" + cmd /c .\sapi\quickstart\windows\cygwin-build\install-cygwin.bat + - name: Install re2c + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | bash ./sapi/scripts/cygwin/install-re2c.sh - name: Configure + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | uname -a # git config --global --add safe.directory /cygdrive/d/a/swoole-cli/swoole-cli @@ -75,6 +85,7 @@ jobs: bash ./sapi/scripts/cygwin/cygwin-config.sh - name: Build + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | bash ./sapi/scripts/cygwin/cygwin-build.sh diff --git a/docs/Cygwin.md b/docs/Cygwin.md index 5c2b1cca9b..5fd4679cab 100755 --- a/docs/Cygwin.md +++ b/docs/Cygwin.md @@ -12,21 +12,43 @@ > 命令行同时安装多个包,包名之间使用逗号隔开 +## windows 环境下 配置 git 环境 + +1. 禁止Git在提交和检出时进行换行符的自动转换‌ +2. 使用`lf` 作为换行符 +3. 区分大小写 + +```shell + +# 下载git +curl.exe -fSLo Git-2.47.1-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/Git-2.47.1-64-bit.exe + +# 命令行静默安装 git +start /wait .\Git-2.47.1-64-bit.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="C:\Program Files\Git" + + +git config --global core.autocrlf false +git config --global core.eol lf +git config --global core.ignorecase false + +``` + ## 安装cygwin 和 cygwin 依赖项 -> 执行如下命令 +> 打开windows CMD 终端,进入项目目录 ,执行如下命令 ```bash # 自动安装 cygwin 和 cygwin 依赖项 -.\sapi\quickstart\windows\download-cygwin.bat -.\sapi\quickstart\windows\install-cygwin.bat +.\sapi\quickstart\windows\cygwin-build\download-cygwin.bat +.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat + ``` 构建步骤 - 执行的命令 ==== -> 运行如下步骤,需要先 打开 cygwin64 Terminal +> 运行如下步骤,打开 cygwin64 Terminal, 并进入项目目录,执行如下命令 ```shell @@ -122,14 +144,16 @@ libzstd-devel ## 安装 cygwin 和 安装 cygwin 依赖项 具体执行的命令 -> `sapi\quickstart\windows\install-cygwin.bat` 脚本包含的内容 +> 多个包之间 使用逗号分隔 + +> 编辑修改此文件即可 `.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat` ```bash # 安装 cygwin -setup-x86_64.exe --site https://mirrors.ustc.edu.cn/cygwin/ +setup-x86_64.exe --site https://mirrors.ustc.edu.cn/cygwin/ # 安装 cygwin 依赖项 -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://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,openssl-devel +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://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 setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages zip unzip icu libicu-devel diff --git a/sapi/quickstart/windows/README.md b/sapi/quickstart/windows/cygwin-build/README.md similarity index 51% rename from sapi/quickstart/windows/README.md rename to sapi/quickstart/windows/cygwin-build/README.md index f7df0e7867..23937d8589 100644 --- a/sapi/quickstart/windows/README.md +++ b/sapi/quickstart/windows/cygwin-build/README.md @@ -1,15 +1,15 @@ # windows 快速准备构建环境 -## [windows cygwin 环境 构建步骤](../../../docs/Cygwin.md) +## [windows cygwin 环境 构建步骤](../../../../docs/Cygwin.md) ## 双击如下两个脚本,自动下载cygwin 和 cygwin安装依赖库 ```shell # 自动下载 cygwin -sapi\quickstart\windows\download-cygwin.bat -# 自动安装 cygwin -sapi\quickstart\windows\install-cygwin.bat +sapi\quickstart\windows\cygwin-build\download-cygwin.bat +# 自动安装 依赖包 +sapi\quickstart\windows\cygwin-build\install-cygwin.bat ``` diff --git a/sapi/quickstart/windows/download-cygwin.bat b/sapi/quickstart/windows/cygwin-build/download-cygwin.bat similarity index 95% rename from sapi/quickstart/windows/download-cygwin.bat rename to sapi/quickstart/windows/cygwin-build/download-cygwin.bat index 684ef9f7af..1b5e928bf8 100644 --- a/sapi/quickstart/windows/download-cygwin.bat +++ b/sapi/quickstart/windows/cygwin-build/download-cygwin.bat @@ -7,7 +7,7 @@ setlocal echo %~dp0 cd /d %~dp0 -cd /d ..\..\..\ +cd /d ..\..\..\..\ set "__PROJECT__=%cd%" echo %cd% diff --git a/sapi/quickstart/windows/cygwin-build/install-cygwin.bat b/sapi/quickstart/windows/cygwin-build/install-cygwin.bat new file mode 100644 index 0000000000..947c6fa2d4 --- /dev/null +++ b/sapi/quickstart/windows/cygwin-build/install-cygwin.bat @@ -0,0 +1,42 @@ +@echo off + +:: cygwin site: https://cygwin.com/ +:: start https://cygwin.com/setup-x86_64.exe + +setlocal enableextensions enabledelayedexpansion + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +cd /d %__PROJECT__%\ +echo %cd% +:: package separate with commas + + +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/" + ) +) +shift + +if not (%1)==() goto getopt + +if "%GITHUB_ACTIONS%"=="" ( + setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site %SITE% +) + +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 + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages zip unzip + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libpq5 libpq-devel + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libzstd-devel + +endlocal diff --git a/sapi/quickstart/windows/install-cygwin.bat b/sapi/quickstart/windows/install-cygwin.bat deleted file mode 100644 index 3473a4dc6a..0000000000 --- a/sapi/quickstart/windows/install-cygwin.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -:: cygwin site: https://cygwin.com/ -:: start https://cygwin.com/setup-x86_64.exe - -setlocal - - -echo %~dp0 -cd /d %~dp0 -cd /d ..\..\..\ - -set "__PROJECT__=%cd%" -echo %cd% -:: package separate with commas - -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://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,openssl-devel - -setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages zip unzip - -setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages libpq5 libpq-devel - -setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages libzstd-devel - -endlocal diff --git a/sapi/scripts/cygwin/cygwin-build.sh b/sapi/scripts/cygwin/cygwin-build.sh index 36386243da..2c4594122c 100755 --- a/sapi/scripts/cygwin/cygwin-build.sh +++ b/sapi/scripts/cygwin/cygwin-build.sh @@ -13,5 +13,18 @@ cd ${__PROJECT__} mkdir -p bin/.libs # export LDFLAGS="-all-static" -make -j $(nproc) +LOGICAL_PROCESSORS=$(nproc) + +set +u +if [ -n "${GITHUB_ACTION}" ]; then + if test $LOGICAL_PROCESSORS -ge 4; then + LOGICAL_PROCESSORS=$((LOGICAL_PROCESSORS - 2)) + fi + make + # make -j $LOGICAL_PROCESSORS +else + make -j $LOGICAL_PROCESSORS +fi +set -u + ./bin/swoole-cli -v diff --git a/sapi/scripts/cygwin/install-cygwin.sh b/sapi/scripts/cygwin/install-cygwin.sh index 79d61128a9..6971f19e5a 100644 --- a/sapi/scripts/cygwin/install-cygwin.sh +++ b/sapi/scripts/cygwin/install-cygwin.sh @@ -42,10 +42,10 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) 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,openssl-devel,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 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 $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,openssl-devel,zip,unzip +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