update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')
xml_helper_py = find_program('tools/xml_helper.py')
+export_dbus_interfaces_py = find_program('tools/dbus_exporter.py')
#####################################################################
# usually, but not always, installed in /bin.
public_programs = []
+# D-Bus introspection XML export
+dbus_programs = []
+dbus_interfaces_dir = get_option('dbus-interfaces-dir')
+if dbus_interfaces_dir == ''
+ dbus_interfaces_dir = get_option('datadir') + '/dbus-1'
+endif
+
tests = []
fuzzers = []
############################################################
-executable(
+dbus_programs += executable(
'systemd',
systemd_sources,
include_directories : includes,
endif
if conf.get('ENABLE_RESOLVE') == 1
- executable(
+ dbus_programs += executable(
'systemd-resolved',
systemd_resolved_sources,
include_directories : resolve_includes,
endif
if conf.get('ENABLE_LOGIND') == 1
- executable(
+ dbus_programs += executable(
'systemd-logind',
systemd_logind_sources,
include_directories : includes,
install_dir : rootbindir)
if conf.get('ENABLE_PORTABLED') == 1
- executable(
+ dbus_programs += executable(
'systemd-portabled',
systemd_portabled_sources,
include_directories : includes,
install : true,
install_dir : rootlibexecdir)
- executable(
+ dbus_programs += executable(
'systemd-homed',
systemd_homed_sources,
include_directories : home_includes,
endif
if conf.get('ENABLE_HOSTNAMED') == 1
- executable(
+ dbus_programs += executable(
'systemd-hostnamed',
'src/hostname/hostnamed.c',
include_directories : includes,
deps = []
endif
- executable(
+ dbus_programs += executable(
'systemd-localed',
systemd_localed_sources,
include_directories : includes,
endif
if conf.get('ENABLE_TIMEDATED') == 1
- executable(
+ dbus_programs += executable(
'systemd-timedated',
'src/timedate/timedated.c',
include_directories : includes,
endif
if conf.get('ENABLE_MACHINED') == 1
- executable(
+ dbus_programs += executable(
'systemd-machined',
systemd_machined_sources,
include_directories : includes,
endif
if conf.get('ENABLE_IMPORTD') == 1
- executable(
+ dbus_programs += executable(
'systemd-importd',
systemd_importd_sources,
include_directories : includes,
endif
if conf.get('ENABLE_OOMD') == 1
- executable('systemd-oomd',
+ dbus_programs += executable('systemd-oomd',
systemd_oomd_sources,
include_directories : includes,
link_with : [libshared],
alias_target('update-dbus-docs', update_dbus_docs)
alias_target('update-man-rules', update_man_rules)
+custom_target(
+ 'export-dbus-interfaces',
+ output : 'interfaces',
+ install : dbus_interfaces_dir != 'no',
+ install_dir : dbus_interfaces_dir,
+ command : [export_dbus_interfaces_py, '@OUTPUT@', dbus_programs])
+
############################################################
alt_time_epoch = run_command('date', '-Is', '-u', '-d', '@@0@'.format(time_epoch),
--- /dev/null
+#!/usr/bin/env python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+from argparse import ArgumentParser
+from pathlib import Path
+from subprocess import run, PIPE
+
+
+def extract_interfaces_xml(output_dir, executable):
+ list_interfaces_process = run(
+ args=[executable.absolute(), '--bus-introspect', 'list'],
+ stdout=PIPE,
+ check=True,
+ universal_newlines=True,
+ )
+
+ interfaces_lines = list_interfaces_process.stdout.splitlines()
+
+ interface_names = [x.split()[1] for x in interfaces_lines]
+
+ for interface_name in interface_names:
+ interface_introspection_run = run(
+ args=[executable.absolute(), '--bus-introspect', interface_name],
+ stdout=PIPE,
+ check=True,
+ universal_newlines=True,
+ )
+
+ interface_file_name = output_dir / (interface_name + '.xml')
+ with open(interface_file_name, mode='w') as f:
+ f.write(interface_introspection_run.stdout)
+ interface_file_name.chmod(0o644)
+
+
+def iterate_executables(output_dir, executables):
+ output_dir.mkdir(mode=0o755, exist_ok=True)
+
+ for exe in executables:
+ extract_interfaces_xml(output_dir, exe)
+
+
+def main():
+ parser = ArgumentParser()
+
+ parser.add_argument(
+ 'output',
+ type=Path,
+ )
+
+ parser.add_argument(
+ 'executables',
+ type=Path,
+ nargs='+',
+ )
+
+ args = parser.parse_args()
+
+ iterate_executables(args.output, args.executables)
+
+
+if __name__ == '__main__':
+ main()