Skip to content

Commit fc662a5

Browse files
committed
Build and deploy native MinGW toolchain packages together with cross-compilation one.
1 parent 83f80ed commit fc662a5

30 files changed

+1073
-209
lines changed

.github/scripts/build-hello-world.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/bash
22

3-
set -e # exit on error
4-
set -x # echo on
5-
set -o pipefail # fail of any command in pipeline is an error
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
64

75
# Sanity check of the GCC binary and its version.
86
aarch64-w64-mingw32-gcc --version

.github/scripts/build-package.sh

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
#!/bin/bash
22

3-
set -e # exit on error
4-
set -x # echo on
5-
set -o pipefail # fail of any command in pipeline is an error
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
64

75
PACKAGE_REPOSITORY=$1
86

9-
CLEAN_BUILD=${CLEAN_BUILD:-0}
10-
INSTALL_PACKAGE=${INSTALL_PACKAGE:-0}
11-
NO_EXTRACT=${NO_EXTRACT:-0}
12-
137
ARGUMENTS="--syncdeps \
148
--rmdeps \
159
--noconfirm \
@@ -21,12 +15,22 @@ ARGUMENTS="--syncdeps \
2115
$([ "$CLEAN_BUILD" = 1 ] && echo "--cleanbuild" || echo "") \
2216
$([ "$INSTALL_PACKAGE" = 1 ] && echo "--install" || echo "")"
2317

24-
ccache -svv || true
25-
26-
if [[ "$PACKAGE_REPOSITORY" == *MINGW* ]]; then
27-
makepkg-mingw $ARGUMENTS
28-
else
29-
makepkg $ARGUMENTS
18+
if command -v ccache &> /dev/null; then
19+
echo "::group::Ccache statistics before build"
20+
ccache -svv || true
21+
echo "::endgroup::"
3022
fi
3123

32-
ccache -svv || true
24+
echo "::group::Build package"
25+
if [[ "$PACKAGE_REPOSITORY" == *MINGW* ]]; then
26+
makepkg-mingw $ARGUMENTS
27+
else
28+
makepkg $ARGUMENTS
29+
fi
30+
echo "::endgroup::"
31+
32+
if command -v ccache &> /dev/null; then
33+
echo "::group::Ccache statistics after build"
34+
ccache -svv || true
35+
echo "::endgroup::"
36+
fi

.github/scripts/clean-cross.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
4+
5+
for ENV in "common" "mingw32" "mingw64" "ucrt64" "mingwarm64"; do
6+
PACKAGES=" \
7+
mingw-w64-cross-$ENV-zlib \
8+
mingw-w64-cross-$ENV-gcc \
9+
mingw-w64-cross-$ENV-winpthreads \
10+
mingw-w64-cross-$ENV-crt \
11+
mingw-w64-cross-$ENV-windows-default-manifest \
12+
mingw-w64-cross-$ENV-gcc-stage1 \
13+
mingw-w64-cross-$ENV-binutils \
14+
mingw-w64-cross-$ENV-headers"
15+
16+
for PACKAGE in $PACKAGES; do
17+
pacman -R --noconfirm --cascade $PACKAGE || true
18+
done
19+
done

.github/scripts/clean-native.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
4+
5+
for ARCH in "aarch64" "x86_64"; do
6+
PACKAGES=" \
7+
mingw-w64-$ARCH-gcc \
8+
mingw-w64-$ARCH-windows-default-manifest \
9+
mingw-w64-$ARCH-binutils \
10+
mingw-w64-$ARCH-libwinpthread-git
11+
mingw-w64-$ARCH-winpthreads-git \
12+
mingw-w64-$ARCH-crt-git \
13+
mingw-w64-$ARCH-headers-git \
14+
mingw-w64-$ARCH-tools-git \
15+
mingw-w64-$ARCH-libmangle-git \
16+
mingw-w64-$ARCH-mpc \
17+
mingw-w64-$ARCH-isl \
18+
mingw-w64-$ARCH-mpfr \
19+
mingw-w64-$ARCH-gmp \
20+
mingw-w64-$ARCH-zstd \
21+
mingw-w64-$ARCH-ninja \
22+
mingw-w64-$ARCH-zlib \
23+
mingw-w64-$ARCH-bzip2 \
24+
mingw-w64-$ARCH-ncurses \
25+
mingw-w64-$ARCH-gettext \
26+
mingw-w64-$ARCH-libsystre \
27+
mingw-w64-$ARCH-libtre \
28+
mingw-w64-$ARCH-libiconv \
29+
mingw-w64-$ARCH-gperf \
30+
autotools-wrappers \
31+
mingw-w64-$ARCH-autotools \
32+
mingw-w64-$ARCH-pkgconf \
33+
mingw-w64-$ARCH-libtool"
34+
35+
for PACKAGE in $PACKAGES; do
36+
pacman -R --noconfirm --cascade $PACKAGE || true
37+
done
38+
done
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
4+
5+
echo "::group::Create MSYS2 packages repository"
6+
mkdir -p repository/x86_64
7+
mv -f mingw-w64-cross-*.pkg.* repository/x86_64/
8+
pushd repository/x86_64
9+
repo-add woarm64.db.tar.gz *.pkg.*
10+
popd
11+
12+
mkdir -p repository/aarch64
13+
mv -f mingw-w64-aarch64-*.pkg.* repository/aarch64/
14+
pushd repository/aarch64
15+
repo-add woarm64-native.db.tar.gz *.pkg.*
16+
popd
17+
echo "::endgroup::"
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

