Skip to content

Commit 718fca9

Browse files
committed
Build native MinGW toolchain packages
1 parent 916a5c8 commit 718fca9

18 files changed

+854
-125
lines changed

.github/scripts/build-package.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ ARGUMENTS="--syncdeps \
2121
$([ "$CLEAN_BUILD" = 1 ] && echo "--cleanbuild" || echo "") \
2222
$([ "$INSTALL_PACKAGE" = 1 ] && echo "--install" || echo "")"
2323

24-
ccache -svv || true
24+
echo "::group::Ccache statistics before build"
25+
ccache -svv || true
26+
echo "::endgroup::"
2527

26-
if [[ "$PACKAGE_REPOSITORY" == *MINGW* ]]; then
27-
makepkg-mingw $ARGUMENTS
28-
else
29-
makepkg $ARGUMENTS
30-
fi
28+
echo "::group::Build package"
29+
if [[ "$PACKAGE_REPOSITORY" == *MINGW* ]]; then
30+
makepkg-mingw $ARGUMENTS
31+
else
32+
makepkg $ARGUMENTS
33+
fi
34+
echo "::endgroup::"
3135

32-
ccache -svv || true
36+
echo "::group::Ccache statistics after build"
37+
ccache -svv || true
38+
echo "::endgroup::"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e # exit on error
4+
set -x # echo on
5+
set -o pipefail # fail of any command in pipeline is an error
6+
7+
echo "::group::Create x86_64 packages repository"
8+
mkdir -p x86_64
9+
mv -f *-x86_64.pkg.tar.zst x86_64/
10+
pushd x86_64
11+
repo-add woarm64.db.tar.gz *.pkg.tar.zst
12+
popd
13+
echo "::endgroup::"
14+
15+
echo "::group::Create aarch64 packages repository"
16+
mkdir aarch64
17+
mv -f *-aarch64.pkg.tar.zst aarch64/
18+
pushd x86_64
19+
repo-add woarm64.db.tar.gz *.pkg.tar.zst
20+
popd
21+
echo "::endgroup::"

.github/scripts/download-artifacts.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ set -x # echo on
55
set -o pipefail # fail of any command in pipeline is an error
66

77
RUN_ID=$1
8-
NEEDS=`echo "$2" | /mingw64/bin/jq 'keys|join(" ")' | sed 's/"//g'`
98

10-
for NEED in $NEEDS; do
11-
echo "Downloading $NEED artifact."
12-
/mingw64/bin/gh run download $RUN_ID -n $NEED
9+
for ARG in "${@:2}"; do
10+
NEEDS=`echo "$ARG" | /mingw64/bin/jq 'keys|join(" ")' | sed 's/"//g'`
11+
for NEED in $NEEDS; do
12+
echo "Downloading $NEED artifact."
13+
/mingw64/bin/gh run download $RUN_ID -n $NEED
14+
done
1315
done

.github/scripts/enable-ccache.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ set -o pipefail # fail of any command in pipeline is an error
66

77
DIR="`dirname ${BASH_SOURCE[0]}`/../.."
88
DIR=`realpath $DIR`
9+
CCACHE_DIR=$DIR/ccache
910
if [[ -n "$GITHUB_WORKSPACE" ]]; then
10-
echo "CCACHE_DIR=$DIR/ccache" >> "$GITHUB_ENV"
11+
echo "CCACHE_DIR=$CCACHE_DIR" >> "$GITHUB_ENV"
1112
echo timestamp=$(date -u --iso-8601=seconds) >> "$GITHUB_OUTPUT"
1213
fi
1314

