[gimp] gitlab-ci, build: CI job to package GIMP on Windows from MSYS2 build.



commit 419892c3bd50dac7c671ac719cd6a9c5997691f5
Author: Jehan <jehan girinstud io>
Date:   Thu May 6 18:40:37 2021 +0200

    gitlab-ci, build: CI job to package GIMP on Windows from MSYS2 build.
    
    This new job resulted in a package which allows to run GIMP on Windows
    (as tested in a VM; at least it starts, I can create a new canvas and
    paint). Of course I think this will need to be tweaked a little bit
    more, as I'm sure we miss things here and there.
    
    At the very least, even though I add the Python and Luajit binaries,
    GIMP on Windows didn't find them. This will need to be investigated.
    
    Also it looks like opening from a remote location may not work. Not sure
    if this about a missing GIO module or maybe something which works
    differently on Windows (I was not even able to drag'n drop from the
    browser!). Anyway this needs to be looked at as well.
    
    Note that gdk-pixbuf-query-loaders is apparently unneeded when GIMP is
    built this way (unlike with our crossroad build).
    
    All this to say that this is still an early attempt to full CI build for
    Windows.
    It doesn't invalidate the crossroad build, because cross-compilation
    builds from Linux will always stay very important for Linux developers
    to be able to easily fix Windows bugs too; yet the crossroad build has 2
    major issues:
    1. We haven't figured out yet how to run GObject Introspection tools for
       cross-builds, so the crossroad builds are not full-featured (and this
       is quite a major feature we are missing!).
    2. Also I will want to run the installer in the CI at some point and the
       one we use can only run on Windows itself AFAIK. We could try to run
       it through Wine, but still anyway the point 1. is already quite a
       blocker, let's do the simple thing.
    
    Note that we will likely want to move to meson for this build, because
    autotools is very slow on Windows. But as long as the few blocker meson
    bugs are not fixed, let's stick to the slow yet good build.

 .gitlab-ci.yml                                |  24 +++-
 build/windows/gitlab-ci/dll_link.py           |   7 +
 build/windows/gitlab-ci/package-gimp-msys2.sh | 189 ++++++++++++++++++++++++++
 3 files changed, 219 insertions(+), 1 deletion(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 929f8c65ba..c087d4719a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -234,7 +234,7 @@ gimp-win64-native:
   artifacts:
     name: "${CI_JOB_NAME}-${CI_COMMIT_REF_SLUG}"
     when: always
-    expire_in: 2 days
+    expire_in: 1 day
     paths:
     - _install
   cache:
@@ -393,6 +393,28 @@ cppcheck:
 
 ## Ready-to-distribute ##
 
+win64-native-nightly:
+  rules:
+    - if: '$CI_COMMIT_TAG == null && $CI_PIPELINE_SOURCE != "schedule"'
+  variables:
+    MSYSTEM: "MINGW64"
+    CHERE_INVOKING: "yes"
+  tags:
+    - win32-ps
+  stage: distribution
+  dependencies:
+    - gimp-win64-native
+  artifacts:
+    name: "${CI_JOB_NAME}-${CI_COMMIT_REF_SLUG}"
+    when: always
+    expire_in: 2 days
+    paths:
+    - gimp-w64
+  script:
+    - C:\msys64\usr\bin\pacman --noconfirm -Syyuu
+    - C:\msys64\usr\bin\bash -lc "bash -x ./build/windows/gitlab-ci/package-gimp-msys2.sh"
+  needs: ["gimp-win64-native"]
+
 sources:
   except:
     - schedules
diff --git a/build/windows/gitlab-ci/dll_link.py b/build/windows/gitlab-ci/dll_link.py
index 59190098e3..61528e7ed9 100755
--- a/build/windows/gitlab-ci/dll_link.py
+++ b/build/windows/gitlab-ci/dll_link.py
@@ -77,6 +77,13 @@ def find_dependencies(obj, srcdir):
     if objdump is None:
       sys.stderr.write('File type of {} unknown: {}\n'.format(obj, file_type))
       sys.exit(os.EX_UNAVAILABLE)
+    elif shutil.which(objdump) is None:
+      # For native objdump case.
+      objdump = 'objdump.exe'
+
+    if shutil.which(objdump) is None:
+      sys.stderr.write("Executable doesn't exist: {}\n".format(objdump))
+      sys.exit(os.EX_UNAVAILABLE)
 
     result = subprocess.run([objdump, '-p', obj], stdout=subprocess.PIPE)
     out = result.stdout.decode('utf-8')
diff --git a/build/windows/gitlab-ci/package-gimp-msys2.sh b/build/windows/gitlab-ci/package-gimp-msys2.sh
new file mode 100644
index 0000000000..89d0f49857
--- /dev/null
+++ b/build/windows/gitlab-ci/package-gimp-msys2.sh
@@ -0,0 +1,189 @@
+#!/bin/bash
+
+set -e
+
+if [[ "$MSYSTEM" == "MINGW32" ]]; then
+    export MSYS2_ARCH="i686"
+else
+    export MSYS2_ARCH="x86_64"
+fi
+
+# Why do we even have to remove these manually? The whole thing is
+# messed up, but it looks like the Gitlab runner fails to clean properly
+# (it spews a bunch of "failed to remove" warnings at runner start, then
+# ends with a "error: failed to commit transaction (conflicting files)"
+# listing the various files it failed to remove).
+# Might be tied to: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1839
+rm -f /c/msys64/mingw64/bin/libpcre-1.dll
+rm -f /c/msys64/mingw64/bin/libgio-2.0-0.dll
+rm -f /c/msys64/mingw64/bin/libglib-2.0-0.dll
+rm -f /c/msys64/mingw64/bin/libgmodule-2.0-0.dll
+rm -f /c/msys64/mingw64/bin/libgobject-2.0-0.dll
+rm -f /c/msys64/mingw64/bin/libpng16-16.dll
+rm -f /c/msys64/mingw64/bin/gdk-pixbuf-pixdata.exe
+rm -f /c/msys64/mingw64/bin/libgdk_pixbuf-2.0-0.dll
+rm -f /c/msys64/mingw64/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.dll
+
+# Update everything
+pacman --noconfirm -Suy
+
+# Install the required packages
+pacman --noconfirm -S --needed \
+    base-devel \
+    mingw-w64-$MSYS2_ARCH-binutils \
+    mingw-w64-$MSYS2_ARCH-toolchain \
+    mingw-w64-$MSYS2_ARCH-ccache \
+    \
+    mingw-w64-$MSYS2_ARCH-appstream-glib \
+    mingw-w64-$MSYS2_ARCH-atk \
+    mingw-w64-$MSYS2_ARCH-cairo \
+    mingw-w64-$MSYS2_ARCH-drmingw \
+    mingw-w64-$MSYS2_ARCH-gexiv2 \
+    mingw-w64-$MSYS2_ARCH-ghostscript \
+    mingw-w64-$MSYS2_ARCH-glib-networking \
+    mingw-w64-$MSYS2_ARCH-gobject-introspection \
+    mingw-w64-$MSYS2_ARCH-gobject-introspection-runtime \
+    mingw-w64-$MSYS2_ARCH-graphviz \
+    mingw-w64-$MSYS2_ARCH-gtk3 \
+    mingw-w64-$MSYS2_ARCH-gtk-doc \
+    mingw-w64-$MSYS2_ARCH-iso-codes \
+    mingw-w64-$MSYS2_ARCH-json-c \
+    mingw-w64-$MSYS2_ARCH-json-glib \
+    mingw-w64-$MSYS2_ARCH-lcms2 \
+    mingw-w64-$MSYS2_ARCH-lensfun \
+    mingw-w64-$MSYS2_ARCH-libarchive \
+    mingw-w64-$MSYS2_ARCH-libheif \
+    mingw-w64-$MSYS2_ARCH-libmypaint \
+    mingw-w64-$MSYS2_ARCH-libspiro \
+    mingw-w64-$MSYS2_ARCH-libwebp \
+    mingw-w64-$MSYS2_ARCH-libwmf \
+    mingw-w64-$MSYS2_ARCH-luajit \
+    mingw-w64-$MSYS2_ARCH-maxflow \
+    mingw-w64-$MSYS2_ARCH-mypaint-brushes \
+    mingw-w64-$MSYS2_ARCH-openexr \
+    mingw-w64-$MSYS2_ARCH-pango \
+    mingw-w64-$MSYS2_ARCH-poppler \
+    mingw-w64-$MSYS2_ARCH-poppler-data \
+    mingw-w64-$MSYS2_ARCH-python3-gobject \
+    mingw-w64-$MSYS2_ARCH-shared-mime-info \
+    mingw-w64-$MSYS2_ARCH-suitesparse \
+    mingw-w64-$MSYS2_ARCH-vala \
+    mingw-w64-$MSYS2_ARCH-xpm-nox
+
+export GIMP_PREFIX=`realpath ./_install`
+export GIMP_DISTRIB=`realpath ./gimp-w64`
+export MSYS_PREFIX="/c/msys64/mingw64/"
+export PATH="$GIMP_PREFIX/bin:/mingw64/bin:$PATH"
+
+# Package ressources.
+mkdir -p ${GIMP_DISTRIB}
+cp -fr ${GIMP_PREFIX}/etc ${GIMP_DISTRIB}
+cp -fr ${GIMP_PREFIX}/include ${GIMP_DISTRIB}
+#cp -fr ${GIMP_PREFIX}/ssl ${GIMP_DISTRIB}
+cp -fr ${GIMP_PREFIX}/share ${GIMP_DISTRIB}
+
+# Package executables.
+mkdir ${GIMP_DISTRIB}/bin
+cp -fr ${GIMP_PREFIX}/bin/gimp*.exe ${GIMP_DISTRIB}/bin/
+
+# With the native Windows build, it's directly in bin/
+#mkdir ${GIMP_DISTRIB}/libexec
+#cp -fr ${GIMP_PREFIX}/libexec/gimp*.exe ${GIMP_DISTRIB}/libexec/
+
+# Add a wrapper at tree root, less messy than having to look for the
+# binary inside bin/, in the middle of all the DLLs.
+echo "bin\gimp-2.99.exe" > ${GIMP_DISTRIB}/gimp.cmd
+
+# Package library data and modules.
+mkdir ${GIMP_DISTRIB}/lib/
+cp -fr ${GIMP_PREFIX}/lib/gimp ${GIMP_DISTRIB}/lib/
+cp -fr ${GIMP_PREFIX}/lib/gegl-0.4 ${GIMP_DISTRIB}/lib/
+cp -fr ${GIMP_PREFIX}/lib/babl-0.1 ${GIMP_DISTRIB}/lib/
+
+cp -fr ${MSYS_PREFIX}/lib/girepository-1.0 ${GIMP_DISTRIB}/lib/
+cp -fr ${GIMP_PREFIX}/lib/girepository-1.0/* ${GIMP_DISTRIB}/lib/girepository-1.0/
+
+cp -fr ${MSYS_PREFIX}/lib/gio ${GIMP_DISTRIB}/lib/
+cp -fr ${MSYS_PREFIX}/lib/gdk-pixbuf-2.0 ${GIMP_DISTRIB}/lib/
+
+cp -fr ${MSYS_PREFIX}/share/glib-2.0 ${GIMP_DISTRIB}/share/
+
+# Only copy from langs supported in GIMP.
+for dir in ${GIMP_DISTRIB}/share/locale/*/; do
+  lang=`basename "$dir"`;
+  # TODO: ideally we could be a bit more accurate and copy only the
+  # language files from our dependencies and iso_639.mo. But let's go
+  # with this for now, especially as each lang may have different
+  # translation availability.
+  if [ -d "${MSYS_PREFIX}/share/locale/${lang}/LC_MESSAGES/" ]; then
+    cp -fr "${MSYS_PREFIX}/share/locale/${lang}/LC_MESSAGES/"*.mo 
"${GIMP_DISTRIB}/share/locale/${lang}/LC_MESSAGES/"
+  fi
+done;
+
+# Only one iso-codes file is useful.
+mkdir -p ${GIMP_DISTRIB}/share/xml/iso-codes
+cp -fr ${MSYS_PREFIX}/share/xml/iso-codes/iso_639.xml ${GIMP_DISTRIB}/share/xml/iso-codes/
+
+# Adwaita can be used as the base icon set.
+cp -fr ${MSYS_PREFIX}/share/icons/Adwaita ${GIMP_DISTRIB}/share/icons/
+
+# Executables for supported interpreters.
+cp -fr ${MSYS_PREFIX}/bin/pythonw.exe ${GIMP_DISTRIB}/bin/
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/pythonw.exe ${GIMP_PREFIX}/ ${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/pythonw.exe ${MSYS_PREFIX}/ ${GIMP_DISTRIB}
+
+cp -fr ${MSYS_PREFIX}/bin/luajit.exe ${GIMP_DISTRIB}/bin/
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/luajit.exe ${GIMP_PREFIX}/ ${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/luajit.exe ${MSYS_PREFIX}/ ${GIMP_DISTRIB}
+
+# Executable for "gegl:introspect" from graphviz package.
+cp -fr ${MSYS_PREFIX}/bin/dot.exe ${GIMP_DISTRIB}/bin/
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/dot.exe ${GIMP_PREFIX}/ ${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/dot.exe ${MSYS_PREFIX}/ ${GIMP_DISTRIB}
+
+# Generate share/glib-2.0/schemas/gschemas.compiled
+glib-compile-schemas --targetdir=${GIMP_DISTRIB}/share/glib-2.0/schemas 
${GIMP_DISTRIB}/share/glib-2.0/schemas
+
+# Package needed DLLs only
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-2.99.exe ${GIMP_PREFIX}/ ${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-2.99.exe ${MSYS_PREFIX}/ ${GIMP_DISTRIB}
+
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-console-2.99.exe ${GIMP_PREFIX}/ 
${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-console-2.99.exe ${MSYS_PREFIX}/ 
${GIMP_DISTRIB}
+
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-debug-resume.exe ${GIMP_PREFIX}/ 
${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-debug-resume.exe ${MSYS_PREFIX}/ 
${GIMP_DISTRIB}
+
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-debug-tool-2.99.exe ${GIMP_PREFIX}/ 
${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-debug-tool-2.99.exe ${MSYS_PREFIX}/ 
${GIMP_DISTRIB}
+
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-test-clipboard-2.99.exe ${GIMP_PREFIX}/ 
${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimp-test-clipboard-2.99.exe ${MSYS_PREFIX}/ 
${GIMP_DISTRIB}
+
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimptool-2.99.exe ${GIMP_PREFIX}/ 
${GIMP_DISTRIB}
+python3 build/windows/gitlab-ci/dll_link.py ${GIMP_DISTRIB}/bin/gimptool-2.99.exe ${MSYS_PREFIX}/ 
${GIMP_DISTRIB}
+
+for dll in ${GIMP_DISTRIB}/lib/babl-0.1/*.dll; do
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${GIMP_PREFIX}/ ${GIMP_DISTRIB};
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${MSYS_PREFIX}/ ${GIMP_DISTRIB};
+done
+for dll in ${GIMP_DISTRIB}/lib/gegl-0.4/*.dll; do
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${GIMP_PREFIX}/ ${GIMP_DISTRIB};
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${MSYS_PREFIX}/ ${GIMP_DISTRIB};
+done
+for dll in ${GIMP_DISTRIB}/lib/gio/modules/*.dll; do
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${GIMP_PREFIX}/ ${GIMP_DISTRIB};
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${MSYS_PREFIX}/ ${GIMP_DISTRIB};
+done
+for dll in ${GIMP_DISTRIB}/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.dll; do
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${GIMP_PREFIX}/ ${GIMP_DISTRIB};
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${MSYS_PREFIX}/ ${GIMP_DISTRIB};
+done
+for dll in ${GIMP_DISTRIB}/lib/gimp/2.99/modules/*.dll; do
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${GIMP_PREFIX}/ ${GIMP_DISTRIB};
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${MSYS_PREFIX}/ ${GIMP_DISTRIB};
+done
+for dll in ${GIMP_DISTRIB}/lib/gimp/2.99/plug-ins/*/*.exe; do
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${GIMP_PREFIX}/ ${GIMP_DISTRIB};
+  python3 build/windows/gitlab-ci/dll_link.py $dll ${MSYS_PREFIX}/ ${GIMP_DISTRIB};
+done


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]