Skip to content

Commit c8525dc

Browse files
committed
Build and test AArch64 Cygwin using Ubuntu cross-toolchain on WSL runner
1 parent 74c9fbe commit c8525dc

1 file changed

Lines changed: 76 additions & 12 deletions

File tree

.github/workflows/cygwin.yml

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,58 @@ jobs:
9696
matrix:
9797
include:
9898
- arch: aarch64
99-
runner: ubuntu-24.04-arm
10099

101-
runs-on: ${{ matrix.runner }}
100+
runs-on: [
101+
Windows,
102+
WSL,
103+
ARM64
104+
]
102105
name: Ubuntu cross ${{ matrix.arch }}-pc-cygwin
103106

107+
defaults:
108+
run:
109+
shell: wsl --user runner bash --noprofile --norc -euo pipefail "$(s="$(wslpath '{0}')" && sed -i 's/\r$//' "$s" && echo "$s")"
110+
104111
env:
105112
GH_TOKEN: ${{ github.token }}
113+
WSLENV: CYGWIN:GH_TOKEN:GITHUB_ENV/p:GITHUB_OUTPUT/p:GITHUB_STEP_SUMMARY/p
106114

107115
steps:
108-
- uses: actions/checkout@v3
116+
# prepare non-ephemeral runner environment
117+
- name: Prepare environment
118+
run: |
119+
if (Test-Path -Path newlib-cygwin) {
120+
Remove-Item -Recurse -Force newlib-cygwin
121+
}
122+
if (Test-Path -Path *-msvcrt-toolchain.tar.gz) {
123+
Remove-Item -Recurse -Force *-msvcrt-toolchain.tar.gz
124+
}
125+
if (Test-Path -Path toolchain) {
126+
Remove-Item -Recurse -Force toolchain
127+
}
128+
if (Test-Path -Path build) {
129+
Remove-Item -Recurse -Force build
130+
}
131+
if (Test-Path -Path install) {
132+
Remove-Item -Recurse -Force install
133+
}
134+
shell: powershell
109135

110136
# install build tools
111137
- name: Install build tools
112138
run: |
113-
sudo apt-get update
114-
sudo apt-get install -y \
139+
sudo apt update
140+
sudo apt install -y \
115141
autoconf \
116142
automake \
143+
binutils \
144+
bzip2 \
117145
dblatex \
118146
docbook2x \
119147
docbook-xsl \
120148
gawk \
149+
gcc \
150+
g++ \
121151
gh \
122152
make \
123153
openssh-client \
@@ -128,6 +158,11 @@ jobs:
128158
python3-ply \
129159
xmlto
130160
161+
# checkout
162+
- name: Checkout
163+
run: |
164+
git clone https://github.com/${{ github.repository }} -b ${{ github.ref_name }}
165+
131166
# download toolchain
132167
- name: Download toolchain
133168
run: |
@@ -146,21 +181,50 @@ jobs:
146181
# build
147182
- name: Configure, build and install
148183
run: |
149-
export PATH="$PATH:${{ github.workspace }}/toolchain/${{ matrix.arch }}-w64-mingw32/bin:${{ github.workspace }}/toolchain/${{ matrix.arch }}-pc-cygwin/bin"
150-
export CXXFLAGS_FOR_TARGET="-D_WIN64 -I${{ github.workspace }}/toolchain/${{ matrix.arch }}-pc-cygwin/include"
151-
export LDFLAGS_FOR_TARGET="-L${{ github.workspace }}/toolchain/${{ matrix.arch }}-pc-cygwin/lib"
152-
export MINGW_CPPFLAGS="-I${{ github.workspace }}/toolchain/${{ matrix.arch }}-w64-mingw32/include"
153-
export MINGW_LDFLAGS="-L${{ github.workspace }}/toolchain/${{ matrix.arch }}-w64-mingw32/lib"
184+
WORKSPACE=$(realpath $(pwd))
185+
export PATH="$PATH:$WORKSPACE/build/${{ matrix.arch }}-pc-cygwin/winsup/testsuite/testinst/bin:$WORKSPACE/toolchain/${{ matrix.arch }}-w64-mingw32/bin:$WORKSPACE/toolchain/${{ matrix.arch }}-pc-cygwin/bin"
186+
export CXXFLAGS_FOR_TARGET="-D_WIN64 -I$WORKSPACE/toolchain/${{ matrix.arch }}-pc-cygwin/include"
187+
export LDFLAGS_FOR_TARGET="-L$WORKSPACE/toolchain/${{ matrix.arch }}-pc-cygwin/lib"
188+
export MINGW_CPPFLAGS="-I$WORKSPACE/toolchain/${{ matrix.arch }}-w64-mingw32/include"
189+
export MINGW_LDFLAGS="-L$WORKSPACE/toolchain/${{ matrix.arch }}-w64-mingw32/lib"
154190
export MAKEFLAGS="V=1 -j$(nproc)"
191+
export CYGWIN=winsymlinks:sys
155192
156193
mkdir build install
157-
(cd winsup && ./autogen.sh)
158-
(cd build && ../configure --target=${{ matrix.arch }}-pc-cygwin --prefix=$(realpath $(pwd)/../install) )
194+
(cd newlib-cygwin/winsup && ./autogen.sh)
195+
(cd build && ../newlib-cygwin/configure --target=${{ matrix.arch }}-pc-cygwin --prefix=$(realpath $(pwd)/../install) )
159196
make -C build
160197
make -C build/*/newlib info man
161198
make -C build install
162199
make -C build/*/newlib install-info install-man
163200
201+
# test
202+
- name: Test Cygwin
203+
continue-on-error: true
204+
run: |
205+
WORKSPACE=$(realpath $(pwd))
206+
export PATH="$PATH:$WORKSPACE/build/${{ matrix.arch }}-pc-cygwin/winsup/testsuite/testinst/bin:$WORKSPACE/toolchain/${{ matrix.arch }}-w64-mingw32/bin:$WORKSPACE/toolchain/${{ matrix.arch }}-pc-cygwin/bin"
207+
export CXXFLAGS_FOR_TARGET="-D_WIN64 -I$WORKSPACE/toolchain/${{ matrix.arch }}-pc-cygwin/include"
208+
export LDFLAGS_FOR_TARGET="-L$WORKSPACE/toolchain/${{ matrix.arch }}-pc-cygwin/lib"
209+
export MINGW_CPPFLAGS="-I$WORKSPACE/toolchain/${{ matrix.arch }}-w64-mingw32/include"
210+
export MINGW_LDFLAGS="-L$WORKSPACE/toolchain/${{ matrix.arch }}-w64-mingw32/lib"
211+
export CYGWIN=winsymlinks:sys
212+
213+
(cd build/${{ matrix.arch }}-pc-cygwin/winsup && WSLENV="$WSLENV:PATH/l" make V=1 check AM_COLOR_TESTS=always)
214+
215+
- name: Pack build folder
216+
if: failure()
217+
run: |
218+
tar -cjf build.tar.bz2 build/
219+
220+
- name: Upload build folder
221+
if: failure()
222+
uses: actions/upload-artifact@v4
223+
with:
224+
name: cygwin-build
225+
retention-days: 1
226+
path: build.tar.bz2
227+
164228
windows-build:
165229
runs-on: windows-latest
166230
strategy:

0 commit comments

Comments
 (0)