15+
mkdir -p $CCACHE_DIR
16+
1417
pushd /
1518
echo "::group::/etc/makepkg.conf"
1619
patch -p1 -b -i "$DIR/patches/ccache/0001-makepkg.patch"
@@ -22,3 +25,15 @@ pushd /
2225
cat /etc/makepkg_mingw.conf
2326
echo "::endgroup::"
2427
popd
28+
29+
pacman -S --noconfirm ccache
30+
31+
pushd /usr/lib/ccache/bin
32+
echo "::group::Add aarch64 toolchain to ccache"
33+
export MSYS=winsymlinks
34+
ln -sf /usr/bin/ccache aarch64-w64-mingw32-c++
35+
ln -sf /usr/bin/ccache aarch64-w64-mingw32-g++
36+
ln -sf /usr/bin/ccache aarch64-w64-mingw32-gcc
37+
ln -sf /usr/bin/true makeinfo
38+
echo "::endgroup::"
39+
popd
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -e # exit on error
4+
set -x # echo on
5+
set -o pipefail # fail of any command in pipeline is an error
6+
7+
if [ -z "$GITHUB_WORKSPACE" ]; then
8+
DIR=`pwd`
9+
else
10+
DIR=`cygpath "$GITHUB_WORKSPACE"`
11+
fi
12+
13+
echo "::group::Pacman hang workaround"
14+
while ! timeout -k 15s 10s pacman -U --noconfirm "$DIR/patches/pacman/pacman-6.1.0-4-x86_64.pkg.tar.zst"
15+
do
16+
echo "Command failed, retrying..."
17+
done
18+
echo "::endgroup::"
19+
20+
echo "::group::Install patch"
21+
pacman -S --noconfirm patch
22+
echo "::endgroup::"
23+
24+
pushd /
25+
echo "::group::Pin pacman packages"
26+
patch -p1 -b -i "$DIR/patches/pacman/0001-pin-packages.patch"
27+
echo "::endgroup::"
28+
29+
echo "::group::/etc/pacman.conf"
30+
cat /etc/pacman.conf
31+
echo "::endgroup::"
32+
popd
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
set -e # exit on error
4+
set -x # echo on
5+
set -o pipefail # fail of any command in pipeline is an error
6+
7+
if [ -z "$GITHUB_WORKSPACE" ]; then
8+
DIR=`pwd`
9+
else
10+
DIR=`cygpath "$GITHUB_WORKSPACE"`
11+
fi
12+
13+
echo "::group::Install patch"
14+
pacman -S --noconfirm patch
15+
echo "::endgroup::"
16+
17+
pushd /
18+
echo "::group::Patch MSYS2 environment"
19+
patch -p1 -b -i "$DIR/patches/makepkg/0001-mingwarm64.patch"
20+
if [[ "$DEBUG" = "1" ]]; then
21+
patch -p1 -b -i "$DIR/patches/makepkg/0002-enable-debug.patch"
22+
fi
23+
echo "::endgroup::"
24+
25+
echo "::group::/etc/makepkg_mingw.conf"
26+
cat /etc/makepkg_mingw.conf
27+
echo "::endgroup::"
28+
29+
echo "::group::/etc/profile"
30+
cat /etc/profile
31+
echo "::endgroup::"
32+
33+
echo "::group::/usr/share/makepkg/tidy/strip.sh"
34+
cat /usr/share/makepkg/tidy/strip.sh
35+
echo "::endgroup::"
36+
popd

.github/workflows/build-package.yml

Lines changed: 86 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ on:
66
package_name:
77
description: "Package name to build"
88
type: string
9-
needs:
10-
description: "Parent workflow job dependencies"
11-
type: string
12-
dependencies:
13-
description: "Install additional dependencies"
14-
type: string
15-
default: ""
169
packages_repository:
1710
description: "MSYS2 packages repository to build from"
1811
type: string
@@ -21,37 +14,111 @@ on:
2114
description: "MSYS2 packages branch to build from"
2215
type: string
2316
default: "woarm64"
17+
runner_arch:
18+
description: "Architecture to build on"
19+
type: string
20+
default: "x86_64"
21+
needs:
22+
description: "Parent workflow job dependencies"
23+
type: string
24+
dependencies:
25+
description: "Install additional dependencies"
26+
type: string
27+
default: ""
2428

2529
defaults:
2630
run:
2731
shell: msys2 {0}
2832

2933
env:
3034
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
CLEAN_BUILD: 1
3136

3237
jobs:
3338
build:
3439
name: Build ${{ inputs.package_name }}
35-
runs-on: windows-latest
40+
runs-on: >-
41+
${{ fromJson(inputs.runner_arch == 'aarch64'
42+
&& '["Windows", "ARM64", "Blackhex"]'
43+
|| '["windows-latest"]') }}
3644
3745
steps:
38-
- uses: msys2/setup-msys2@v2
46+
- name: Kill hanging processes
47+
if: ${{ inputs.runner_arch == 'aarch64' }}
48+
shell: powershell
49+
run: |
50+
tasklist
51+
taskkill /F /FI 'MODULES eq msys-2.0.dll'
52+
tasklist
53+
Set-Location "${{ github.workspace }}"
54+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path packages
55+
exit 0
56+
57+
- name: Fix Git long paths
58+
if: ${{ inputs.runner_arch == 'aarch64' }}
59+
shell: powershell
60+
run: |
61+
git config --global core.longpaths true
62+
63+
- name: Fix $PATH
64+
if: ${{ inputs.runner_arch == 'aarch64' }}
65+
shell: powershell
66+
run: |
67+
Write-Output "GITHUB_PATH: $env:GITHUB_PATH"
68+
Write-Output "C:\Program Files\Git\usr\bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
69+
70+
- uses: Windows-on-ARM-Experiments/setup-msys2@main
71+
timeout-minutes: 10
3972
with:
40-
msystem: ${{ contains(inputs.packages_repository, 'MINGW') && 'MINGW64' || 'MSYS' }}
41-
update: true
42-
cache: true
73+
msystem: >-
74+
${{ contains(inputs.packages_repository, 'MINGW')
75+
&& ((inputs.runner_arch == 'aarch64') && 'MINGWARM64' || 'MINGW64')
76+
|| 'MSYS' }}
77+
update: ${{ inputs.runner_arch == 'x86_64' }}
78+
cache: ${{ inputs.runner_arch == 'x86_64' }}
4379

