Skip to content

Commit 109568d

Browse files
committed
Build libjpeg-turbo, OpenSSL, OpenBLAS, and FFmpeg packages using MSYS2 MinGW toolchain
1 parent 23c43e5 commit 109568d

File tree

8 files changed

+176
-4
lines changed

8 files changed

+176
-4
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
pushd /
8+
patch -p1 -i `cygpath "$GITHUB_WORKSPACE"`/patches/makepkg/0001-cross-compilation.patch
9+
cat /etc/makepkg_mingw.conf
10+
cat /etc/profile
11+
cat /usr/share/makepkg/tidy/strip.sh
12+
popd

.github/workflows/build-package.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ on:
2121
description: "MSYS2 packages branch to build from"
2222
type: string
2323
default: "woarm64"
24+
cross_compile:
25+
description: "Use cross-compiler for the package build"
26+
type: boolean
27+
default: false
2428

2529
defaults:
2630
run:
@@ -53,10 +57,13 @@ jobs:
5357
git \
5458
mingw-w64-x86_64-github-cli \
5559
mingw-w64-x86_64-jq \
60+
${{ inputs.cross_compile && 'mingw-w64-cross-gcc' || '' }} \
5661
${{ inputs.dependencies }}
5762
58-
- name: Checkout repository
59-
uses: actions/checkout@v4
63+
- name: Setup cross-compilation environment
64+
if: ${{ inputs.cross_compile }}
65+
run: |
66+
`cygpath "${{ github.workspace }}"`/.github/scripts/setup-cross-compilation.sh
6067
6168
- name: Checkout ${{ inputs.packages_repository }} repository
6269
uses: actions/checkout@v4
@@ -83,7 +90,13 @@ jobs:
8390
- name: Build ${{ inputs.package_name }}
8491
working-directory: ${{ github.workspace }}/packages/${{ inputs.package_name }}
8592
run: |
86-
makepkg --syncdeps --rmdeps --cleanbuild --noconfirm --noprogressbar --nocheck --force
93+
if [[ "${{ inputs.packages_repository }}" == *MINGW* ]]; then
94+
command="makepkg-mingw"
95+
else
96+
command="makepkg"
97+
fi
98+
MINGW_ARCH=mingw64 \
99+
$command --syncdeps --rmdeps --cleanbuild --skippgpcheck --noconfirm --noprogressbar --nocheck --force
87100
88101
- name: Upload ${{ inputs.package_name }}
89102
uses: actions/upload-artifact@v4

.github/workflows/ffmpeg.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build MinGW FFmpeg using MSYS2 toolchain
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
mingw_packages_branch:
8+
description: "MINGW-packages branch to build"
9+
type: string
10+
required: false
11+
default: "woarm64"
12+
13+
jobs:
14+
mingw-w64-ffmpeg:
15+
uses: ./.github/workflows/build-package.yml
16+
with:
17+
package_name: mingw-w64-ffmpeg
18+
packages_repository: Windows-on-ARM-Experiments/MINGW-packages
19+
packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }}
20+
cross_compile: true
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build MinGW libjpeg-turbo using MSYS2 toolchain
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
mingw_packages_branch:
8+
description: "MINGW-packages branch to build"
9+
type: string
10+
required: false
11+
default: "woarm64"
12+
13+
jobs:
14+
mingw-w64-libjpeg-turbo:
15+
uses: ./.github/workflows/build-package.yml
16+
with:
17+
package_name: mingw-w64-libjpeg-turbo
18+
packages_repository: Windows-on-ARM-Experiments/MINGW-packages
19+
packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }}
20+
cross_compile: true

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
87
workflow_dispatch:
98
inputs:
109
msys2_packages_branch:

.github/workflows/openblas.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build MinGW OpenBLAS using MSYS2 toolchain
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
mingw_packages_branch:
8+
description: "MINGW-packages branch to build"
9+
type: string
10+
required: false
11+
default: "woarm64"
12+
13+
jobs:
14+
mingw-w64-openblas:
15+
uses: ./.github/workflows/build-package.yml
16+
with:
17+
package_name: mingw-w64-openblas
18+
packages_repository: Windows-on-ARM-Experiments/MINGW-packages
19+
packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }}
20+
cross_compile: true

