2022-08-10 18:11:05 +02:00
|
|
|
#!/bin/sh -e
|
|
|
|
export LC_ALL=C
|
|
|
|
cd "$MESON_INSTALL_DESTDIR_PREFIX"
|
|
|
|
msys2_root=$1
|
|
|
|
|
2023-06-22 01:48:02 +02:00
|
|
|
# Support running directly from within MSYS2 on Windows.
|
|
|
|
if [ -n "$MSYSTEM" ]
|
|
|
|
then
|
|
|
|
wine64() { "$@"; }
|
|
|
|
awk() { command awk -v RS='\r?\n' "$@"; }
|
|
|
|
fi
|
|
|
|
|
2022-08-11 14:49:23 +02:00
|
|
|
# Copy binaries we directly or indirectly depend on.
|
2022-08-10 18:11:05 +02:00
|
|
|
cp -p "$msys2_root"/bin/*.dll .
|
2024-04-06 20:41:06 +02:00
|
|
|
cp -p "$msys2_root"/bin/wperl.exe . || :
|
|
|
|
cp -p "$msys2_root"/bin/exiftool . || :
|
2022-08-11 11:36:31 +02:00
|
|
|
# The console helper is only useful for debug builds.
|
|
|
|
cp -p "$msys2_root"/bin/gspawn-*-helper*.exe .
|
2022-08-10 18:11:05 +02:00
|
|
|
cp -pR "$msys2_root"/etc/ .
|
|
|
|
|
|
|
|
mkdir -p lib
|
|
|
|
cp -pR "$msys2_root"/lib/gdk-pixbuf-2.0/ lib
|
2024-04-06 20:41:06 +02:00
|
|
|
cp -pR "$msys2_root"/lib/perl5/ lib || :
|
2022-08-11 11:36:31 +02:00
|
|
|
mkdir -p share/glib-2.0/schemas
|
|
|
|
cp -pR "$msys2_root"/share/glib-2.0/schemas/*.Settings.* share/glib-2.0/schemas
|
2022-08-10 18:11:05 +02:00
|
|
|
mkdir -p share/icons
|
|
|
|
cp -pR "$msys2_root"/share/icons/Adwaita/ share/icons
|
|
|
|
mkdir -p share/icons/hicolor
|
|
|
|
cp -p "$msys2_root"/share/icons/hicolor/index.theme share/icons/hicolor
|
2023-06-27 00:32:20 +02:00
|
|
|
mkdir -p share/mime
|
|
|
|
# GIO doesn't use the database on Windows, this subset is for us.
|
|
|
|
find "$msys2_root"/share/mime/ -maxdepth 1 -type f -exec cp -p {} share/mime \;
|
2022-08-10 18:11:05 +02:00
|
|
|
|
|
|
|
# Remove unreferenced libraries.
|
|
|
|
find lib -name '*.a' -exec rm -- {} +
|
|
|
|
awk 'function whitelist(binary) {
|
|
|
|
if (seen[binary]++)
|
|
|
|
return
|
|
|
|
|
|
|
|
delete orphans[binary]
|
|
|
|
while (("strings -a \"" binary "\" 2>/dev/null" | getline string) > 0)
|
|
|
|
if (match(string, /[-.+_a-zA-Z0-9]+[.][Dd][Ll][Ll]$/))
|
|
|
|
whitelist("./" substr(string, RSTART, RLENGTH))
|
|
|
|
} BEGIN {
|
|
|
|
while (("find . -type f -path \"./*.[Dd][Ll][Ll]\"" | getline) > 0)
|
|
|
|
orphans[$0]++
|
|
|
|
while (("find . -type f -path \"./*.[Ee][Xx][Ee]\"" | getline) > 0)
|
|
|
|
whitelist($0)
|
2022-08-11 14:49:23 +02:00
|
|
|
while (("find ./lib -type f -path \"./*.[Dd][Ll][Ll]\"" | getline) > 0)
|
2022-08-10 18:11:05 +02:00
|
|
|
whitelist($0)
|
|
|
|
for (library in orphans)
|
|
|
|
print library
|
|
|
|
}' | xargs rm --
|
|
|
|
|
|
|
|
# Removes unused icons from the Adwaita theme. It could be even more aggressive,
|
|
|
|
# since it keeps around lots of sizes and all the GTK+ stock icons.
|
|
|
|
find share/icons/Adwaita -type f | awk 'BEGIN {
|
|
|
|
while (("grep -aho \"[a-z][a-z-]*\" *.dll *.exe" | getline) > 0)
|
|
|
|
good[$0] = 1
|
|
|
|
} /[.](png|svg|cur|ani)$/ {
|
|
|
|
# Cut out the basename without extensions.
|
|
|
|
match($0, /[^\/]+$/)
|
|
|
|
base = substr($0, RSTART)
|
|
|
|
sub(/[.].+$/, "", base)
|
|
|
|
|
|
|
|
# Try matching while cutting off suffixes.
|
|
|
|
# Disregarding the not-much-used GTK_ICON_LOOKUP_GENERIC_FALLBACK.
|
|
|
|
while (!(keep = good[base]) &&
|
|
|
|
sub(/-(ltr|rtl|symbolic)$/, "", base)) {}
|
|
|
|
if (!keep)
|
|
|
|
print
|
|
|
|
}' | xargs rm --
|
|
|
|
|
|
|
|
wine64 "$msys2_root"/bin/glib-compile-schemas.exe share/glib-2.0/schemas
|
|
|
|
|
|
|
|
# This may speed up program start-up a little bit.
|
|
|
|
wine64 "$msys2_root"/bin/gtk-update-icon-cache-3.0.exe share/icons/Adwaita
|