build: Make D-Bus codegen declarative

This makes it a bit less cumbersome to add more D-Bus codegen
interfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2811>
This commit is contained in:
Jonas Ådahl 2023-01-27 16:42:15 +01:00
parent 8b92a00dd1
commit bef9cecb81
2 changed files with 93 additions and 66 deletions

View File

@ -857,27 +857,24 @@ if mutter_private_enum_sources.length() > 0
mutter_built_sources += mutter_private_enum_types mutter_built_sources += mutter_private_enum_types
endif endif
dbus_display_config_built_sources = gnome.gdbus_codegen('meta-dbus-display-config', dbus_interfaces = [
join_paths(dbus_interfaces_dir, 'org.gnome.Mutter.DisplayConfig.xml'), {
interface_prefix: 'org.gnome.Mutter.', 'name': 'meta-dbus-display-config',
namespace: 'MetaDBus', 'interface': 'org.gnome.Mutter.DisplayConfig.xml',
) 'prefix': 'org.gnome.Mutter.',
mutter_built_sources += dbus_display_config_built_sources },
{
dbus_idle_monitor_built_sources = gnome.gdbus_codegen('meta-dbus-idle-monitor', 'name': 'meta-dbus-idle-monitor',
join_paths(dbus_interfaces_dir, 'org.gnome.Mutter.IdleMonitor.xml'), 'interface': 'org.gnome.Mutter.IdleMonitor.xml',
interface_prefix: 'org.gnome.Mutter.', 'prefix': 'org.gnome.Mutter.',
namespace: 'MetaDBus', 'object_manager': true,
object_manager: true, },
) {
mutter_built_sources += dbus_idle_monitor_built_sources 'name': 'meta-dbus-input-mapping',
'interface': 'org.gnome.Mutter.InputMapping.xml',
dbus_input_mapping_built_sources = gnome.gdbus_codegen('meta-dbus-input-mapping', 'prefix': 'org.gnome.Mutter.',
join_paths(dbus_interfaces_dir, 'org.gnome.Mutter.InputMapping.xml'), },
interface_prefix: 'org.gnome.Mutter.', ]
namespace: 'MetaDBus',
)
mutter_built_sources += dbus_input_mapping_built_sources
if have_profiler if have_profiler
mutter_sources += [ mutter_sources += [
@ -885,13 +882,14 @@ if have_profiler
'core/meta-profiler.h', 'core/meta-profiler.h',
] ]
sysprof3_dbus_file = join_paths(sysprof_dbus_interfaces_dir, 'org.gnome.Sysprof3.Profiler.xml') dbus_interfaces += [
dbus_sysprof3_profiler_built_sources = gnome.gdbus_codegen('meta-dbus-sysprof3-profiler', {
sysprof3_dbus_file, 'name': 'meta-dbus-sysprof3-profiler',
interface_prefix: 'org.gnome.', 'interface': 'org.gnome.Sysprof3.Profiler.xml',
namespace: 'MetaDBus', 'prefix': 'org.gnome.',
) 'directory': sysprof_dbus_interfaces_dir,
mutter_built_sources += dbus_sysprof3_profiler_built_sources },
]
endif endif
if have_native_backend if have_native_backend
@ -904,50 +902,79 @@ if have_native_backend
) )
mutter_built_sources += default_modes_h mutter_built_sources += default_modes_h
dbus_login1_built_sources = gnome.gdbus_codegen('meta-dbus-login1', dbus_interfaces += [
join_paths(dbus_interfaces_dir, 'org.freedesktop.login1.xml'), {
interface_prefix: 'org.freedesktop.', 'name': 'meta-dbus-login1',
namespace: 'MetaDBus', 'interface': 'org.freedesktop.login1.xml',
) 'prefix': 'org.freedesktop.',
mutter_built_sources += dbus_login1_built_sources },
]
endif endif
if have_remote_desktop if have_remote_desktop
dbus_remote_desktop_built_sources = gnome.gdbus_codegen('meta-dbus-remote-desktop', dbus_interfaces += [
join_paths(dbus_interfaces_dir, 'org.gnome.Mutter.RemoteDesktop.xml'), {
interface_prefix: 'org.gnome.Mutter.', 'name': 'meta-dbus-remote-desktop',
namespace: 'MetaDBus', 'interface': 'org.gnome.Mutter.RemoteDesktop.xml',
) 'prefix': 'org.gnome.Mutter.',
mutter_built_sources += dbus_remote_desktop_built_sources },
{
dbus_screen_cast_built_sources = gnome.gdbus_codegen('meta-dbus-screen-cast', 'name': 'meta-dbus-screen-cast',
join_paths(dbus_interfaces_dir, 'org.gnome.Mutter.ScreenCast.xml'), 'interface': 'org.gnome.Mutter.ScreenCast.xml',
interface_prefix: 'org.gnome.Mutter.', 'prefix': 'org.gnome.Mutter.',
namespace: 'MetaDBus', },
) ]
mutter_built_sources += dbus_screen_cast_built_sources
endif endif
dbus_rtkit_built_sources = gnome.gdbus_codegen('meta-dbus-rtkit1', dbus_interfaces += [
join_paths(dbus_interfaces_dir, 'org.freedesktop.RealtimeKit1.xml'), {
interface_prefix: 'org.freedesktop.', 'name': 'meta-dbus-rtkit1',
namespace: 'MetaDBus', 'interface': 'org.freedesktop.RealtimeKit1.xml',
) 'prefix': 'org.freedesktop.',
mutter_built_sources += dbus_rtkit_built_sources },
{
'name': 'meta-dbus-gsd-color',
'interface': 'org.gnome.SettingsDaemon.Color.xml',
'prefix': 'org.gnome.',
},
{
'name': 'meta-dbus-gsd-power-screen',
'interface': 'org.gnome.SettingsDaemon.Power.Screen.xml',
'prefix': 'org.gnome.',
},
]
dbus_gsd_color_built_sources = gnome.gdbus_codegen('meta-dbus-gsd-color', built_dbus_sources = {}
join_paths(dbus_interfaces_dir, 'org.gnome.SettingsDaemon.Color.xml'),
interface_prefix: 'org.gnome.',
namespace: 'MetaDBus',
)
mutter_built_sources += dbus_gsd_color_built_sources
dbus_gsd_power_screen_built_sources = gnome.gdbus_codegen('meta-dbus-gsd-power-screen', foreach dbus_interface: dbus_interfaces
join_paths(dbus_interfaces_dir, 'org.gnome.SettingsDaemon.Power.Screen.xml'), name = dbus_interface['name']
interface_prefix: 'org.gnome.',
interface = dbus_interface['interface']
if dbus_interface.has_key('directory')
directory = dbus_interface['directory']
else
directory = dbus_interfaces_dir
endif
interface_file = join_paths(directory, interface)
prefix = dbus_interface['prefix']
if dbus_interface.has_key('object_manager')
object_manager = dbus_interface['object_manager']
else
object_manager = false
endif
dbus_sources = gnome.gdbus_codegen(name, interface_file,
interface_prefix: prefix,
namespace: 'MetaDBus', namespace: 'MetaDBus',
) object_manager: object_manager,
mutter_built_sources += dbus_gsd_power_screen_built_sources )
built_dbus_sources += {
name: dbus_sources,
}
mutter_built_sources += dbus_sources
endforeach
wayland_protocol_server_headers = [] wayland_protocol_server_headers = []
wayland_protocol_client_headers = [] wayland_protocol_client_headers = []

View File

@ -253,8 +253,8 @@ if have_native_tests
screen_cast_client = executable('mutter-screen-cast-client', screen_cast_client = executable('mutter-screen-cast-client',
sources: [ sources: [
'screen-cast-client.c', 'screen-cast-client.c',
dbus_remote_desktop_built_sources, built_dbus_sources['meta-dbus-remote-desktop'],
dbus_screen_cast_built_sources, built_dbus_sources['meta-dbus-screen-cast'],
], ],
include_directories: tests_includes, include_directories: tests_includes,
c_args: [ c_args: [