mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
meson: Simplify the use of built tools
The Meson build has fallen a bit behind the Autotools one, when it comes to the internally built tools like glib-mkenums and glib-genmarshals. We don't need to generate gmarshal.strings any more, and since the glib-genmarshal tool is now written in Python it can also be used when cross-compiling, and without indirection, just like we use glib-mkenums. We can also coalesce various rules into a simple array iteration, with minimal changes to glib-mkenums, thus making the build a bit more resilient and without unnecessary duplication.
This commit is contained in:
parent
7ee050dc4b
commit
3c03cc8f68
@ -15,6 +15,13 @@ import re
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
VERSION_STR = '''glib-mkenums version @VERSION@
|
||||
glib-genmarshal comes with ABSOLUTELY NO WARRANTY.
|
||||
You may redistribute copies of glib-genmarshal under the terms of
|
||||
the GNU General Public License which can be found in the
|
||||
GLib source package. Sources, examples and contact
|
||||
information are available at http://www.gtk.org'''
|
||||
|
||||
output_stream = sys.stdout
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
@ -64,8 +71,6 @@ def write_output(output):
|
||||
global output_stream
|
||||
print(output, file=output_stream)
|
||||
|
||||
version = '@GLIB_VERSION@'
|
||||
|
||||
# glib-mkenums.py
|
||||
# Information about the current enumeration
|
||||
flags = False # Is enumeration a bitmask?
|
||||
@ -190,15 +195,6 @@ def parse_entries(file, file_name):
|
||||
sys.exit("Failed to parse %s." % file_name)
|
||||
return False
|
||||
|
||||
def print_version():
|
||||
print("glib-mkenums version glib-" + version)
|
||||
print("glib-mkenums comes with ABSOLUTELY NO WARRANTY.")
|
||||
print("You may redistribute copies of glib-mkenums under the terms of")
|
||||
print("the GNU General Public License which can be found in the")
|
||||
print("GLib source package. Sources, examples and contact")
|
||||
print("information are available at http://www.gtk.org")
|
||||
sys.exit(0)
|
||||
|
||||
help_epilog = '''Production text substitutions:
|
||||
\u0040EnumName\u0040 PrefixTheXEnum
|
||||
\u0040enum_name\u0040 prefix_the_xenum
|
||||
@ -306,7 +302,8 @@ parser.add_argument('args', nargs='*')
|
||||
options = parser.parse_args()
|
||||
|
||||
if options.version:
|
||||
print_version()
|
||||
print(VERSION_STR)
|
||||
sys.exit(0)
|
||||
|
||||
def unescape_cmdline_args(arg):
|
||||
arg = arg.replace('\\n', '\n')
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# Does the same thing as `marshal-genstrings.pl` and the 'gmarshal.strings'
|
||||
# target in Makefile.am
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
prefix = '"g_cclosure_marshal_'
|
||||
suffix = '",\n'
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print('Usage: {0} <input> <output>'.format(sys.argv[0]))
|
||||
|
||||
fin = open(sys.argv[1], 'r')
|
||||
fout = open(sys.argv[2], 'w')
|
||||
|
||||
for line in fin:
|
||||
if not line[0].isalpha():
|
||||
continue
|
||||
symbol = line[:-1].replace(':', '__').replace(',', '_')
|
||||
fout.write(prefix + symbol + suffix)
|
@ -66,35 +66,34 @@ libgobject = shared_library('gobject-2.0',
|
||||
libgobject_dep = declare_dependency(link_with : libgobject,
|
||||
include_directories : gobjectinc)
|
||||
|
||||
glib_mkenums_conf = configuration_data()
|
||||
glib_mkenums_conf.set('GLIB_VERSION', glib_version)
|
||||
glib_mkenums_conf.set('PYTHON', python.path())
|
||||
python_tools = [
|
||||
'glib-genmarshal',
|
||||
'glib-mkenums',
|
||||
]
|
||||
|
||||
# FIXME: Set permissions
|
||||
glib_mkenums = configure_file(input : 'glib-mkenums.in',
|
||||
output : 'glib-mkenums',
|
||||
install : true,
|
||||
install_dir : 'bin', configuration : glib_mkenums_conf)
|
||||
python_tools_conf = configuration_data()
|
||||
python_tools_conf.set('VERSION', glib_version)
|
||||
python_tools_conf.set('PYTHON', python.path())
|
||||
|
||||
foreach tool: python_tools
|
||||
# FIXME: Ensure we set the appropriate permissions
|
||||
tool_bin = configure_file(
|
||||
input : tool + '.in',
|
||||
output : tool,
|
||||
configuration : python_tools_conf,
|
||||
install : true,
|
||||
install_dir : glib_bindir,
|
||||
)
|
||||
|
||||
# Set variables for later use
|
||||
set_variable(tool.underscorify(), tool_bin)
|
||||
endforeach
|
||||
|
||||
executable('gobject-query', 'gobject-query.c',
|
||||
install : true,
|
||||
c_args : ['-DHAVE_CONFIG_H=1'],
|
||||
dependencies : [libglib_dep, libgobject_dep])
|
||||
|
||||
gmarshal_strings = custom_target('gmarshal.strings',
|
||||
input : ['gmarshal-list-to-strings.py', 'gmarshal.list'],
|
||||
output : ['gmarshal.strings'],
|
||||
command : [python, '@INPUT0@', '@INPUT1@', '@OUTPUT@'])
|
||||
|
||||
glib_genmarshal_conf = configuration_data()
|
||||
glib_genmarshal_conf.set('VERSION', glib_version)
|
||||
glib_genmarshal_conf.set('PYTHON', python.path())
|
||||
|
||||
glib_genmarshal = configure_file(input : 'glib-genmarshal.in',
|
||||
output : 'glib-genmarshal',
|
||||
install : true,
|
||||
install_dir : 'bin', configuration : glib_genmarshal_conf)
|
||||
|
||||
install_data('gobject_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
|
||||
gdb_conf = configuration_data()
|
||||
gdb_conf.set('datadir', glib_datadir)
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# FIXME: where does the #include "marshalers.h" go?
|
||||
|
||||
import sys, subprocess
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print('Usage: {0} <listname> <outputfile>')
|
||||
sys.exit(0)
|
||||
|
||||
glib_genmarshal = sys.argv[1]
|
||||
listname = sys.argv[2]
|
||||
outname = sys.argv[3]
|
||||
|
||||
if outname.endswith('.h'):
|
||||
arg = '--header'
|
||||
else:
|
||||
arg = '--body'
|
||||
|
||||
output = subprocess.check_output([glib_genmarshal, '--prefix=test', '--valist-marshallers', arg, listname])
|
||||
open(outname, 'wb').write(output)
|
@ -44,26 +44,37 @@ foreach test_name : gobject_tests
|
||||
test(test_name, exe, env : test_env)
|
||||
endforeach
|
||||
|
||||
# The marshalers test requires running a binary, so we cannot build it when
|
||||
# cross-compiling
|
||||
if not meson.has_exe_wrapper()
|
||||
genmarshal = find_program('gobject_test_marshal.py')
|
||||
marshalers_h = custom_target('marshalers_h',
|
||||
output : 'marshalers.h',
|
||||
input : 'marshalers.list',
|
||||
command : [
|
||||
python, glib_genmarshal,
|
||||
'--prefix=test',
|
||||
'--valist-marshallers',
|
||||
'--output=@OUTPUT@',
|
||||
'--quiet',
|
||||
'--header',
|
||||
'@INPUT@',
|
||||
],
|
||||
)
|
||||
marshalers_c = custom_target('marshalers_c',
|
||||
output : 'marshalers.c',
|
||||
input : 'marshalers.list',
|
||||
command : [
|
||||
python, glib_genmarshal,
|
||||
'--prefix=test',
|
||||
'--valist-marshallers',
|
||||
'--include-header=marshalers.h',
|
||||
'--output=@OUTPUT@',
|
||||
'--quiet',
|
||||
'--body',
|
||||
'@INPUT@',
|
||||
],
|
||||
)
|
||||
|
||||
marshalers_h = custom_target('marshalers_h',
|
||||
output : 'marshalers.h',
|
||||
input : 'marshalers.list',
|
||||
command : [genmarshal, glib_genmarshal, '@INPUT@', '@OUTPUT@'],
|
||||
)
|
||||
marshalers_c = custom_target('marshalers_c',
|
||||
output : 'marshalers.c',
|
||||
input : 'marshalers.list',
|
||||
command : [genmarshal, glib_genmarshal, '@INPUT@', '@OUTPUT@'],
|
||||
)
|
||||
|
||||
exe = executable('signals',
|
||||
'signals.c', marshalers_h, marshalers_c,
|
||||
c_args : ['-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib-GObject"'],
|
||||
dependencies : deps,
|
||||
)
|
||||
test('signals', exe, env : test_env)
|
||||
endif
|
||||
exe = executable('signals',
|
||||
'signals.c', marshalers_h, marshalers_c,
|
||||
c_args : ['-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib-GObject"'],
|
||||
dependencies : deps,
|
||||
)
|
||||
test('signals', exe, env : test_env)
|
||||
|
@ -49,6 +49,7 @@ gmoduleinc = include_directories('gmodule')
|
||||
gioinc = include_directories('gio')
|
||||
|
||||
glib_prefix = get_option('prefix')
|
||||
glib_bindir = join_paths(glib_prefix, get_option('bindir'))
|
||||
glib_libdir = join_paths(glib_prefix, get_option('libdir'))
|
||||
glib_datadir = join_paths(glib_prefix, get_option('datadir'))
|
||||
glib_pkgdatadir = join_paths(glib_datadir, 'glib-2.0')
|
||||
|
@ -31,7 +31,7 @@ foreach t : gobject_tests
|
||||
test_timeout = t.get(3, 30)
|
||||
|
||||
# FIXME? $(GLIB_DEBUG_FLAGS)
|
||||
exe = executable(test_name, test_src,
|
||||
exe = executable(test_name + '-gobject', test_src,
|
||||
c_args : test_cargs + test_extra_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS'],
|
||||
dependencies : [libm, thread_dep, libglib_dep, libgobject_dep],
|
||||
install : false,
|
||||
|
Loading…
Reference in New Issue
Block a user