forked from AuroraMiddleware/gtk
52cdf3056d
The GtkComposeTable cache is always in big-endian format and is byteswapped on load for the more common little-endian CPUs, but init_builtin_table() in GtkIMContextSimple can't byteswap the built-in data without copying it, which is undesirable. Pregenerate both big- and little-endian compose data, and compile the correct flavour into each build of GTK. This fixes failure of the composetable test when building for a big-endian architecture such as s390x and (traditional, big-endian) powerpc. Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/4217 Signed-off-by: Simon McVittie <smcv@debian.org>
101 lines
3.0 KiB
Python
101 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# Generate gtk.gresources.xml
|
|
#
|
|
# Usage: gen-gtk-gresources-xml SRCDIR_GTK [OUTPUT-FILE]
|
|
|
|
import os, sys
|
|
import filecmp
|
|
|
|
def replace_if_changed(new, old):
|
|
'''
|
|
Compare contents and only replace if changed to avoid triggering a rebuild.
|
|
'''
|
|
try:
|
|
changed = not filecmp.cmp(new, old, shallow=False)
|
|
except FileNotFoundError:
|
|
changed = True
|
|
if changed:
|
|
os.replace(new, old)
|
|
else:
|
|
os.remove(new)
|
|
|
|
srcdir = sys.argv[1]
|
|
endian = sys.argv[2]
|
|
|
|
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))))
|
|
|
|
xml += '''
|
|
<file>theme/Empty/gtk.css</file>
|
|
|
|
<file>theme/Default/gtk.css</file>
|
|
<file alias='theme/Default-dark/gtk.css'>theme/Default/gtk-dark.css</file>
|
|
<file alias='theme/Default-hc/gtk.css'>theme/Default/gtk-hc.css</file>
|
|
<file alias='theme/Default-hc-dark/gtk.css'>theme/Default/gtk-hc-dark.css</file>
|
|
|
|
<file>theme/Default/gtk-light.css</file>
|
|
<file>theme/Default/gtk-dark.css</file>
|
|
<file>theme/Default/gtk-hc.css</file>
|
|
<file>theme/Default/gtk-hc-dark.css</file>
|
|
<file>theme/Default/Default-light.css</file>
|
|
<file>theme/Default/Default-dark.css</file>
|
|
<file>theme/Default/Default-hc.css</file>
|
|
<file>theme/Default/Default-hc-dark.css</file>
|
|
'''
|
|
|
|
for f in get_files('theme/Default/assets', '.png'):
|
|
xml += ' <file>theme/Default/assets/{0}</file>\n'.format(f)
|
|
|
|
xml += '\n'
|
|
|
|
for f in get_files('theme/Default/assets', '.svg'):
|
|
xml += ' <file>theme/Default/assets/{0}</file>\n'.format(f)
|
|
|
|
for f in get_files('theme/Default/assets-hc', '.png'):
|
|
xml += ' <file>theme/Default/assets-hc/{0}</file>\n'.format(f)
|
|
|
|
xml += '\n'
|
|
|
|
for f in get_files('theme/Default/assets-hc', '.svg'):
|
|
xml += ' <file>theme/Default/assets-hc/{0}</file>\n'.format(f)
|
|
|
|
for f in get_files('ui', '.ui'):
|
|
xml += ' <file preprocess=\'xml-stripblanks\'>ui/{0}</file>\n'.format(f)
|
|
|
|
xml += '\n'
|
|
|
|
for s in ['16x16', '32x32', '64x64', 'scalable']:
|
|
for c in ['actions', 'categories', 'emblems', 'emotes', 'devices', 'mimetypes', 'places', '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(icons_dir, '.svg'):
|
|
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/inspector.css</file>
|
|
<file>emoji/en.data</file>
|
|
<file alias="compose/sequences">compose/sequences-{0}-endian</file>
|
|
<file>compose/chars</file>
|
|
</gresource>
|
|
</gresources>'''.format(endian)
|
|
|
|
if len(sys.argv) > 3:
|
|
outfile = sys.argv[3]
|
|
tmpfile = outfile + '~'
|
|
with open(tmpfile, 'w') as f:
|
|
f.write(xml)
|
|
replace_if_changed(tmpfile, outfile)
|
|
else:
|
|
print(xml)
|