3-
set -e # exit on error
4-
set -x # echo on
5-
set -o pipefail # fail of any command in pipeline is an error
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
64

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

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

.github/scripts/enable-ccache.sh

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
11
#!/bin/bash
22

3-
set -e # exit on error
4-
set -x # echo on
5-
set -o pipefail # fail of any command in pipeline is an error
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
64

75
DIR="`dirname ${BASH_SOURCE[0]}`/../.."
86
DIR=`realpath $DIR`
7+
CCACHE_DIR=$DIR/ccache
98
if [[ -n "$GITHUB_WORKSPACE" ]]; then
10-
echo "CCACHE_DIR=$DIR/ccache" >> "$GITHUB_ENV"
9+
echo "CCACHE_DIR=$CCACHE_DIR" >> "$GITHUB_ENV"
1110
echo timestamp=$(date -u --iso-8601=seconds) >> "$GITHUB_OUTPUT"
1211
fi
1312

13+
apply_patch () {
14+
if patch -R -p1 --dry-run -b -i "$1" > /dev/null 2>&1; then
15+
echo "Patch $1 is already applied"
16+
else
17+
patch -p1 -b -i "$1"
18+
fi
19+
}
20+
21+
mkdir -p $CCACHE_DIR
22+
1423
pushd /
1524
echo "::group::/etc/makepkg.conf"
16-
patch -p1 -b -i "$DIR/patches/ccache/0001-makepkg.patch"
25+
apply_patch "$DIR/patches/ccache/0001-makepkg.patch"
1726
cat /etc/makepkg.conf
1827
echo "::endgroup::"
1928

2029
echo "::group::/etc/makepkg_mingw.conf"
21-
patch -p1 -b -i "$DIR/patches/ccache/0002-makepkg-mingw.patch"
30+
apply_patch "$DIR/patches/ccache/0002-makepkg-mingw.patch"
2231
cat /etc/makepkg_mingw.conf
2332
echo "::endgroup::"
2433
popd
34+
35+
pacman -S --noconfirm ccache
36+
37+
pushd /usr/lib/ccache/bin
38+
echo "::group::Add aarch64 toolchain to ccache"
39+
export MSYS=winsymlinks
40+
ln -sf /usr/bin/ccache aarch64-w64-mingw32-c++
41+
ln -sf /usr/bin/ccache aarch64-w64-mingw32-g++
42+
ln -sf /usr/bin/ccache aarch64-w64-mingw32-gcc
43+
if [[ "$FLAVOR" = "CROSS" ]]; then
44+
ln -sf /usr/bin/true makeinfo
45+
fi
46+
echo "::endgroup::"
47+
popd
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
set -e # exit on error
4-
set -x # echo on
5-
set -o pipefail # fail of any command in pipeline is an error
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
64

75
pacman -U --noconfirm *.pkg.tar.zst
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
4+
5+
DEPENDENCIES=$1
6+
7+
case $FLAVOR in
8+
"CROSS")
9+
pacman -S --noconfirm \
10+
git \
11+
base-devel \
12+
$DEPENDENCIES
13+
;;
14+
"NATIVE_WITH_CROSS")
15+
pacman -S --noconfirm \
16+
git \
17+
base-devel \
18+
mingw-w64-cross-mingwarm64-gcc \
19+
mingw-w64-cross-mingwarm64-windows-default-manifest \
20+
mingw-w64-x86_64-gcc-libs \
21+
$DEPENDENCIES
22+
;;
23+
"NATIVE_WITH_NATIVE")
24+
pacman -S --noconfirm \
25+
git \
26+
base-devel \
27+
mingw-w64-aarch64-gcc \
28+
$DEPENDENCIES
29+
;;
30+
*)
31+
echo "Unknown flavor: $FLAVOR"
32+
exit 1
33+
;;
34+
esac

.github/scripts/pthread-headers-hack-after.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/bash
22

3-
set -e # exit on error
4-
set -x # echo on
5-
set -o pipefail # fail of any command in pipeline is an error
3+
source `dirname ${BASH_SOURCE[0]}`/../../config.sh
64

75
pacman -R --noconfirm mingw-w64-cross-mingw64-winpthreads || true
86
rm -rf /opt/aarch64-w64-mingw32/include/pthread_signal.h

0 commit comments

Comments
 (0)