.github/workflows/openssl.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build MinGW OpenSSL using MSYS2 toolchain
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
mingw_packages_branch:
8+
description: "MINGW-packages branch to build"
9+
type: string
10+
required: false
11+
default: "woarm64"
12+
13+
jobs:
14+
mingw-w64-openssl:
15+
uses: ./.github/workflows/build-package.yml
16+
with:
17+
package_name: mingw-w64-openssl
18+
packages_repository: Windows-on-ARM-Experiments/MINGW-packages
19+
packages_branch: ${{ github.event.inputs.mingw_packages_branch || 'woarm64' }}
20+
dependencies: mingw-w64-cross-zlib
21+
cross_compile: true
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
diff --git a/etc/makepkg_mingw.conf b/etc/makepkg_mingw.conf
2+
--- a/etc/makepkg_mingw.conf
3+
+++ b/etc/makepkg_mingw.conf
4+
@@ -34,15 +34,17 @@
5+
#
6+
7+
if [[ "$MSYSTEM" == "MINGW64" ]]; then
8+
- CARCH="x86_64"
9+
+ CARCH="aarch64"
10+
CHOST="x86_64-w64-mingw32"
11+
MINGW_CHOST="x86_64-w64-mingw32"
12+
MINGW_PREFIX="/mingw64"
13+
MINGW_PACKAGE_PREFIX="mingw-w64-x86_64"
14+
- CC="gcc"
15+
- CXX="g++"
16+
+ CC="aarch64-w64-mingw32-gcc"
17+
+ CXX="aarch64-w64-mingw32-g++"
18+
+ STRIP="aarch64-w64-mingw32-strip"
19+
+ OBJDUMP="aarch64-w64-mingw32-objdump"
20+
CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1"
21+
- CFLAGS="-march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong"
22+
+ CFLAGS="-O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong"
23+
CXXFLAGS="$CFLAGS"
24+
LDFLAGS=""
25+
elif [[ "$MSYSTEM" == "MINGW32" ]]; then
26+
diff --git a/etc/profile b/etc/profile
27+
--- a/etc/profile
28+
+++ b/etc/profile
29+
@@ -49,7 +49,7 @@
30+
case "${MSYSTEM}" in
31+
MINGW*|CLANG*|UCRT*)
32+
MINGW_MOUNT_POINT="${MINGW_PREFIX}"
33+
- PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
34+
+ PATH="/opt/bin:${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}${ORIGINAL_PATH:+:${ORIGINAL_PATH}}"
35+
PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
36+
PKG_CONFIG_SYSTEM_INCLUDE_PATH="${MINGW_MOUNT_POINT}/include"
37+
PKG_CONFIG_SYSTEM_LIBRARY_PATH="${MINGW_MOUNT_POINT}/lib"
38+
diff --git a/usr/share/makepkg/tidy/strip.sh b/usr/share/makepkg/tidy/strip.sh
39+
--- a/usr/share/makepkg/tidy/strip.sh
40+
+++ b/usr/share/makepkg/tidy/strip.sh
41+
@@ -85,7 +85,7 @@
42+
strip_file(){
43+
local binary=$1; shift
44+
local tempfile=$(mktemp "$binary.XXXXXX")
45+
- if strip "$@" "$binary" -o "$tempfile"; then
46+
+ if $STRIP "$@" "$binary" -o "$tempfile"; then
47+
cat "$tempfile" > "$binary"
48+
fi
49+
rm -f "$tempfile"
50+
@@ -95,7 +95,7 @@
51+
local binary=$1;
52+
53+
local tempfile=$(mktemp "$binary.XXXXXX")
54+
- if strip -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1 "$binary" -o "$tempfile"; then
55+
+ if $STRIP -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1 "$binary" -o "$tempfile"; then
56+
cat "$tempfile" > "$binary"
57+
fi
58+
rm -f "$tempfile"
59+
@@ -176,7 +176,7 @@
60+
case "${binary##*/}" in
61+
*.dll|*.exe|*.sfx|*.so|*.so.[0-9]*|*.oct|*.cmxs) ;;
62+
# make sure this isn't some oddly named DLL
63+
- *) if LANG=en_US.UTF-8 LC_ALL=C objdump -f "${binary}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0'
64+
+ *) if LANG=en_US.UTF-8 LC_ALL=C $OBJDUMP -f "${binary}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0'
65+
then
66+
mv "${binary}" "${binary}.exe"
67+
binary+=.exe

0 commit comments

Comments
 (0)