Skip to content

Commit

Permalink
[WIP] meson: Provide our Python tools for builds
Browse files Browse the repository at this point in the history
Several of our tools are installed and are used by other projects to
generate code. However, there is no 'install' when projects use glib
as a subproject, so we needed some way for glib to 'provide' these
tools.

Starting from Meson 0.46, this can be done with the
meson.override_find_program() function. This also means that we can
use these tools ourselves via the GNOME module and don't need to
manually create command-lines.

WIP because it requires mesonbuild/meson#3218
  • Loading branch information
nirbheek committed Apr 15, 2018
1 parent 3ba2f83 commit 68e6abe
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 80 deletions.
3 changes: 3 additions & 0 deletions gio/gdbus-2.0/codegen/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ gdbus_codegen = configure_file(input : 'gdbus-codegen.in',
install_dir : get_option('bindir'),
configuration : gdbus_codegen_conf
)
# Provide gdbus-codegen for us (GNOME module)
# and for others when we're a subproject
meson.override_find_program('gdbus-codegen', gdbus_codegen)

codegen_dir = join_paths(get_option('datadir'), 'glib-2.0/codegen')

Expand Down
74 changes: 24 additions & 50 deletions gio/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -229,38 +229,24 @@ gdbus_sources = files(
subdir('gdbus-2.0/codegen')

# Generate xdp-dbus.{c,h}
xdp_dbus_generated = custom_target('xdp-dbus',
input : ['org.freedesktop.portal.Documents.xml',
'org.freedesktop.portal.OpenURI.xml',
'org.freedesktop.portal.NetworkMonitor.xml',
'org.freedesktop.portal.ProxyResolver.xml'],
output : ['xdp-dbus.h', 'xdp-dbus.c'],
depend_files : gdbus_codegen_built_files,
command : [python, gdbus_codegen,
'--interface-prefix', 'org.freedesktop.portal.',
'--output-directory', '@OUTDIR@',
'--generate-c-code', 'xdp-dbus',
'--c-namespace', 'GXdp',
'--annotate', 'org.freedesktop.portal.Documents.Add()',
'org.gtk.GDBus.C.UnixFD', 'true',
'--annotate', 'org.freedesktop.portal.Documents.AddNamed()',
'org.gtk.GDBus.C.UnixFD', 'true',
'--annotate', 'org.freedesktop.portal.Documents.AddFull()',
'org.gtk.GDBus.C.UnixFD', 'true',
'--annotate', 'org.freedesktop.portal.OpenURI.OpenFile()',
'org.gtk.GDBus.C.UnixFD', 'true',
'@INPUT@'])
xdp_dbus_generated = gnome.gdbus_codegen('xdp-dbus',
sources : ['org.freedesktop.portal.Documents.xml',
'org.freedesktop.portal.OpenURI.xml',
'org.freedesktop.portal.NetworkMonitor.xml',
'org.freedesktop.portal.ProxyResolver.xml'],
interface_prefix : 'org.freedesktop.portal.',
namespace: 'GXdp',
annotations : [
['org.freedesktop.portal.Documents.Add()', 'org.gtk.GDBus.C.UnixFD', 'true'],
['org.freedesktop.portal.Documents.AddNamed()', 'org.gtk.GDBus.C.UnixFD', 'true'],
['org.freedesktop.portal.Documents.AddFull()', 'org.gtk.GDBus.C.UnixFD', 'true'],
['org.freedesktop.portal.OpenURI.OpenFile()', 'org.gtk.GDBus.C.UnixFD', 'true']])

# Generate gdbus-generated.{c,h}
gdbus_daemon_generated = custom_target('gdbus-daemon-generated',
input : ['dbus-daemon.xml'],
output : ['gdbus-daemon-generated.h', 'gdbus-daemon-generated.c'],
depend_files : gdbus_codegen_built_files,
command : [python, gdbus_codegen,
'--interface-prefix', 'org.',
'--output-directory', '@OUTDIR@',
'--generate-c-code', 'gdbus-daemon-generated',
'--c-namespace', '_G', '@INPUT@'])
gdbus_daemon_generated = gnome.gdbus_codegen('gdbus-daemon-generated',
'dbus-daemon.xml',
interface_prefix: 'org.',
namespace: '_G')

settings_headers = files(
'gsettingsbackend.h',
Expand Down Expand Up @@ -714,27 +700,15 @@ gio_headers += settings_headers
gio_headers += gdbus_headers
install_headers(gio_headers, subdir : 'glib-2.0/gio/')

# We can't use gnome.mkenums() because the GNOME module looks for glib-mkenums
# in PATH, which means you can't bootstrap glib with its own glib-mkenums.
gioenumtypes_h = custom_target('gioenumtypes_h',
output : 'gioenumtypes.h',
capture : true,
input : gio_headers,
install : true,
install_dir : join_paths(get_option('includedir'), 'glib-2.0/gio'),
command : [python, glib_mkenums,
'--template', files('gioenumtypes.h.template'),
'@INPUT@', gnetworking_h])

gioenumtypes_c = custom_target('gioenumtypes_c',
output : 'gioenumtypes.c',
capture : true,
input : gio_headers,
depends : [gioenumtypes_h],
command : [python, glib_mkenums,
'--template', files('gioenumtypes.c.template'),
'@INPUT@', gnetworking_h])
gioenumtypes = gnome.mkenums('gioenumtypes',
sources : gio_headers,
h_template : 'gioenumtypes.h.template',
c_template : 'gioenumtypes.c.template',
install_header : true,
install_dir : join_paths(get_option('includedir'), 'glib-2.0/gio'))

gioenumtypes_c = gioenumtypes[0]
gioenumtypes_h = gioenumtypes[1]
gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h])

# inotify
Expand Down
5 changes: 3 additions & 2 deletions gobject/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ foreach tool: python_tools
install : true,
install_dir : glib_bindir,
)

# Set variables for later use
# Set variables for later use; by gio/tests/meson.build for example
set_variable(tool.underscorify(), tool_bin)
# Provide tools for us (GNOME module), and for others when we're a subproject
meson.override_find_program(tool, tool_bin)
endforeach

executable('gobject-query', 'gobject-query.c',
Expand Down
34 changes: 8 additions & 26 deletions gobject/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,16 @@ foreach test_name : gobject_tests
test(test_name, exe, env : test_env)
endforeach

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 = gnome.genmarshal('marshalers',
sources : 'marshalers.list',
prefix : 'test',
valist_marshallers : true,
extra_args : ['--quiet']
)

marshalers_c = marshalers[0]
marshalers_h = marshalers[1]

exe = executable('signals',
'signals.c', marshalers_h, marshalers_c,
c_args : ['-DG_LOG_DOMAIN="GLib-GObject"'],
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1776,9 +1776,10 @@ if want_systemtap and enable_dtrace
enable_systemtap = true
endif


pkg = import('pkgconfig')
windows = import('windows')
gnome = import('gnome')

subdir('glib')
subdir('gobject')
subdir('gthread')
Expand Down Expand Up @@ -1838,7 +1839,6 @@ if get_option('man')
man1_dir = get_option('mandir') + '/man1'
endif

gnome = import('gnome')
subdir('docs/reference/glib')
subdir('docs/reference/gobject')
subdir('docs/reference/gio')

0 comments on commit 68e6abe

Please sign in to comment.