gtk2/gdk/broadway/gen-c-array.py
Chun-wei Fan c1e40a5fbd meson: Really fix Broadway builds
We must also feed rawinflate.min.js into gen-c-array.py, so that the
windows really show up in the browser when running GTK programs using
broadway.
2019-04-11 16:45:36 +02:00

23 lines
711 B
Python

#!/usr/bin/env python3
import argparse
import sys
parser = argparse.ArgumentParser()
parser.add_argument('--array-name', help='The name of the array variable')
parser.add_argument('--output', metavar='FILE', help='Output file',
type=argparse.FileType('w'),
default=sys.stdout)
parser.add_argument('input', metavar='FILE', help='The input file',
type=argparse.FileType('r'), nargs='+')
args = parser.parse_args()
args.output.write('static const char {}[] = {{\n'.format(args.array_name))
for input in args.input:
for line in input:
for ch in line:
args.output.write(' 0x{:02x},\n'.format(ord(ch)))
args.output.write('};')