[gtk] Rewrite toarray Perl script to Python
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Rewrite toarray Perl script to Python
- Date: Wed, 14 Feb 2018 15:57:07 +0000 (UTC)
commit 7f25cc9d4efab4b54ca4c1269cd9d7de70c47e70
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Feb 14 15:51:45 2018 +0000
Rewrite toarray Perl script to Python
We don't need to shell out to Perl to generate a C array out of a text
file.
gdk/broadway/gen-c-array.py | 21 +++++++++++++++++++++
gdk/broadway/meson.build | 22 +++++++++++++++++-----
gdk/broadway/toarray.pl | 24 ------------------------
3 files changed, 38 insertions(+), 29 deletions(-)
---
diff --git a/gdk/broadway/gen-c-array.py b/gdk/broadway/gen-c-array.py
new file mode 100644
index 0000000000..afffda34e5
--- /dev/null
+++ b/gdk/broadway/gen-c-array.py
@@ -0,0 +1,21 @@
+#!/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'))
+
+args = parser.parse_args()
+
+args.output.write('static const char {}[] = {{\n'.format(args.array_name))
+for line in args.input:
+ for ch in line:
+ args.output.write(' 0x{:02x},\n'.format(ord(ch)))
+
+args.output.write('};')
diff --git a/gdk/broadway/meson.build b/gdk/broadway/meson.build
index 614a623784..970b6c8e6c 100644
--- a/gdk/broadway/meson.build
+++ b/gdk/broadway/meson.build
@@ -28,11 +28,18 @@ gdk_broadway_public_headers = [
gdk_broadway_deps = [shmlib]
+gen_c_array = find_program('gen-c-array.py')
+
clienthtml_h = custom_target('clienthtml.h',
input : 'client.html',
output : 'clienthtml.h',
- command : [find_program('toarray.pl'), 'client_html', '@INPUT@'],
- capture : true)
+ command : [
+ gen_c_array,
+ '--array-name=client_html',
+ '--output=@OUTPUT@',
+ '@INPUT@',
+ ],
+)
libgdk_broadway = static_library('gdk-broadway',
clienthtml_h,
@@ -52,13 +59,18 @@ broadwayd_syslib = os_win32 ? find_library('ws2_32') : shmlib
broadwayjs_h = custom_target('broadwayjs.h',
input : ['broadway.js'],
output : 'broadwayjs.h',
- command : [find_program('toarray.pl'), 'broadway_js', '@INPUT0@'],
- capture : true)
+ command : [
+ gen_c_array,
+ '--array-name=broadway_js',
+ '--output=@OUTPUT@',
+ '@INPUT0@',
+ ],
+)
executable('gtk4-broadwayd',
clienthtml_h, broadwayjs_h,
'broadwayd.c', 'broadway-server.c', 'broadway-output.c',
- include_directories: [confinc, gdkinc],
+ include_directories: [confinc, gdkinc, include_directories('.')],
c_args: ['-DGDK_COMPILATION', '-DG_LOG_DOMAIN="Gdk"', ],
dependencies : [broadwayd_syslib, gdk_deps],
install : true)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]