From 03bc99a530b136b186207ec5e95ddadcc7fb1442 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 21 Mar 2018 11:48:52 +0100 Subject: [PATCH] travis-ci: Add cross building support for mingw 64 bit compiler Signed-off-by: Ralf Habacker https://bugs.freedesktop.org/show_bug.cgi?id=105662 --- .travis.yml | 9 ++++--- cmake/x86_64-w64-mingw32.cmake | 19 ++++++++++++++ tools/ci-build.sh | 56 +++++++++++++++++++++++++++++++++++++++--- tools/ci-install.sh | 33 +++++++++++++++++-------- 4 files changed, 101 insertions(+), 16 deletions(-) create mode 100644 cmake/x86_64-w64-mingw32.cmake diff --git a/.travis.yml b/.travis.yml index 4ffc48c4..ea52b710 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,9 +35,12 @@ env: - ci_variant=reduced - ci_variant=legacy - ci_buildsys=cmake - - ci_host=mingw - - ci_host=mingw ci_variant=debug - - ci_host=mingw ci_buildsys=cmake + - ci_host=mingw32 + - ci_host=mingw32 ci_variant=debug + - ci_host=mingw32 ci_buildsys=cmake + - ci_host=mingw64 + - ci_host=mingw64 ci_variant=debug + - ci_host=mingw64 ci_buildsys=cmake - ci_docker=ubuntu:xenial ci_distro=ubuntu ci_suite=xenial - ci_docker=debian:jessie-slim ci_distro=debian ci_suite=jessie - ci_docker=debian:stretch-slim ci_distro=debian ci_suite=stretch diff --git a/cmake/x86_64-w64-mingw32.cmake b/cmake/x86_64-w64-mingw32.cmake new file mode 100644 index 00000000..069bfdde --- /dev/null +++ b/cmake/x86_64-w64-mingw32.cmake @@ -0,0 +1,19 @@ +# Toolchain for mingw-w64 64-bit compilers, as shipped in Debian/Ubuntu. + +set(GNU_HOST x86_64-w64-mingw32) +set(CMAKE_SYSTEM_PROCESSOR "x86_64") + +set(COMPILER_PREFIX "${GNU_HOST}-") + +set(CMAKE_SYSTEM_NAME "Windows") +set(CMAKE_CROSSCOMPILING TRUE) +set(WIN32 TRUE) +set(MINGW TRUE) + +set(CMAKE_C_COMPILER ${COMPILER_PREFIX}gcc) +set(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}g++) +set(CMAKE_RC_COMPILER ${COMPILER_PREFIX}windres) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/tools/ci-build.sh b/tools/ci-build.sh index 81e05afa..29f91474 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -94,7 +94,7 @@ cd ci-build-${ci_variant}-${ci_host} make="make -j${ci_parallel} V=1 VERBOSE=1" case "$ci_host" in - (mingw) + (mingw32) mirror=http://repo.msys2.org/mingw/i686 mingw="$(pwd)/mingw32" install -d "${mingw}" @@ -116,6 +116,29 @@ case "$ci_host" in done export TMPDIR=/tmp ;; + + (mingw64) + mirror=http://repo.msys2.org/mingw/x86_64 + mingw="$(pwd)/mingw64" + install -d "${mingw}" + export PKG_CONFIG_LIBDIR="${mingw}/lib/pkgconfig" + export PKG_CONFIG_PATH= + export PKG_CONFIG="pkg-config --define-variable=prefix=${mingw}" + unset CC + unset CXX + for pkg in \ + expat-2.1.0-6 \ + gcc-libs-5.2.0-4 \ + gettext-0.19.6-1 \ + glib2-2.46.1-1 \ + libffi-3.2.1-3 \ + zlib-1.2.8-9 \ + ; do + wget ${mirror}/mingw-w64-x86_64-${pkg}-any.pkg.tar.xz + tar -xvf mingw-w64-x86_64-${pkg}-any.pkg.tar.xz + done + export TMPDIR=/tmp + ;; esac case "$ci_buildsys" in @@ -198,7 +221,7 @@ case "$ci_buildsys" in esac case "$ci_host" in - (mingw) + (mingw32) set _ "$@" set "$@" --build="$(build-aux/config.guess)" set "$@" --host=i686-w64-mingw32 @@ -211,6 +234,20 @@ case "$ci_buildsys" in ci_sudo=no shift ;; + + (mingw64) + set _ "$@" + set "$@" --build="$(build-aux/config.guess)" + set "$@" --host=x86_64-w64-mingw32 + set "$@" CFLAGS=-static-libgcc + set "$@" CXXFLAGS=-static-libgcc + # don't run tests yet, Wine needs Xvfb and + # more msys2 libraries + ci_test=no + # don't "make install" system-wide + ci_sudo=no + shift + ;; esac ../configure \ @@ -254,7 +291,7 @@ case "$ci_buildsys" in (cmake) case "$ci_host" in - (mingw) + (mingw32) set _ "$@" set "$@" -D CMAKE_TOOLCHAIN_FILE="${srcdir}/cmake/i686-w64-mingw32.cmake" set "$@" -D CMAKE_PREFIX_PATH="${mingw}" @@ -267,6 +304,19 @@ case "$ci_buildsys" in # msys2 libraries ci_test=no ;; + (mingw64) + set _ "$@" + set "$@" -D CMAKE_TOOLCHAIN_FILE="${srcdir}/cmake/x86_64-w64-mingw32.cmake" + set "$@" -D CMAKE_PREFIX_PATH="${mingw}" + set "$@" -D CMAKE_INCLUDE_PATH="${mingw}/include" + set "$@" -D CMAKE_LIBRARY_PATH="${mingw}/lib" + set "$@" -D EXPAT_LIBRARY="${mingw}/lib/libexpat.dll.a" + set "$@" -D GLIB2_LIBRARIES="${mingw}/lib/libglib-2.0.dll.a ${mingw}/lib/libgobject-2.0.dll.a ${mingw}/lib/libgio-2.0.dll.a" + shift + # don't run tests yet, Wine needs Xvfb and more + # msys2 libraries + ci_test=no + ;; esac cmake "$@" ../cmake diff --git a/tools/ci-install.sh b/tools/ci-install.sh index 5a1fa317..fa8f4176 100755 --- a/tools/ci-install.sh +++ b/tools/ci-install.sh @@ -82,19 +82,32 @@ case "$ci_distro" in # travis-ci has a sources list for Chrome which doesn't support i386 : | $sudo tee /etc/apt/sources.list.d/google-chrome.list - if [ "$ci_host" = mingw ]; then - $sudo dpkg --add-architecture i386 - fi + case "$ci_host" in + (mingw32) + $sudo dpkg --add-architecture i386 + ;; + (mingw64) + $sudo dpkg --add-architecture amd64 + ;; + esac $sudo apt-get -qq -y update - if [ "$ci_host" = mingw ]; then - $sudo apt-get -qq -y install \ - binutils-mingw-w64-i686 \ - g++-mingw-w64-i686 \ - wine:i386 \ - ${NULL} - fi + case "$ci_host" in + (mingw32) + $sudo apt-get -qq -y install \ + binutils-mingw-w64-i686 \ + g++-mingw-w64-i686 \ + wine:i386 \ + ${NULL} + ;; + (mingw64) + $sudo apt-get -qq -y install \ + binutils-mingw-w64-x86-64\ + g++-mingw-w64-x86-64 \ + wine:amd64 \ + ${NULL} + esac $sudo apt-get -qq -y install \ autoconf-archive \ -- 2.12.3