Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial meson implementation #2

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
```

Expand Down
4 changes: 2 additions & 2 deletions gtk4-cross-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions gtk4-cross-meson/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 15 additions & 0 deletions gtk4-cross-meson/build.sh
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions gtk4-cross-meson/cargo.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
ar = "x86_64-w64-mingw32-gcc-ar"
17 changes: 17 additions & 0 deletions gtk4-cross-meson/mingw-env
Original file line number Diff line number Diff line change
@@ -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/
44 changes: 44 additions & 0 deletions gtk4-cross-meson/package.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions gtk4-cross-meson/toolchain-mingw64.meson
Original file line number Diff line number Diff line change
@@ -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'
31 changes: 31 additions & 0 deletions gtk4-cross-meson/x86_64-meson
Original file line number Diff line number Diff line change
@@ -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 \
"$@"