4480
- name: Checkout repository
4581
uses: actions/checkout@v4
4682

83+
- name: Checkout ${{ inputs.packages_repository }} repository
84+
uses: actions/checkout@v4
85+
with:
86+
repository: ${{ inputs.packages_repository }}
87+
ref: ${{ inputs.packages_branch }}
88+
sparse-checkout: ${{ inputs.package_name }}
89+
path: ${{ github.workspace }}/packages
90+
91+
- name: Pacman hang workaround
92+
if: ${{ inputs.runner_arch == 'aarch64' }}
93+
run: |
94+
`cygpath "${{ github.workspace }}"`/.github/scripts/pacman-workaround.sh
95+
96+
- name: First MSYS2 update
97+
if: ${{ inputs.runner_arch == 'aarch64' }}
98+
shell: powershell
99+
run: |
100+
msys2 -c 'pacman -Syuu --noconfirm'
101+
exit 0
102+
103+
- name: Second MSYS2 update
104+
if: ${{ inputs.runner_arch == 'aarch64' }}
105+
shell: powershell
106+
run: |
107+
msys2 -c 'pacman -Syuu --noconfirm'
108+
109+
- name: Setup packages repository
110+
if: ${{ inputs.runner_arch == 'aarch64' }}
111+
run: |
112+
`cygpath "${{ github.workspace }}"`/.github/scripts/setup-repository.sh
113+
47114
- name: Install dependencies
48115
run: |
49116
pacman -S --noconfirm \
50117
git \
51118
mingw-w64-x86_64-github-cli \
52119
mingw-w64-x86_64-jq \
53120
base-devel \
54-
${{ contains(inputs.packages_repository, 'MINGW') && 'mingw-w64-cross-gcc mingw-w64-x86_64-ccache' || ' ccache' }} \
121+
${{ contains(inputs.packages_repository, 'MINGW') && 'mingw-w64-cross-mingwarm64-gcc mingw-w64-cross-mingwarm64-windows-default-manifest mingw-w64-x86_64-gcc-libs' || '' }} \
55122
${{ inputs.dependencies }}
56123
57124
- name: Download artifacts
@@ -69,21 +136,18 @@ jobs:
69136
run: |
70137
`cygpath "${{ github.workspace }}"`/.github/scripts/pthread-headers-hack-before.sh
71138
72-
- name: Checkout ${{ inputs.packages_repository }} repository
73-
uses: actions/checkout@v4
74-
with:
75-
repository: ${{ inputs.packages_repository }}
76-
ref: ${{ inputs.packages_branch }}
77-
sparse-checkout: ${{ inputs.package_name }}
78-
path: ${{ github.workspace }}/packages
139+
- name: Setup MINGWARM64 environment
140+
if: ${{ inputs.runner_arch == 'aarch64' }}
141+
run: |
142+
`cygpath "${{ github.workspace }}"`/.github/scripts/setup-mingwarm64.sh
79143
80144
- name: Enable Ccache
81145
id: enable-ccache
82146
run: |
83147
`cygpath "${{ github.workspace }}"`/.github/scripts/enable-ccache.sh
84148
85149
- name: Restore Ccache
86-
uses: actions/cache/restore@v4
150+
uses: actions/cache/restore@v4
87151
with:
88152
path: ${{ github.workspace }}/ccache
89153
key: main-ccache-${{ steps.enable-ccache.outputs.timestamp }}
@@ -92,13 +156,11 @@ jobs:
92156
- name: Build ${{ inputs.package_name }}
93157
working-directory: ${{ github.workspace }}/packages/${{ inputs.package_name }}
94158
run: |
95-
ccache -svv || true
96159
`cygpath "${{ github.workspace }}"`/.github/scripts/build-package.sh ${{ inputs.packages_repository }}
97-
ccache -svv || true
98160
99161
- name: Save Ccache
100162
if: always()
101-
uses: actions/cache/save@v4
163+
uses: actions/cache/save@v4
102164
with:
103165
path: ${{ github.workspace }}/ccache
104166
key: main-ccache-${{ steps.enable-ccache.outputs.timestamp }}

0 commit comments

Comments
 (0)