Skip to content

Test

Test #292

Workflow file for this run

name: Build
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- { icon: '🟦', sys: mingw64, mode: dynamic, cross: false }
- { icon: '🟦', sys: mingw64, mode: static, cross: false }
- { icon: '🟨', sys: ucrt64, mode: dynamic, cross: false }
- { icon: '🟨', sys: ucrt64, mode: static, cross: false }
- { icon: '🟧', sys: clang64, mode: dynamic, cross: false }
- { icon: '🟧', sys: clang64, mode: static, cross: false }
- { icon: '🟧', sys: clang64, mode: dynamic, cross: true, cross_arch: aarch64 }
- { icon: '🟧', sys: clang64, mode: static, cross: true, cross_arch: aarch64 }
env:
dynamic_flags: '--enable-gtk'
static_flags: '--disable-gtk --disable-spice --disable-usb-redir --disable-smartcard --disable-gnutls --disable-libssh --static'
static_extra_cflags: '-DCURL_STATICLIB -DLIBSSH_STATIC -DLIBSLIRP_STATIC -DCAIRO_WIN32_STATIC_BUILD'
clang_extra_cflags: '-Wno-missing-prototypes -Wno-sometimes-uninitialized -Wno-pragma-pack'
clang_cross_flags: '--cross-prefix="aarch64-w64-mingw32-"'
clang_dynamic_flags: '--disable-plugins'
name: ${{ format('🚧{0} {1} Build {2} {3}', matrix.icon, matrix.sys, matrix.mode, matrix.cross && matrix.cross_arch || '') }}
defaults:
run:
shell: msys2 {0}
steps:
- name: '🧰 Checkout'
uses: actions/checkout@main
- name: '${{ matrix.icon }} Setup MSYS2'
uses: msys2/setup-msys2@v2
env:
library_prefix: ${{ (matrix.cross && matrix.cross_arch == 'aarch64') && 'a' || 'p' }}
with:
msystem: ${{ matrix.sys }}
update: true
install: >-
git
make
bison
diffutils
flex
base-devel
python
python-setuptools
pacboy: >-
toolchain:p
toolchain:${{ env.library_prefix }}
binutils:${{ env.library_prefix }}
capstone:${{ env.library_prefix }}
ccache:${{ env.library_prefix }}
curl:${{ env.library_prefix }}
cyrus-sasl:${{ env.library_prefix }}
dtc:${{ env.library_prefix }}
gcc:${{ env.library_prefix }}
glib2:${{ env.library_prefix }}
gnutls:${{ env.library_prefix }}
gtk3:${{ env.library_prefix }}
libgcrypt:${{ env.library_prefix }}
libjpeg-turbo:${{ env.library_prefix }}
libnfs:${{ env.library_prefix }}
libpng:${{ env.library_prefix }}
libssh:${{ env.library_prefix }}
libtasn1:${{ env.library_prefix }}
libusb:${{ env.library_prefix }}
lzo2:${{ env.library_prefix }}
nettle:${{ env.library_prefix }}
ninja:p
pixman:${{ env.library_prefix }}
pkgconf:p
python:p
SDL2:${{ env.library_prefix }}
SDL2_image:${{ env.library_prefix }}
snappy:${{ env.library_prefix }}
spice:${{ env.library_prefix }}
usbredir:${{ env.library_prefix }}
zstd:${{ env.library_prefix }}
libslirp:${{ env.library_prefix }}
nsis:p
- uses: robinraju/release-downloader@v1
if: ${{ startsWith(matrix.sys, 'clang') }}
with:
repository: 'lzw29107/mingw-clang-workaround'
fileName: '*'
latest: true
out-file-path: 'clang'
- name: 'Install clang'
if: ${{ startsWith(matrix.sys, 'clang') }}
run: |
pacman -U clang/*.pkg.tar.zst --noconfirm
- name: 'Clang cross build workaround'
if: ${{ matrix.cross && matrix.cross_arch == 'aarch64' }}
run: |
ln /${{ matrix.sys }}/bin/pkg-config.exe /${{ matrix.sys }}/bin/aarch64-w64-mingw32-pkg-config.exe
ln /usr/bin/windmc.exe /${{ matrix.sys }}/bin/aarch64-w64-mingw32-windmc.exe
sed -i -s 's/bindir=\${prefix}\/bin/bindir=\/${{ matrix.sys }}\/bin/' /clangarm64/lib/pkgconfig/*.pc
echo "PKGCONFIG_CROSS=1" > $GITHUB_ENV
- name: 'Modify pkgconfig to avoid linker issues'
if: ${{ matrix.mode == 'static' }}
env:
prefix: ${{ (matrix.cross && matrix.cross_arch == 'aarch64') && 'clangarm64' || matrix.sys }}
run: |
PKGCONFIG_FILE="/$prefix/lib/pkgconfig/gpg-error.pc"
sed -i "s#/$prefix/lib/libintl.dll.a#-llibintl#g" "$PKGCONFIG_FILE"
sed -i "s#/$prefix/lib/libiconv.dll.a#-llibiconv#g" "$PKGCONFIG_FILE"
- name: 'headers-git workaround'
if: ${{ !startsWith(matrix.sys, 'clang') }}
env:
pkgprefix: ${{ matrix.sys == 'mingw64' && 'mingw-w64-x86_64-' || 'mingw-w64-ucrt-x86_64-' }}
run: |
pacman -U 'https://repo.msys2.org/mingw/${{ matrix.sys }}/${{ env.pkgprefix }}headers-git-12.0.0.r297.g0be496546-1-any.pkg.tar.zst' --noconfirm
- name: ${{ format ('🚧 Build QEMU (arm & aarch64) {0} {1}', matrix.mode, matrix.cross && matrix.cross_arch || '') }}
env:
mode_flags: ${{ matrix.mode == 'dynamic' && env.dynamic_flags || env.static_flags }}
extra_cflags: ${{ (matrix.mode == 'static' || startsWith(matrix.sys, 'clang')) && format('--extra-cflags="{0} {1}"', matrix.mode == 'static' && env.static_extra_cflags || '', startsWith(matrix.sys, 'clang') && env.clang_extra_cflags || '') || '' }}
arch_flags: ${{ (matrix.cross && matrix.cross_arch == 'aarch64') && env.clang_cross_flags || '--enable-avx2' }}
workaround_flags: ${{ (matrix.mode == 'dynamic' && startsWith(matrix.sys, 'clang')) && env.clang_dynamic_flags || '' }}
run: |
if [ $PKGCONFIG_CROSS == 1 ];
then
PKG_CONFIG_PATH=/clangarm64/lib/pkgconfig:/clangarm64/share/pkgconfig:$PKG_CONFIG_PATH
PKG_CONFIG_SYSTEM_INCLUDE=/clangarm64/include:$PKG_CONFIG_SYSTEM_INCLUDE_PATH
PKG_CONFIG_SYSTEM_LIBRARY=/clangarm64/lib:$PKG_CONFIG_SYSTEM_LIBRARY_PATH
fi
./configure --enable-sdl --enable-fdt=system --disable-docs --target-list=arm-softmmu,aarch64-softmmu --prefix="$(cygpath -u '${{ github.workspace }}')/artifacts" ${{ format('{0} {1} {2} {3}', env.arch_flags, env.mode_flags, env.workaround_flags, env.extra_cflags) }}
make -j16
echo "version=v$(cat VERSION)-$(git rev-parse --short HEAD)" > $GITHUB_ENV
- name: 'Prepare Artifacts (static)'
if: ${{ matrix.mode == 'static' }}
run: |
make install
- name: 'Prepare Artifacts (dynamic)'
if: ${{ matrix.mode == 'dynamic' }}
run: |
if [ $PKGCONFIG_CROSS == 1 ];
then
binpath="$(cygpath -m /clangarm64/bin)"
sed -i "s#\(.exe.*\)/${{ matrix.sys }}/bin#\1$binpath#" 'build/build.ninja'
fi
make installer
mv -v build/qemu-setup*.exe qemu-setup-${version}.exe;
- name: 'Upload artifact (dynamic)'
if: ${{ matrix.mode == 'dynamic' }}
uses: actions/upload-artifact@main
with:
name: ${{ format('QEMU {0} {1} ({2} {3} build)', env.version, matrix.cross && matrix.cross_arch || '', matrix.sys, matrix.mode) }}
path: ${{ github.workspace }}\qemu-setup-${{ env.version }}.exe
compression-level: 9
- name: 'Upload artifact (static)'
if: ${{ matrix.mode == 'static' }}
uses: actions/upload-artifact@main
with:
name: ${{ format('QEMU {0} {1} ({2} {3} build)', env.version, matrix.cross && matrix.cross_arch || '', matrix.sys, matrix.mode) }}
path: ${{ github.workspace }}\artifacts
compression-level: 9
- name: 'Upload logs'
if: ${{ failure() }}
uses: actions/upload-artifact@main
with:
name: ${{ format('QEMU {0} {1} ({2} {3} build) logs', env.version, matrix.cross && matrix.cross_arch || '', matrix.sys, matrix.mode) }}
path: ${{ github.workspace }}/build
compression-level: 9
build_linux:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- { system: 24.04, arch: x64 }
- { system: 24.04, arch: aarch64 }
- { system: devel, arch: x64 }
- { system: devel, arch: aarch64 }
name: Build Linux (Ubuntu ${{ matrix.system }} ${{ matrix.arch }})
steps:
- name: '🧰 Checkout'
uses: actions/checkout@main
- name: 'Update system to devel'
if: ${{ matrix.system == 'devel' }}
run: |
sudo sed -i 's/noble/devel/g' /etc/apt/sources.list.d/ubuntu.sources
sudo apt update
sudo apt full-upgrade
- name: 'Install software packages (for cross build)'
if: ${{ matrix.arch == 'aarch64' }}
run: |
sudo apt update
sudo apt-get install gcc-aarch64-linux-gnu
sudo dpkg --add-architecture arm64
sudo sed -i '/Types/{N;N;N;N;N;N;N;N;N;N;N;N;s/\(Types.*\n.*\)archive\(.*\)\/ubuntu\(.*\n.*\n.*\n.*gpg\)\(\n\n.*\n.*\n\)\(Types.*\n.*\)archive\(.*\)\/ubuntu\(.*\n.*\n.*\n.*gpg\)/\1archive\2\/ubuntu\3\nArchitectures: amd64\n\n\1ports\2\/ubuntu-ports\3\nArchitectures: arm64\4\5archive\6\/ubuntu\7\nArchitectures: amd64\n\n\5ports\6\/ubuntu-ports\7\nArchitectures: arm64/}' /etc/apt/sources.list.d/ubuntu.sources
sudo apt update
- name: 'Install software packages'
env:
library-suffix: ${{ matrix.arch == 'aarch64' && 'arm64' || 'amd64'}}
run: |
sudo apt-get install ninja-build valgrind libglib2.0-dev:${{ env.library-suffix}} libfdt-dev:${{ env.library-suffix}} libpixman-1-dev:${{ env.library-suffix}} libaio-dev:${{ env.library-suffix}} libbluetooth-dev:${{ env.library-suffix}} libcapstone-dev:${{ env.library-suffix}} libbrlapi-dev:${{ env.library-suffix}} libbz2-dev:${{ env.library-suffix}} libcap-ng-dev:${{ env.library-suffix}} libcurl4-gnutls-dev:${{ env.library-suffix}} libgtk-3-dev:${{ env.library-suffix}} libibverbs-dev:${{ env.library-suffix}} libjpeg8-dev:${{ env.library-suffix}} libnuma-dev:${{ env.library-suffix}} librbd-dev:${{ env.library-suffix}} librdmacm-dev:${{ env.library-suffix}} libsasl2-dev:${{ env.library-suffix}} libsdl2-dev:${{ env.library-suffix}} libseccomp-dev:${{ env.library-suffix}} libsnappy-dev:${{ env.library-suffix}} libssh-dev:${{ env.library-suffix}} libvde-dev:${{ env.library-suffix}} libvdeplug-dev:${{ env.library-suffix}} libvte-2.91-dev:${{ env.library-suffix}} libxen-dev:${{ env.library-suffix}} liblzo2-dev:${{ env.library-suffix}} xfslibs-dev:${{ env.library-suffix}} libnfs-dev:${{ env.library-suffix}} libiscsi-dev:${{ env.library-suffix}}
- name: '🚧 Build QEMU Linux (arm & aarch64) (Ubuntu ${{ matrix.system }} ${{ matrix.arch }})'
env:
build_flags: ${{ matrix.arch == 'x64' && '--enable-avx2' || '--enable-kvm --cross-prefix=aarch64-linux-gnu-' }}
run: |
./configure --disable-docs --enable-gtk --enable-sdl --target-list=arm-softmmu,aarch64-softmmu --prefix='${{ github.workspace }}/artifacts' ${{ env.build_flags }}
make -j16
echo "version=v$(cat VERSION)-$(git rev-parse --short HEAD)" > $GITHUB_ENV
- name: 'Prepare Artifacts'
run: |
make install
- name: 'Upload artifact'
uses: actions/upload-artifact@main
with:
name: ${{ format('QEMU {0} Linux {1} (Ubuntu {2} build)', env.version, matrix.arch, matrix.system) }}
path: ${{ github.workspace }}/artifacts
compression-level: 9
- name: 'Upload logs'
if: ${{ failure() }}
uses: actions/upload-artifact@main
with:
name: ${{ format('QEMU {0} Linux {1} (Ubuntu {2} build) logs', env.version, matrix.arch, matrix.system) }}
path: ${{ github.workspace }}/build
compression-level: 9