summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2021-04-07 19:09:25 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2021-04-07 19:11:30 +0100
commit866670e30907eb534895da26626709ed5f2e419d (patch)
treeff40382fa391f7c0f3c2c5d41bffcb633d578305
parent6e8a9c608649db887705d3666cbd39e924319cb4 (diff)
downloadgdk-pixbuf-866670e30907eb534895da26626709ed5f2e419d.tar.gz
build: Port post-install script to Python
Avoid the whole shell/batch file shenanigans.
-rw-r--r--build-aux/post-install.bat24
-rw-r--r--build-aux/post-install.py26
-rw-r--r--build-aux/post-install.sh18
-rw-r--r--meson.build19
4 files changed, 31 insertions, 56 deletions
diff --git a/build-aux/post-install.bat b/build-aux/post-install.bat
deleted file mode 100644
index 6994d49e1..000000000
--- a/build-aux/post-install.bat
+++ /dev/null
@@ -1,24 +0,0 @@
-@echo off
-
-set bindir=%1
-set libdir=%2
-set binary_version=%3
-
-set libdir_windows=%libdir:/=\%
-
-if not "%DESTDIR%" == "" goto warn_msg
-if not exist %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\ mkdir %libdir_windows%\gdk-pixbuf-2.0\%binary_version%
-%bindir%\gdk-pixbuf-query-loaders > %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\loaders.cache
-
-goto end
-
-:warn_msg
-echo ***
-echo *** Warning: loaders.cache not built
-echo ***
-echo *** You should generate this file manually on the host system
-echo *** using:
-echo *** gdk-pixbuf-query-loaders ^> %libdir_windows%\gdk-pixbuf-2.0\%binary_version%\loaders.cache
-echo ***
-
-:end
diff --git a/build-aux/post-install.py b/build-aux/post-install.py
new file mode 100644
index 000000000..d532ddf73
--- /dev/null
+++ b/build-aux/post-install.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import subprocess
+
+if 'DESTDIR' not in os.environ:
+ bindir = sys.argv[1]
+ libdir = sys.argv[2]
+ binary_version = sys.argv[3]
+
+ query_loaders = os.path.join(bindir, "gdk-pixbuf-query-loaders")
+ loaders_dir = os.path.join(libdir, "gdk-pixbuf-2.0", binary_version)
+ loaders_cache = os.path.join(loaders_dir, "loaders.cache")
+
+ os.makedirs(loaders_dir, exist_ok=True)
+
+ cmd = [query_loaders]
+ with subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True) as p:
+ data = p.stdout.read()
+
+ with open(loaders_cache, "wb") as f:
+ f.write(data)
+else:
+ print("*** Warning: loaders.cache not built because DESTDIR is set")
+ print("*** You will need to manually call gdk-pixbuf-query-loaders")
diff --git a/build-aux/post-install.sh b/build-aux/post-install.sh
deleted file mode 100644
index 661bceeef..000000000
--- a/build-aux/post-install.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-bindir="$1"
-libdir="$2"
-binary_version="$3"
-
-if [ -z "$DESTDIR" ]; then
- mkdir -p "$libdir/gdk-pixbuf-2.0/$binary_version"
- $bindir/gdk-pixbuf-query-loaders > "$libdir/gdk-pixbuf-2.0/$binary_version/loaders.cache"
-else
- echo "***"
- echo "*** Warning: loaders.cache not built"
- echo "***"
- echo "*** You should generate this file manually on the host system"
- echo "*** using:"
- echo "*** gdk-pixbuf-query-loaders > $libdir/gdk-pixbuf-2.0/$binary_version/loaders.cache"
- echo "***"
-fi
diff --git a/meson.build b/meson.build
index 286f17c2d..b84d804c7 100644
--- a/meson.build
+++ b/meson.build
@@ -419,20 +419,11 @@ build_docs = get_option('gtk_doc') or get_option('docs')
subdir('docs')
if not meson.is_cross_build()
- # On Visual Studio, we don't normally have a shell interpreter, so use a .bat
- if cc.get_id() == 'msvc'
- meson.add_install_script('build-aux/post-install.bat',
- gdk_pixbuf_bindir,
- gdk_pixbuf_libdir,
- gdk_pixbuf_binary_version,
- )
- else
- meson.add_install_script('build-aux/post-install.sh',
- gdk_pixbuf_bindir,
- gdk_pixbuf_libdir,
- gdk_pixbuf_binary_version,
- )
- endif
+ meson.add_install_script('build-aux/post-install.py',
+ gdk_pixbuf_bindir,
+ gdk_pixbuf_libdir,
+ gdk_pixbuf_binary_version,
+ )
endif
if not meson.is_subproject()