diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2017-08-03 13:15:04 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2017-08-03 13:19:47 +0100 |
commit | b09e4ca69b4dca6fd9d2e98a3722d765f86c837f (patch) | |
tree | 6b8044d29eaaf43066fce365eeb6e1f37111848c /build-aux | |
parent | 861a6dbea289d1ed98af1f66eb8024bc04464bd9 (diff) | |
download | gdk-pixbuf-b09e4ca69b4dca6fd9d2e98a3722d765f86c837f.tar.gz |
Move all aux scripts to their own directory
This makes it easier to find them and reference them.
Diffstat (limited to 'build-aux')
-rwxr-xr-x | build-aux/gen-color-table.pl | 74 | ||||
-rw-r--r-- | build-aux/gen-installed-test.py | 21 | ||||
-rw-r--r-- | build-aux/gen-resources.py | 44 | ||||
-rw-r--r-- | build-aux/gen-thumbnailer.py | 43 |
4 files changed, 182 insertions, 0 deletions
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($_ = <IN>)) { + 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 <<EOT; +/* xpm-color-table.h: Generated by gen-color-table.pl from rgb.txt + * + * Date: $date + * + * Do not edit. + */ +static const char color_names[] = +EOT + +for $color (@colors) { + $name = $color->[3]; + + if ($offset != 0) { + print qq(\n); + } + print qq( "$name\\0"); + + $color->[4] = $offset; + $offset += length($name) + 1; +} + +print ";\n\n"; + +print <<EOT; +typedef struct { + guint16 name_offset; + guchar red; + guchar green; + guchar blue; +} XPMColorEntry; + +static const XPMColorEntry xColors[] = { +EOT + +$i = 0; +for $color (@colors) { + $red = $color->[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) |