Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化 cygwin 构建环境 #893

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/windows-cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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/
Expand All @@ -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
Expand All @@ -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

Expand Down
38 changes: 31 additions & 7 deletions docs/Cygwin.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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


```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ setlocal

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

set "__PROJECT__=%cd%"
echo %cd%
Expand Down
42 changes: 42 additions & 0 deletions sapi/quickstart/windows/cygwin-build/install-cygwin.bat
Original file line number Diff line number Diff line change
@@ -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
24 changes: 0 additions & 24 deletions sapi/quickstart/windows/install-cygwin.bat

This file was deleted.

15 changes: 14 additions & 1 deletion sapi/scripts/cygwin/cygwin-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions sapi/scripts/cygwin/install-cygwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading