From b09e4ca69b4dca6fd9d2e98a3722d765f86c837f Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 3 Aug 2017 13:15:04 +0100 Subject: Move all aux scripts to their own directory This makes it easier to find them and reference them. --- Makefile.am | 7 ++-- build-aux/gen-color-table.pl | 74 +++++++++++++++++++++++++++++++++++++++++ build-aux/gen-installed-test.py | 21 ++++++++++++ build-aux/gen-resources.py | 44 ++++++++++++++++++++++++ build-aux/gen-thumbnailer.py | 43 ++++++++++++++++++++++++ gdk-pixbuf/Makefile.am | 1 - gdk-pixbuf/gen-color-table.pl | 74 ----------------------------------------- meson.build | 5 +++ tests/gen-installed-test.py | 21 ------------ tests/gen-resources.py | 44 ------------------------ tests/meson.build | 3 -- thumbnailer/gen-thumbnailer.py | 43 ------------------------ thumbnailer/meson.build | 1 - 13 files changed, 191 insertions(+), 190 deletions(-) create mode 100755 build-aux/gen-color-table.pl create mode 100644 build-aux/gen-installed-test.py create mode 100644 build-aux/gen-resources.py create mode 100644 build-aux/gen-thumbnailer.py delete mode 100755 gdk-pixbuf/gen-color-table.pl delete mode 100644 tests/gen-installed-test.py delete mode 100644 tests/gen-resources.py delete mode 100644 thumbnailer/gen-thumbnailer.py diff --git a/Makefile.am b/Makefile.am index 9779b24a2..68cb49f9d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,10 +9,11 @@ meson_files = \ contrib/gdk-pixbuf-xlib/meson.build \ po/meson.build \ tests/meson.build \ - tests/gen-installed-test.py \ - tests/gen-resources.py \ thumbnailer/meson.build \ - thumbnailer/gen-thumbnailer.py \ + build-aux/gen-color-table.pl \ + build-aux/gen-installed-test.py \ + build-aux/gen-resources.py \ + build-aux/gen-thumbnailer.py \ $() EXTRA_DIST = \ diff --git a/build-aux/gen-color-table.pl b/build-aux/gen-color-table.pl new file mode 100755 index 000000000..8b02fe583 --- /dev/null +++ b/build-aux/gen-color-table.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl -w + +if (@ARGV != 1) { + die "Usage: gen-color-table.pl rgb.txt > xpm-color-table.h\n"; +} + +open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n"; + +@colors = (); +while (defined($_ = )) { + next if /^!/; + if (!/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(.*\S)\s+$/) { + die "Cannot parse line $_"; + } + + push @colors, [$1, $2, $3, $4]; +} + +@colors = sort { lc($a->[3]) cmp lc($b->[3]) } @colors; + +$offset = 0; + +$date = gmtime; + +print <[3]; + + if ($offset != 0) { + print qq(\n); + } + print qq( "$name\\0"); + + $color->[4] = $offset; + $offset += length($name) + 1; +} + +print ";\n\n"; + +print <[0]; + $green = $color->[1]; + $blue = $color->[2]; + $offset = $color->[4]; + + if ($i != 0) { + print ",\n"; + } + print " { $offset, $red, $green, $blue }"; + $i++; +} + +print "\n};\n"; diff --git a/build-aux/gen-installed-test.py b/build-aux/gen-installed-test.py new file mode 100644 index 000000000..745abf339 --- /dev/null +++ b/build-aux/gen-installed-test.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import sys +import os +import argparse + +def write_template(filename, data): + with open(filename, 'w') as f: + f.write(data) + +def build_template(bindir, binname): + return "[Test]\nType=session\nExec={}\n".format(os.path.join(bindir, binname)) + +argparser = argparse.ArgumentParser(description='Generate installed-test data.') +argparser.add_argument('--testbindir', metavar='dir', help='Installed test directory') +argparser.add_argument('--testbin', metavar='name', help='Installed test name') +argparser.add_argument('output', help='Output file') + +args = argparser.parse_args() + +write_template(args.output, build_template(args.testbindir, args.testbin)) diff --git a/build-aux/gen-resources.py b/build-aux/gen-resources.py new file mode 100644 index 000000000..4c182d9cf --- /dev/null +++ b/build-aux/gen-resources.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +# Ancillary wrapper around glib-compile-resources that sets up a +# modified environment in order to use the tools that we just +# built instead of the system ones + +import argparse +import os +import subprocess +import sys + +argparser = argparse.ArgumentParser(description='Compile resources') +argparser.add_argument('--pixdata', metavar='PATH', help='Path to gdk-pixbuf-pixdata') +argparser.add_argument('--loaders', metavar='PATH', help='Path to the loaders.cache file') +argparser.add_argument('--sourcedir', metavar='PATH', help='Path to the source directory') +argparser.add_argument('resource', help='GResource XML file') +argparser.add_argument('output', help='Output file') + +group = argparser.add_mutually_exclusive_group() +group.add_argument('--header', help='Generate header file', action='store_true') +group.add_argument('--source', help='Generate source file', action='store_true') + +args = argparser.parse_args() + +cmd = ['glib-compile-resources'] +if args.header: + cmd += ['--generate-header'] +else: + cmd += ['--generate-source'] + +cmd += ['--sourcedir', args.sourcedir] +cmd += [args.resource] +cmd += ['--target', args.output] + +newenv = os.environ.copy() +newenv['GDK_PIXBUF_PIXDATA'] = args.pixdata +newenv['GDK_PIXBUF_MODULE_FILE'] = args.loaders + +out, err = subprocess.Popen(cmd, env=newenv).communicate() +if out is None: + sys.exit(0) +else: + print(out) + sys.exit(1) diff --git a/build-aux/gen-thumbnailer.py b/build-aux/gen-thumbnailer.py new file mode 100644 index 000000000..9994043f9 --- /dev/null +++ b/build-aux/gen-thumbnailer.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +# Ancillary wrapper around gdk-pixbuf-print-mime-types that sets up a +# modified environment in order to use the tools that we just built +# instead of the system ones + +import argparse +import os +import subprocess +import sys + +argparser = argparse.ArgumentParser(description='Compile resources') +argparser.add_argument('--printer', metavar='PATH', help='Path to gdk-pixbuf-print-mime-types') +argparser.add_argument('--pixdata', metavar='PATH', help='Path to gdk-pixbuf-pixdata') +argparser.add_argument('--loaders', metavar='PATH', help='Path to the loaders.cache file') +argparser.add_argument('--bindir', metavar='PATH', help='Path to the source directory') +argparser.add_argument('input', help='Template file') +argparser.add_argument('output', help='Output file') + +args = argparser.parse_args() + +newenv = os.environ.copy() +newenv['GDK_PIXBUF_PIXDATA'] = args.pixdata +newenv['GDK_PIXBUF_MODULE_FILE'] = args.loaders + +cmd = args.printer + +mimetypes_out = subprocess.Popen(cmd, env=newenv, stdout=subprocess.PIPE).communicate()[0] +if not mimetypes_out: + sys.exit(1) + +infile = open(args.input, 'r') +outfile = open(args.output, 'w') + +for line in infile: + line = line.replace('@bindir@', args.bindir) + line = line.replace('@mimetypes@', mimetypes_out.decode('ascii')) + outfile.write(line) + +infile.close() +outfile.close() + +sys.exit(0) diff --git a/gdk-pixbuf/Makefile.am b/gdk-pixbuf/Makefile.am index d5901dcdf..01b693ce9 100644 --- a/gdk-pixbuf/Makefile.am +++ b/gdk-pixbuf/Makefile.am @@ -595,7 +595,6 @@ EXTRA_DIST = \ gdk-pixbuf-marshal.list \ gdk-pixbuf-enum-types.c.template \ gdk-pixbuf-enum-types.h.template \ - gen-color-table.pl \ gdiplus.def \ fallback-c89.c diff --git a/gdk-pixbuf/gen-color-table.pl b/gdk-pixbuf/gen-color-table.pl deleted file mode 100755 index 8b02fe583..000000000 --- a/gdk-pixbuf/gen-color-table.pl +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/perl -w - -if (@ARGV != 1) { - die "Usage: gen-color-table.pl rgb.txt > xpm-color-table.h\n"; -} - -open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n"; - -@colors = (); -while (defined($_ = )) { - next if /^!/; - if (!/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(.*\S)\s+$/) { - die "Cannot parse line $_"; - } - - push @colors, [$1, $2, $3, $4]; -} - -@colors = sort { lc($a->[3]) cmp lc($b->[3]) } @colors; - -$offset = 0; - -$date = gmtime; - -print <[3]; - - if ($offset != 0) { - print qq(\n); - } - print qq( "$name\\0"); - - $color->[4] = $offset; - $offset += length($name) + 1; -} - -print ";\n\n"; - -print <[0]; - $green = $color->[1]; - $blue = $color->[2]; - $offset = $color->[4]; - - if ($i != 0) { - print ",\n"; - } - print " { $offset, $red, $green, $blue }"; - $i++; -} - -print "\n};\n"; diff --git a/meson.build b/meson.build index b0be82acf..a754c9d49 100644 --- a/meson.build +++ b/meson.build @@ -283,6 +283,11 @@ configure_file(input: 'gdk-pixbuf-2.0.pc.in', root_inc = include_directories('.') +# Auxiliary scripts +gen_resources = find_program('build-aux/gen-resources.py') +gen_installed_test = find_program('build-aux/gen-installed-test.py') +gen_thumbnailer = find_program('build-aux/gen-thumbnailer.py') + gnome = import('gnome') subdir('gdk-pixbuf') diff --git a/tests/gen-installed-test.py b/tests/gen-installed-test.py deleted file mode 100644 index 745abf339..000000000 --- a/tests/gen-installed-test.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -import argparse - -def write_template(filename, data): - with open(filename, 'w') as f: - f.write(data) - -def build_template(bindir, binname): - return "[Test]\nType=session\nExec={}\n".format(os.path.join(bindir, binname)) - -argparser = argparse.ArgumentParser(description='Generate installed-test data.') -argparser.add_argument('--testbindir', metavar='dir', help='Installed test directory') -argparser.add_argument('--testbin', metavar='name', help='Installed test name') -argparser.add_argument('output', help='Output file') - -args = argparser.parse_args() - -write_template(args.output, build_template(args.testbindir, args.testbin)) diff --git a/tests/gen-resources.py b/tests/gen-resources.py deleted file mode 100644 index 4c182d9cf..000000000 --- a/tests/gen-resources.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 - -# Ancillary wrapper around glib-compile-resources that sets up a -# modified environment in order to use the tools that we just -# built instead of the system ones - -import argparse -import os -import subprocess -import sys - -argparser = argparse.ArgumentParser(description='Compile resources') -argparser.add_argument('--pixdata', metavar='PATH', help='Path to gdk-pixbuf-pixdata') -argparser.add_argument('--loaders', metavar='PATH', help='Path to the loaders.cache file') -argparser.add_argument('--sourcedir', metavar='PATH', help='Path to the source directory') -argparser.add_argument('resource', help='GResource XML file') -argparser.add_argument('output', help='Output file') - -group = argparser.add_mutually_exclusive_group() -group.add_argument('--header', help='Generate header file', action='store_true') -group.add_argument('--source', help='Generate source file', action='store_true') - -args = argparser.parse_args() - -cmd = ['glib-compile-resources'] -if args.header: - cmd += ['--generate-header'] -else: - cmd += ['--generate-source'] - -cmd += ['--sourcedir', args.sourcedir] -cmd += [args.resource] -cmd += ['--target', args.output] - -newenv = os.environ.copy() -newenv['GDK_PIXBUF_PIXDATA'] = args.pixdata -newenv['GDK_PIXBUF_MODULE_FILE'] = args.loaders - -out, err = subprocess.Popen(cmd, env=newenv).communicate() -if out is None: - sys.exit(0) -else: - print(out) - sys.exit(1) diff --git a/tests/meson.build b/tests/meson.build index 50d4b1d19..a40ea9413 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,7 +1,6 @@ # Resources; we cannot use gnome.compile_resources() here, because we need to # override the environment in order to use the utilities we just built instead # of the system ones -gen_resources = find_program('gen-resources.py') resources_c = custom_target('resources.c', input: 'resources.gresource.xml', output: 'resources.c', @@ -83,8 +82,6 @@ test_data = [ 'aero.gif', ] -gen_installed_test = find_program('gen-installed-test.py') - installed_test_bindir = join_paths(gdk_pixbuf_libexecdir, 'installed-tests', gdk_pixbuf_api_name) installed_test_datadir = join_paths(gdk_pixbuf_datadir, 'installed-tests', gdk_pixbuf_api_name) diff --git a/thumbnailer/gen-thumbnailer.py b/thumbnailer/gen-thumbnailer.py deleted file mode 100644 index 9994043f9..000000000 --- a/thumbnailer/gen-thumbnailer.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -# Ancillary wrapper around gdk-pixbuf-print-mime-types that sets up a -# modified environment in order to use the tools that we just built -# instead of the system ones - -import argparse -import os -import subprocess -import sys - -argparser = argparse.ArgumentParser(description='Compile resources') -argparser.add_argument('--printer', metavar='PATH', help='Path to gdk-pixbuf-print-mime-types') -argparser.add_argument('--pixdata', metavar='PATH', help='Path to gdk-pixbuf-pixdata') -argparser.add_argument('--loaders', metavar='PATH', help='Path to the loaders.cache file') -argparser.add_argument('--bindir', metavar='PATH', help='Path to the source directory') -argparser.add_argument('input', help='Template file') -argparser.add_argument('output', help='Output file') - -args = argparser.parse_args() - -newenv = os.environ.copy() -newenv['GDK_PIXBUF_PIXDATA'] = args.pixdata -newenv['GDK_PIXBUF_MODULE_FILE'] = args.loaders - -cmd = args.printer - -mimetypes_out = subprocess.Popen(cmd, env=newenv, stdout=subprocess.PIPE).communicate()[0] -if not mimetypes_out: - sys.exit(1) - -infile = open(args.input, 'r') -outfile = open(args.output, 'w') - -for line in infile: - line = line.replace('@bindir@', args.bindir) - line = line.replace('@mimetypes@', mimetypes_out.decode('ascii')) - outfile.write(line) - -infile.close() -outfile.close() - -sys.exit(0) diff --git a/thumbnailer/meson.build b/thumbnailer/meson.build index 6a2fd2ac5..e80114491 100644 --- a/thumbnailer/meson.build +++ b/thumbnailer/meson.build @@ -12,7 +12,6 @@ gdk_pixbuf_print_mime_types = executable('gdk-pixbuf-print-mime-types', c_args: common_cflags, dependencies: gdk_pixbuf_deps + [ gdkpixbuf_dep ]) -gen_thumbnailer = find_program('gen-thumbnailer.py') custom_target('thumbnailer', input: 'gdk-pixbuf-thumbnailer.thumbnailer.in', output: 'gdk-pixbuf-thumbnailer.thumbnailer', -- cgit v1.2.1