[gtk+/wip/meson: 40/73] meson: gtk: generate gtk.gresource.xml



commit 9261253285192cfed83dfaa1f36555dc8208310c
Author: Tim-Philipp Müller <tim centricular com>
Date:   Sat Mar 11 21:54:20 2017 +0000

    meson: gtk: generate gtk.gresource.xml

 gtk/gen-gtk-gresources-xml.py |   94 ++++++++++++++
 gtk/gtk.gresource.xml         |  269 -----------------------------------------
 gtk/meson.build               |   13 ++-
 3 files changed, 105 insertions(+), 271 deletions(-)
---
diff --git a/gtk/gen-gtk-gresources-xml.py b/gtk/gen-gtk-gresources-xml.py
new file mode 100644
index 0000000..99445be
--- /dev/null
+++ b/gtk/gen-gtk-gresources-xml.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python3
+#
+# Generate gtk.gresources.xml
+#
+# Usage: gen-gtk-gresources-xml SRCDIR_GTK [OUTPUT-FILE]
+
+import os, sys
+
+srcdir = sys.argv[1]
+
+xml = '''<?xml version='1.0' encoding='UTF-8'?>
+<gresources>
+  <gresource prefix='/org/gtk/libgtk'>
+'''
+
+def get_files(subdir,extension):
+  return sorted(filter(lambda x: x.endswith((extension)), os.listdir(os.path.join(srcdir,subdir))))
+
+for f in get_files('theme/Raleigh', '.css'):
+  xml += '    <file alias=\'theme/Raleigh/gtk.css\'>theme/Raleigh/{0}</file>\n'.format(f)
+
+
+xml += '''
+    <file>theme/Adwaita/gtk.css</file>
+    <file>theme/Adwaita/gtk-dark.css</file>
+    <file>theme/Adwaita/gtk-contained.css</file>
+    <file>theme/Adwaita/gtk-contained-dark.css</file>
+'''
+
+for f in get_files('theme/Adwaita/assets', '.png'):
+  xml += '    <file preprocess=\'to-pixdata\'>theme/Adwaita/assets/{0}</file>\n'.format(f)
+
+xml += '\n'
+
+for f in get_files('theme/Adwaita/assets', '.svg'):
+  xml += '    <file>theme/Adwaita/assets/{0}</file>\n'.format(f)
+
+xml += '''
+    <file>theme/HighContrast/gtk.css</file>
+    <file alias='theme/HighContrastInverse/gtk.css'>theme/HighContrast/gtk-inverse.css</file>
+    <file>theme/HighContrast/gtk-contained.css</file>
+    <file>theme/HighContrast/gtk-contained-inverse.css</file>
+'''
+
+for f in get_files('theme/HighContrast/assets', '.png'):
+  xml += '    <file preprocess=\'to-pixdata\'>theme/HighContrast/assets/{0}</file>\n'.format(f)
+
+xml += '\n'
+
+for f in get_files('theme/HighContrast/assets', '.svg'):
+  xml += '    <file>theme/HighContrast/assets/{0}</file>\n'.format(f)
+
+xml += '''
+    <file>theme/win32/gtk-win32-base.css</file>
+    <file>theme/win32/gtk.css</file>
+'''
+
+for f in get_files('cursor', '.png'):
+  xml += '    <file>cursor/{0}</file>\n'.format(f)
+
+xml += '\n'
+
+for f in get_files('gesture', '.symbolic.png'):
+  xml += '    <file alias=\'icons/64x64/actions/{0}\'>gesture/{0}</file>\n'.format(f)
+
+xml += '\n'
+
+for f in get_files('ui', '.ui'):
+  xml += '    <file preprocess=\'xml-stripblanks\'>ui/{0}</file>\n'.format(f)
+
+xml += '\n'
+
+for s in ['16x16', '22x22', '24x24', '32x32', '48x48']:
+  for c in ['actions', 'status']:
+    icons_dir = 'icons/{0}/{1}'.format(s,c)
+    if os.path.exists(os.path.join(srcdir,icons_dir)):
+      for f in get_files(icons_dir, '.png'):
+        xml += '    <file>icons/{0}/{1}/{2}</file>\n'.format(s,c,f)
+
+for f in get_files('inspector', '.ui'):
+  xml += '    <file preprocess=\'xml-stripblanks\'>inspector/{0}</file>\n'.format(f)
+
+xml += '''
+    <file>inspector/logo.png</file>
+  </gresource>
+</gresources>'''
+
+if len(sys.argv) > 2:
+  outfile = sys.argv[2]
+  f = open(outfile, 'w')
+  f.write(xml)
+  f.close()
+else:
+  print(xml)
diff --git a/gtk/meson.build b/gtk/meson.build
index 24598d4..0e712ff 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -605,10 +605,19 @@ gtk_unix_sources = files([
   'gtksearchenginetracker.c',
 ])
 
+gen_gtk_gresources_xml = find_program('gen-gtk-gresources-xml.py')
+# FIXME: absolute path to work around meson bug with @OUTPUT@ etc. not being
+# handled here, and also with the working dir from which the script is called.
+# Hopefully all to be fixed in Meson 0.39
+outfile = '@0@/gtk.gresources.xml'.format(meson.current_build_dir())
+gtk_gresources_xml = configure_file(output : 'gtk.gresources.xml',
+  input : 'gtk/ui/gtkdialog.ui', # FIXME: shouldn't be needed
+  command : [gen_gtk_gresources_xml, meson.current_source_dir(), outfile])
+
 gtkresources = gnome.compile_resources(
   'gtkresources',
-  'gtk.gresource.xml',
-  source_dir: '.',
+  gtk_gresources_xml,
+  source_dir: meson.current_source_dir(),
   c_name: '_gtk',
   extra_args: '--manual-register'
 )


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