diff --git a/README.md b/README.md index f309056..6525c46 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,9 @@ FROM gtk4-cross-base ADD build.sh /usr/bin RUN chmod +x /usr/bin/build.sh +ADD package.sh /usr/bin +RUN chmod +x /usr/bin/package.sh + CMD ["/bin/bash"] ``` diff --git a/gtk4-cross-base/Dockerfile b/gtk4-cross-base/Dockerfile index e1bf96e..787f116 100644 --- a/gtk4-cross-base/Dockerfile +++ b/gtk4-cross-base/Dockerfile @@ -9,9 +9,9 @@ WORKDIR /root/pe-util/build RUN cmake .. -DCMAKE_BUILD_TYPE=Release RUN make -FROM fedora:rawhide +FROM fedora:latest COPY --from=0 /root/pe-util/build/peldd /usr/bin/peldd -RUN dnf install git mingw64-binutils mingw64-gcc meson mingw64-pango mingw64-gdk-pixbuf mingw64-libepoxy mingw64-winpthreads-static glib2-devel gobject-introspection-devel vala wine cmake gcc zip boost boost-system -y && dnf clean all -y +RUN dnf install git mingw64-binutils mingw64-gcc meson mingw64-pango mingw64-gdk-pixbuf mingw64-libepoxy mingw64-winpthreads-static glib2-devel gobject-introspection-devel mingw64-gstreamer1-plugins-bad-free vala wine cmake gcc zip boost boost-system -y && dnf clean all -y # Clone the gtk4 repository (Move after the mingw setup for efficiency later) WORKDIR /tmp diff --git a/gtk4-cross-meson/Dockerfile b/gtk4-cross-meson/Dockerfile new file mode 100644 index 0000000..7adf403 --- /dev/null +++ b/gtk4-cross-meson/Dockerfile @@ -0,0 +1,32 @@ +FROM aknarts/gtk4-cross:gtk-4.4 + +RUN dnf install git mingw64-binutils mingw64-gcc meson mingw64-pango mingw64-gdk-pixbuf mingw64-libepoxy mingw64-sqlite mingw64-winpthreads-static glib2-devel gobject-introspection-devel mingw64-gstreamer1-plugins-bad-free vala wine cmake gcc zip boost sqlite sqlite-devel boost-system -y && dnf update -y && dnf clean all -y + +# Add meson executable +ADD x86_64-meson /usr/bin +RUN chmod +x /usr/bin/x86_64-meson + +# Add mingw-env executable +ADD mingw-env /usr/bin +RUN chmod +x /usr/bin/mingw-env + +# Update with the new toolchain file +ADD toolchain-mingw64.meson /usr/share/mingw + +# Add build.sh +ADD build.sh /usr/bin +RUN chmod +x /usr/bin/build.sh + +# Add package.sh +ADD package.sh /usr/bin +RUN chmod +x /usr/bin/package.sh + +# Setup rust +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +RUN . ~/.cargo/env && \ + rustup target add x86_64-pc-windows-gnu + +# Set default linker to the GCC linker +ADD cargo.config /home/rust/.cargo/config + +CMD ["/bin/bash"] diff --git a/gtk4-cross-meson/build.sh b/gtk4-cross-meson/build.sh new file mode 100644 index 0000000..9b7cb4d --- /dev/null +++ b/gtk4-cross-meson/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash +source ~/.cargo/env +export MINGW_PREFIX=/usr/x86_64-w64-mingw32/sys-root/mingw/ + +x86_64-meson /tmp/_build -Dwindows=true --prefix=/usr +meson compile -C /tmp/_build + +mkdir -p package +cp /tmp/_build/target/x86_64-pc-windows-gnu/release/*.exe package +mkdir -p package/data +cp /tmp/_build/data/resources.gresource package/data +mkdir -p package/share/glib-2.0/schemas +cp /tmp/_build/data/*.gschema.xml package/share/glib-2.0/schemas +glib-compile-schemas package/share/glib-2.0/schemas + diff --git a/gtk4-cross-meson/cargo.config b/gtk4-cross-meson/cargo.config new file mode 100644 index 0000000..45bd98a --- /dev/null +++ b/gtk4-cross-meson/cargo.config @@ -0,0 +1,3 @@ +[target.x86_64-pc-windows-gnu] +linker = "x86_64-w64-mingw32-gcc" +ar = "x86_64-w64-mingw32-gcc-ar" \ No newline at end of file diff --git a/gtk4-cross-meson/mingw-env b/gtk4-cross-meson/mingw-env new file mode 100644 index 0000000..03a3bee --- /dev/null +++ b/gtk4-cross-meson/mingw-env @@ -0,0 +1,17 @@ +#!/bin/sh + +_arch=$1 + +default_mingw_pp_flags="-D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS" +default_mingw_compiler_flags="$default_mingw_pp_flags -O2 -pipe -fno-plt -fexceptions --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fcf-protection" +default_mingw_linker_flags="-Wl,-O1,--sort-common,--as-needed -fstack-protector" + +export CPPFLAGS="${MINGW_CPPFLAGS:-$default_mingw_pp_flags $CPPFLAGS}" +export CFLAGS="${MINGW_CFLAGS:-$default_mingw_compiler_flags $CFLAGS}" +export CXXFLAGS="${MINGW_CXXFLAGS:-$default_mingw_compiler_flags $CXXFLAGS}" +export LDFLAGS="${MINGW_LDFLAGS:-$default_mingw_linker_flags $LDFLAGS}" + +mingw_prefix=/usr/${_arch} +export PKG_CONFIG_SYSROOT_DIR="${mingw_prefix}" +export PKG_CONFIG_LIBDIR="${mingw_prefix}/lib/pkgconfig:${mingw_prefix}/share/pkgconfig" +export MINGW_PREFIX=/usr/x86_64-w64-mingw32/sys-root/mingw/ diff --git a/gtk4-cross-meson/package.sh b/gtk4-cross-meson/package.sh new file mode 100644 index 0000000..fb0da1c --- /dev/null +++ b/gtk4-cross-meson/package.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +export DLLS=`peldd package/*.exe -t --ignore-errors` +mkdir -p package +for DLL in $DLLS + #do cp /usr/x86_64-w64-mingw32/bin/"$DLL" package + do cp "$DLL" package +done + +# Copy libgtk and few other dlls into package +cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/*.dll package + +# Add gdbus which is recommended on Windows +cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/gdbus.exe package + + +mkdir -p package/share/{themes,gtk-4.0,glib-2.0} +#cp -r $GTK_INSTALL_PATH/share/glib-2.0/schemas package/share/glib-2.0/ +cp -r $GTK_INSTALL_PATH/share/icons package/share/icons + +if [ -z "$WIN_THEME" ] +then + cat <<-EOF > package/share/gtk-4.0/settings.ini + [Settings] + gtk-font-name = Segoe UI 10 + gtk-xft-rgba = rgb + gtk-xft-antialias = 1 +EOF +else + cp -r /home/rust/Windows10 package/share/themes + + cat <<-EOF > package/share/gtk-4.0/settings.ini + [Settings] + gtk-theme-name = Windows10 + gtk-font-name = Segoe UI 10 + gtk-xft-rgba = rgb + gtk-xft-antialias = 1 + EOF +fi + +find package -maxdepth 1 -type f -exec mingw-strip {} + + +zip -qr package.zip package/* +rm -rf package diff --git a/gtk4-cross-meson/toolchain-mingw64.meson b/gtk4-cross-meson/toolchain-mingw64.meson new file mode 100644 index 0000000..f0133f1 --- /dev/null +++ b/gtk4-cross-meson/toolchain-mingw64.meson @@ -0,0 +1,23 @@ +[binaries] +c = '/usr/bin/x86_64-w64-mingw32-gcc' +cpp = '/usr/bin/x86_64-w64-mingw32-g++' +fortran = '/usr/bin/x86_64-w64-mingw32-gfortran' +rust = ['rustc', '--target', 'x86_64-pc-windows-gnu', '-C', 'linker=/usr/bin/x86_64-w64-mingw32-gcc'] +ar = '/usr/bin/x86_64-w64-mingw32-ar' +pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config' +ranlib = '/usr/bin/x86_64-w64-mingw32-ranlib' +strip = '/usr/bin/x86_64-w64-mingw32-strip' +windres = '/usr/bin/x86_64-w64-mingw32-windres' +dlltool = '/usr/bin/x86_64-w64-mingw32-dlltool' +libgcrypt-config = '/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libgcrypt-config' +exe_wrapper = '/usr/bin/wine' + +[properties] +root = '/usr/x86_64-w64-mingw32/sys-root/mingw' +needs_exe_wrapper = true + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' diff --git a/gtk4-cross-meson/x86_64-meson b/gtk4-cross-meson/x86_64-meson new file mode 100644 index 0000000..6e8f3ca --- /dev/null +++ b/gtk4-cross-meson/x86_64-meson @@ -0,0 +1,31 @@ +#!/bin/sh + +if [ -z ${CROSS_FILE} ] +then + if [ -z ${NEED_WINE} ] + then + CROSS_FILE=/usr/share/mingw/toolchain-mingw64.meson + else + CROSS_FILE=/usr/share/mingw/toolchain-mingw64-wine.meson + MESON_EXE_WRAPPER=/usr/bin/x86_64-w64-mingw64-wine + fi +fi + +exec meson setup \ + --libdir /usr/x86_64-w64-mingw32/sys-root/mingw/lib \ + --libexecdir /usr/x86_64-w64-mingw32/sys-root/mingw/lib \ + --bindir /usr/x86_64-w64-mingw32/sys-root/mingw/bin \ + --sbindir /usr/x86_64-w64-mingw32/sys-root/mingw/bin \ + --includedir /usr/x86_64-w64-mingw32/sys-root/mingw/include \ + --datadir /usr/x86_64-w64-mingw32/sys-root/mingw/share \ + --mandir /usr/x86_64-w64-mingw32/sys-root/mingw/share/man \ + --infodir /usr/x86_64-w64-mingw32/sys-root/mingw/share/info \ + --localedir /usr/x86_64-w64-mingw32/sys-root/mingw/share/locale \ + --sysconfdir /usr/x86_64-w64-mingw32/sys-root/mingw/etc \ + --localstatedir /var \ + --sharedstatedir /var/lib \ + --buildtype release \ + --wrap-mode nofallback \ + --cross-file ${CROSS_FILE} \ + --default-library shared \ + "$@"