From 14099ed04a693791dc6645566ee55a08be19a199 Mon Sep 17 00:00:00 2001 From: Felipe Sateler Date: Tue, 12 Feb 2019 20:29:42 -0300 Subject: [PATCH] build-sys: don't generate introspection xml by running the program Instead, embed the xml file into the binary. This should make both cross-compiling and editing the introspection xml easier. --- Makefile.am | 8 +++-- configure.ac | 1 + org.freedesktop.RealtimeKit1.xml | 42 +++++++++++++++++++++++++++ rtkit-daemon.c | 50 +++----------------------------- xml-introspection.S | 7 +++++ 5 files changed, 59 insertions(+), 49 deletions(-) create mode 100644 org.freedesktop.RealtimeKit1.xml create mode 100644 xml-introspection.S diff --git a/Makefile.am b/Makefile.am index 25aaa10..8fe24f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,6 +33,7 @@ EXTRA_DIST = \ org.freedesktop.RealtimeKit1.policy \ org.freedesktop.RealtimeKit1.conf \ org.freedesktop.RealtimeKit1.service.in \ + org.freedesktop.RealtimeKit1.xml \ rtkit-daemon.service.in CLEANFILES = \ @@ -60,7 +61,9 @@ systemdsystemunit_DATA = \ endif rtkit_daemon_SOURCES = \ - rtkit-daemon.c rtkit.h + rtkit-daemon.c \ + rtkit.h \ + xml-introspection.S rtkit_daemon_LDADD = \ $(DBUS_LIBS) \ $(LIBSYSTEMD_LIBS) @@ -91,8 +94,7 @@ org.freedesktop.RealtimeKit1.service: org.freedesktop.RealtimeKit1.service.in rtkit-daemon.service: rtkit-daemon.service.in $(AM_V_GEN)sed -e 's,@LIBEXECDIR\@,$(libexecdir),g' < $< > $@ -org.freedesktop.RealtimeKit1.xml: rtkit-daemon - $(AM_V_GEN)./$< --introspect > $@ +xml-introspection.o: org.freedesktop.RealtimeKit1.xml man8_MANS = rtkitctl.8 diff --git a/configure.ac b/configure.ac index 1e62ebc..aafff94 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,7 @@ AM_PROG_CC_C_O AC_PROG_GCC_TRADITIONAL AC_USE_SYSTEM_EXTENSIONS AC_SYS_LARGEFILE +AM_PROG_AS # GCC flags diff --git a/org.freedesktop.RealtimeKit1.xml b/org.freedesktop.RealtimeKit1.xml new file mode 100644 index 0000000..305e767 --- /dev/null +++ b/org.freedesktop.RealtimeKit1.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rtkit-daemon.c b/rtkit-daemon.c index 205478b..6884644 100644 --- a/rtkit-daemon.c +++ b/rtkit-daemon.c @@ -67,48 +67,8 @@ #define RLIMIT_RTTIME 15 #endif -#define INTROSPECT_XML \ - DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \ - "\n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n"\ - " " \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - " \n" \ - "\n" +/* The introspection XML from org.freedesktop.RealtimeKit1.xml (via xml-introspection.S) */ +extern const char introspect_xml[]; /* Similar to assert(), but has side effects, and hence shall never be optimized away, regardless of NDEBUG */ #define assert_se(expr) \ @@ -1457,12 +1417,10 @@ static DBusHandlerResult dbus_handler(DBusConnection *c, DBusMessage *m, void *u interface)); } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) { - const char *xml = INTROSPECT_XML; - assert_se(r = dbus_message_new_method_return(m)); assert_se(dbus_message_append_args( r, - DBUS_TYPE_STRING, &xml, + DBUS_TYPE_STRING, &introspect_xml, DBUS_TYPE_INVALID)); } else return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -2256,7 +2214,7 @@ static int parse_command_line(int argc, char *argv[], int *ret) { break; case ARG_INTROSPECT: - fputs(INTROSPECT_XML, stdout); + fputs(introspect_xml, stdout); *ret = 0; return 0; diff --git a/xml-introspection.S b/xml-introspection.S new file mode 100644 index 0000000..4bd2355 --- /dev/null +++ b/xml-introspection.S @@ -0,0 +1,7 @@ +.section .rodata +.global introspect_xml +.type introspect_xml, @object + +introspect_xml: +.incbin "org.freedesktop.RealtimeKit1.xml" +.byte 0