From 89580f2113a190494afd7e9454bad5275beda4c6 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Fri, 22 Oct 2021 01:59:09 +0200 Subject: sdgui: cross-compile for Windows No one bothered to ask whether it /should/ be done. The hamburger needs to be replaced with a file open dialog there. --- cmake/FindLibIntl.cmake | 8 +++++ cmake/Win64CrossToolchain.cmake | 15 +++++++++ cmake/Win64Depends.sh | 74 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 cmake/FindLibIntl.cmake create mode 100644 cmake/Win64CrossToolchain.cmake create mode 100644 cmake/Win64Depends.sh (limited to 'cmake') diff --git a/cmake/FindLibIntl.cmake b/cmake/FindLibIntl.cmake new file mode 100644 index 0000000..1a15555 --- /dev/null +++ b/cmake/FindLibIntl.cmake @@ -0,0 +1,8 @@ +# Public Domain + +find_library (LibIntl_LIBRARIES intl) + +include (FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS (LibIntl DEFAULT_MSG LibIntl_LIBRARIES) + +mark_as_advanced (LibIntl_LIBRARIES) diff --git a/cmake/Win64CrossToolchain.cmake b/cmake/Win64CrossToolchain.cmake new file mode 100644 index 0000000..68214ec --- /dev/null +++ b/cmake/Win64CrossToolchain.cmake @@ -0,0 +1,15 @@ +set (CMAKE_SYSTEM_NAME "Windows") +set (CMAKE_SYSTEM_PROCESSOR "x86_64") + +set (CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc") +set (CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++") +set (CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres") + +# Not needed to crosscompile an installation package +#set (CMAKE_CROSSCOMPILING_EMULATOR "wine64") + +set (CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32") + +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/cmake/Win64Depends.sh b/cmake/Win64Depends.sh new file mode 100644 index 0000000..971517c --- /dev/null +++ b/cmake/Win64Depends.sh @@ -0,0 +1,74 @@ +#!/bin/sh -e +# Win64Depends.sh: download dependencies from MSYS2 for cross-compilation +# Dependencies: AWK, sed, sha256sum, cURL, bsdtar, wine64 +repository=https://repo.msys2.org/mingw/mingw64/ + +status() { + echo "$(tput bold)-- $*$(tput sgr0)" +} + +dbsync() { + status Fetching repository DB + [ -f db.tsv ] || curl -# "$repository/mingw64.db" | bsdtar -xOf- | awk ' + function flush() { print f["%NAME%"] f["%FILENAME%"] f["%DEPENDS%"] } + NR > 1 && $0 == "%FILENAME%" { flush(); for (i in f) delete f[i] } + !/^[^%]/ { field = $0; next } { f[field] = f[field] $0 "\t" } + field == "%SHA256SUM%" { path = "*packages/" f["%FILENAME%"] + sub(/\t$/, "", path); print $0, path > "db.sums" } END { flush() } + ' > db.tsv +} + +fetch() { + status Resolving "$@" + mkdir -p packages + awk -F'\t' 'function get(name, i, a) { + if (visited[name]++ || !(name in filenames)) return + print filenames[name]; split(deps[name], a); for (i in a) get(a[i]) + } BEGIN { while ((getline < "db.tsv") > 0) { + filenames[$1] = $2; deps[$1] = ""; for (i = 3; i <= NF; i++) { + gsub(/[<=>].*/, "", $i); deps[$1] = deps[$1] $i FS } + } for (i = 0; i < ARGC; i++) get(ARGV[i]) }' "$@" | while IFS= read -r name + do + status Fetching "$name" + [ -f "packages/$name" ] || curl -#o "packages/$name" "$repository/$name" + done +} + +verify() { + status Verifying checksums + sha256sum --ignore-missing --quiet -c db.sums +} + +extract() { + status Extracting packages + for subdir in * + do [ -d "$subdir" -a "$subdir" != packages ] && rm -rf -- "$subdir" + done + for i in packages/* + do bsdtar -xf "$i" --strip-components 1 mingw64 + done +} + +configure() { + status Configuring packages + glib-compile-schemas share/glib-2.0/schemas + wine64 bin/gdk-pixbuf-query-loaders.exe \ + > lib/gdk-pixbuf-2.0/2.10.0/loaders.cache + + # pkgconf has a command line option for this, but CMake can't pass it + sed -i "s|^prefix=/mingw64|prefix=$(pwd)|" {share,lib}/pkgconfig/*.pc +} + +mkdir -p win32-depends +cd win32-depends +dbsync +fetch mingw-w64-x86_64-gtk3 mingw-w64-x86_64-icu \ + mingw-w64-x86_64-libwinpthread-git # because we don't do "provides"? +verify +extract +configure + +status Success + +# XXX: Why is this override needed to run some GLib-based things under wine64? +export XDG_DATA_DIRS=$(pwd)/share -- cgit v1.2.3-70-g09d2