Skip to content

Commit 477cfbf

Browse files
authored
优化 cygwin 构建环境 (#893)
* 优化 cygwin 构建环境 * 优化 cygwin 构建环境 * updae install-cygwin.bat * test cygwin make * update cygwin-build.sh * update cygwin-build.sh * update cygwin-build.sh
1 parent 406803f commit 477cfbf

File tree

8 files changed

+106
-40
lines changed

8 files changed

+106
-40
lines changed

.github/workflows/windows-cygwin.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
systeminfo
1616
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
1717
systeminfo | findstr /B /C:"Manufacturer" /C:"Product" /C:"Version"
18+
set
1819
1920
- name: Prepare git
2021
run: |
@@ -52,7 +53,8 @@ jobs:
5253
# platform: x64
5354
# 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
5455

55-
- name: Install Cygwin Packages
56+
- name: Install Cygwin Packages with bash
57+
if: 0
5658
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
5759
run: |
5860
ls -lah /cygdrive/c/
@@ -62,11 +64,19 @@ jobs:
6264
6365
bash ./sapi/scripts/cygwin/install-cygwin.sh
6466
67+
- name: Install Cygwin Packages
68+
if: 1
69+
run: |
70+
Copy-Item -Path "C:\setup.exe" -Destination "${{ github.workspace }}\setup-x86_64.exe"
71+
cmd /c .\sapi\quickstart\windows\cygwin-build\install-cygwin.bat
72+
6573
- name: Install re2c
74+
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
6675
run: |
6776
bash ./sapi/scripts/cygwin/install-re2c.sh
6877
6978
- name: Configure
79+
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
7080
run: |
7181
uname -a
7282
# git config --global --add safe.directory /cygdrive/d/a/swoole-cli/swoole-cli
@@ -75,6 +85,7 @@ jobs:
7585
bash ./sapi/scripts/cygwin/cygwin-config.sh
7686
7787
- name: Build
88+
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
7889
run: |
7990
bash ./sapi/scripts/cygwin/cygwin-build.sh
8091

docs/Cygwin.md

+31-7
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,43 @@
1212
1313
> 命令行同时安装多个包,包名之间使用逗号隔开
1414
15+
## windows 环境下 配置 git 环境
16+
17+
1. 禁止Git在提交和检出时进行换行符的自动转换‌
18+
2. 使用`lf` 作为换行符
19+
3. 区分大小写
20+
21+
```shell
22+
23+
# 下载git
24+
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
25+
26+
# 命令行静默安装 git
27+
start /wait .\Git-2.47.1-64-bit.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="C:\Program Files\Git"
28+
29+
30+
git config --global core.autocrlf false
31+
git config --global core.eol lf
32+
git config --global core.ignorecase false
33+
34+
```
35+
1536
## 安装cygwin 和 cygwin 依赖项
1637

17-
> 执行如下命令
38+
> 打开windows CMD 终端,进入项目目录 ,执行如下命令
1839
1940
```bash
2041

2142
# 自动安装 cygwin 和 cygwin 依赖项
22-
.\sapi\quickstart\windows\download-cygwin.bat
23-
.\sapi\quickstart\windows\install-cygwin.bat
43+
.\sapi\quickstart\windows\cygwin-build\download-cygwin.bat
44+
.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat
45+
2446

2547
```
2648

2749
构建步骤 - 执行的命令
2850
====
29-
> 运行如下步骤,需要先 打开 cygwin64 Terminal
51+
> 运行如下步骤,打开 cygwin64 Terminal, 并进入项目目录,执行如下命令
3052
3153
```shell
3254

@@ -122,14 +144,16 @@ libzstd-devel
122144

123145
## 安装 cygwin 和 安装 cygwin 依赖项 具体执行的命令
124146

125-
> `sapi\quickstart\windows\install-cygwin.bat` 脚本包含的内容
147+
> 多个包之间 使用逗号分隔
148+
149+
> 编辑修改此文件即可 `.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat`
126150
127151
```bash
128152
# 安装 cygwin
129-
setup-x86_64.exe --site https://mirrors.ustc.edu.cn/cygwin/
153+
setup-x86_64.exe --site https://mirrors.ustc.edu.cn/cygwin/
130154

131155
# 安装 cygwin 依赖项
132-
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
156+
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
133157

134158
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
135159

sapi/quickstart/windows/README.md sapi/quickstart/windows/cygwin-build/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# windows 快速准备构建环境
22

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

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

77
```shell
88

99
# 自动下载 cygwin
10-
sapi\quickstart\windows\download-cygwin.bat
11-
# 自动安装 cygwin
12-
sapi\quickstart\windows\install-cygwin.bat
10+
sapi\quickstart\windows\cygwin-build\download-cygwin.bat
11+
# 自动安装 依赖包
12+
sapi\quickstart\windows\cygwin-build\install-cygwin.bat
1313

1414

1515
```

sapi/quickstart/windows/download-cygwin.bat sapi/quickstart/windows/cygwin-build/download-cygwin.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ setlocal
77

88
echo %~dp0
99
cd /d %~dp0
10-
cd /d ..\..\..\
10+
cd /d ..\..\..\..\
1111

1212
set "__PROJECT__=%cd%"
1313
echo %cd%
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@echo off
2+
3+
:: cygwin site: https://cygwin.com/
4+
:: start https://cygwin.com/setup-x86_64.exe
5+
6+
setlocal enableextensions enabledelayedexpansion
7+
8+
echo %~dp0
9+
cd /d %~dp0
10+
cd /d ..\..\..\..\
11+
12+
set "__PROJECT__=%cd%"
13+
cd /d %__PROJECT__%\
14+
echo %cd%
15+
:: package separate with commas
16+
17+
18+
set SITE="https://mirrors.kernel.org/sourceware/cygwin/"
19+
20+
:getopt
21+
if /i "%1" equ "--mirror" (
22+
if /i "%2" equ "china" (
23+
set SITE="https://mirrors.ustc.edu.cn/cygwin/"
24+
)
25+
)
26+
shift
27+
28+
if not (%1)==() goto getopt
29+
30+
if "%GITHUB_ACTIONS%"=="" (
31+
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site %SITE%
32+
)
33+
34+
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
35+
36+
setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages zip unzip
37+
38+
setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libpq5 libpq-devel
39+
40+
setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libzstd-devel
41+
42+
endlocal

sapi/quickstart/windows/install-cygwin.bat

-24
This file was deleted.

sapi/scripts/cygwin/cygwin-build.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,18 @@ cd ${__PROJECT__}
1313

1414
mkdir -p bin/.libs
1515
# export LDFLAGS="-all-static"
16-
make -j $(nproc)
16+
LOGICAL_PROCESSORS=$(nproc)
17+
18+
set +u
19+
if [ -n "${GITHUB_ACTION}" ]; then
20+
if test $LOGICAL_PROCESSORS -ge 4; then
21+
LOGICAL_PROCESSORS=$((LOGICAL_PROCESSORS - 2))
22+
fi
23+
make
24+
# make -j $LOGICAL_PROCESSORS
25+
else
26+
make -j $LOGICAL_PROCESSORS
27+
fi
28+
set -u
29+
1730
./bin/swoole-cli -v

sapi/scripts/cygwin/install-cygwin.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ while [ $# -gt 0 ]; do
4242
shift $(($# > 0 ? 1 : 0))
4343
done
4444

45-
# 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
45+
# 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
4646
#setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://mirrors.ustc.edu.cn/cygwin/ --packages
4747

48-
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
48+
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
4949
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages zip unzip icu libicu-devel
5050
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages libpq5 libpq-devel
5151
setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages libzstd-devel

0 commit comments

Comments
 (0)