diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-10-21 19:16:01 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-10-21 19:38:37 +0200 |
commit | 8ac267c8db771bf87111e29f0511b26e145819fa (patch) | |
tree | b57cc0f71df377c8b94bf300f9829f645906e8d5 | |
parent | 45dd1a4a8677b885424d1f1b7498d1c9d9517d04 (diff) | |
download | logdiag-8ac267c8db771bf87111e29f0511b26e145819fa.tar.gz logdiag-8ac267c8db771bf87111e29f0511b26e145819fa.tar.xz logdiag-8ac267c8db771bf87111e29f0511b26e145819fa.zip |
Figure out how to abuse MSYS2 repositories
In the end, all seems to work fairly well on Windows 10.
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | README.adoc | 15 | ||||
-rw-r--r-- | ToolchainCrossMinGW.cmake (renamed from ToolchainDebianMinGW.cmake) | 0 | ||||
-rw-r--r-- | ToolchainCrossMinGWW64.cmake (renamed from ToolchainDebianMinGWW64.cmake) | 0 | ||||
-rw-r--r-- | ToolchainCrossWin64.cmake | 16 | ||||
-rw-r--r-- | Win64Depends.sh | 69 |
6 files changed, 102 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bead1c..ab3e04b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -348,12 +348,16 @@ if (WIN32) DESTINATION etc) install (DIRECTORY ${WIN32_DEPENDS_PATH}/lib/gdk-pixbuf-2.0 - DESTINATION lib) + DESTINATION lib + FILES_MATCHING PATTERN "*" PATTERN "*.a" EXCLUDE) install (DIRECTORY ${WIN32_DEPENDS_PATH}/share/glib-2.0/schemas DESTINATION share/glib-2.0 FILES_MATCHING PATTERN "org.gtk.Settings.*") + install (DIRECTORY + ${WIN32_DEPENDS_PATH}/share/icons/Adwaita + DESTINATION share/icons OPTIONAL) install (FILES ${WIN32_DEPENDS_PATH}/share/icons/hicolor/index.theme DESTINATION share/icons/hicolor) diff --git a/README.adoc b/README.adoc index b1d65c7..ebfd0b6 100644 --- a/README.adoc +++ b/README.adoc @@ -51,7 +51,7 @@ After _cpack_ finishes making the package, install this file. Build from source on Windows ---------------------------- -_Note that with the current method we're stuck with GTK+ 3.10.4 at best._ +_Note that with the current method we're stuck with GTK+ 3.8.2._ First install CMake >= 3.1 and MinGW. Add both to your system path. If you want to build an installation package, also install NSIS. @@ -86,7 +86,6 @@ By default, that is if you specify no generator, both packages are built. Cross-compilation for Windows ----------------------------- - The procedure is almost exactly the same as before, including the requirements. Just install MinGW-w64 and let automation take care of the rest. @@ -94,7 +93,17 @@ Just install MinGW-w64 and let automation take care of the rest. $ mkdir build $ cd build $ cmake .. \ - -DCMAKE_TOOLCHAIN_FILE=../ToolchainDebianMinGWW64.cmake \ + -DCMAKE_TOOLCHAIN_FILE=../ToolchainCrossMinGWW64.cmake \ + -DCMAKE_BUILD_TYPE=Release + $ cpack + +Alternatively, for an unnecessarily bloated MSYS2-based 64-bit build: + + $ sh Win64Depends.cmake + $ mkdir build + $ cd build + $ cmake .. \ + -DCMAKE_TOOLCHAIN_FILE=../ToolchainCrossWin64.cmake \ -DCMAKE_BUILD_TYPE=Release $ cpack diff --git a/ToolchainDebianMinGW.cmake b/ToolchainCrossMinGW.cmake index 7c9242b..7c9242b 100644 --- a/ToolchainDebianMinGW.cmake +++ b/ToolchainCrossMinGW.cmake diff --git a/ToolchainDebianMinGWW64.cmake b/ToolchainCrossMinGWW64.cmake index f72e903..f72e903 100644 --- a/ToolchainDebianMinGWW64.cmake +++ b/ToolchainCrossMinGWW64.cmake diff --git a/ToolchainCrossWin64.cmake b/ToolchainCrossWin64.cmake new file mode 100644 index 0000000..a562ed0 --- /dev/null +++ b/ToolchainCrossWin64.cmake @@ -0,0 +1,16 @@ +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 "wine") + +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/Win64Depends.sh b/Win64Depends.sh new file mode 100644 index 0000000..aa0deab --- /dev/null +++ b/Win64Depends.sh @@ -0,0 +1,69 @@ +#!/bin/sh -e +# Win64Depends.sh: download dependencies from MSYS2 for cross-compilation +# Dependencies: AWK, sed, cURL, bsdtar, wine64 +repository=https://repo.msys2.org/mingw/mingw64/ + +status() { + echo "$(tput bold)-- $*$(tput sgr0)" +} + +# TODO: Try to verify checksums, it will be relatively low-effort. +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] } + { if (/^[^%]/) f[field] = f[field] $0 "\t"; else field = $0 } + 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 +} + +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)|" lib/pkgconfig/*.pc +} + +mkdir -p win32-depends +cd win32-depends +dbsync +fetch mingw-w64-x86_64-gtk3 mingw-w64-x86_64-lua \ + mingw-w64-x86_64-libwinpthread-git # because we don't do "provides"? +extract +configure + +# XXX: Why is this override needed to run some GLib-based things under wine64? +export XDG_DATA_DIRS=$(pwd)/share |