]> err.no Git - systemd/commitdiff
build-sys: allow cross-compilation
authorThierry Reding <thierry.reding@avionic-design.de>
Tue, 23 Nov 2010 20:12:11 +0000 (21:12 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 23 Nov 2010 21:38:55 +0000 (22:38 +0100)
When cross-compiling systemd, the introspection XML files fail to be
generated because the systemd host binary is not executable. This patch
works around this by putting the introspection XML data into separate
ELF sections and extracting them from the binary when generating the XML
files.

The extracted XML data is passed through the strings utility in order to
strip the trailing NUL character. A small AWK script is used to prepend
the doctype and add the opening and closing node tags respectively.
Finally, the C preprocessor is used to substitute the correct doctype
information from the D-Bus header files.

17 files changed:
Makefile.am
configure.ac
introspect.awk [new file with mode: 0644]
src/dbus-automount.c
src/dbus-device.c
src/dbus-job.c
src/dbus-manager.c
src/dbus-mount.c
src/dbus-path.c
src/dbus-service.c
src/dbus-snapshot.c
src/dbus-socket.c
src/dbus-swap.c
src/dbus-target.c
src/dbus-timer.c
src/dbus-unit.c
src/macro.h

index 4330db06dddf06712bb718c5d7c700d2ff2daf26..694ec57a9b89d154b704be767514d6f379f6b28b 100644 (file)
@@ -1118,8 +1118,12 @@ CLEANFILES += \
        ${XML_IN_FILES:.xml.in=.html.in}
 endif
 
+DBUS_PREPROCESS = $(CPP) -P $(DBUS_CFLAGS) -imacros dbus/dbus-protocol.h
+
 org.freedesktop.systemd1.%.xml: systemd
-       $(AM_V_GEN)SYSTEMD_SKIP_API_MOUNTS=1 ./systemd --introspect=${@:.xml=} > $@
+       $(AM_V_GEN)$(OBJCOPY) -O binary -j introspect.$* $< $@.tmp && \
+               $(STRINGS) $@.tmp | $(AWK) -f introspect.awk | \
+               $(DBUS_PREPROCESS) -o $@ - && rm $@.tmp
 
 CLEANFILES += \
        $(dbusinterface_DATA)
index 247806d747a17ebec3697a74817b0dbaef30cbed..f9f5eeea3bf0f0501362d40287d4a07485d625f2 100644 (file)
@@ -48,6 +48,9 @@ AM_PROG_CC_C_O
 AC_PROG_GCC_TRADITIONAL
 AC_USE_SYSTEM_EXTENSIONS
 
+AC_CHECK_TOOL(OBJCOPY, objcopy)
+AC_CHECK_TOOL(STRINGS, strings)
+
 CC_CHECK_CFLAGS_APPEND([ \
         -pipe \
         -Wall \
diff --git a/introspect.awk b/introspect.awk
new file mode 100644 (file)
index 0000000..5931913
--- /dev/null
@@ -0,0 +1,13 @@
+BEGIN {
+       print "<!DOCTYPE node PUBLIC DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER"
+       print "DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER>"
+       print "<node>"
+}
+
+// {
+       print
+}
+
+END {
+       print "</node>"
+}
index 3bccb4e5f735df83e46679a6d03d5276178f7c13..af277af39c77f317cbfe63b92770ecc25892c697 100644 (file)
@@ -38,7 +38,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                 \
         "</node>\n"
 
-const char bus_automount_interface[] = BUS_AUTOMOUNT_INTERFACE;
+const char bus_automount_interface[] _introspect_("Automount") = BUS_AUTOMOUNT_INTERFACE;
 
 DBusHandlerResult bus_automount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
         const BusProperty properties[] = {
index fcb05a441e6cb24837aed7b75ccb87eccce07549..aafe5d61fa010150533efd1a96f78ebc17b5640a 100644 (file)
@@ -37,7 +37,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_device_interface[] = BUS_DEVICE_INTERFACE;
+const char bus_device_interface[] _introspect_("Device") = BUS_DEVICE_INTERFACE;
 
 const char bus_device_invalidating_properties[] =
         "SysFSPath\0"
index 667eb04a69907ff2b2bfc1f004a9617b869e3eb1..18da72d67a1ded5e7aa9cd8f03ae264883e91dc0 100644 (file)
@@ -43,7 +43,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                  \
         "</node>\n"
 
-const char bus_job_interface[] = BUS_JOB_INTERFACE;
+const char bus_job_interface[] _introspect_("Job") = BUS_JOB_INTERFACE;
 
 #define INVALIDATING_PROPERTIES                 \
         "State\0"                               \
index 28986e54269b7600e9f347b072c5e0e155e584ec..d160e7bba35f8dac23a072d7ddbf1f3e075307cb 100644 (file)
 #define INTROSPECTION_END                                               \
         "</node>\n"
 
-const char bus_manager_interface[] = BUS_MANAGER_INTERFACE;
+const char bus_manager_interface[] _introspect_("Manager") = BUS_MANAGER_INTERFACE;
 
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_running_as, manager_running_as, ManagerRunningAs);
 
index 4de00f7fac38d3b73614d53eb19e021d6e23e014..fa319febd59cc761506ce8db7505f3337a1f50c5 100644 (file)
@@ -50,7 +50,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_mount_interface[] = BUS_MOUNT_INTERFACE;
+const char bus_mount_interface[] _introspect_("Mount") = BUS_MOUNT_INTERFACE;
 
 const char bus_mount_invalidating_properties[] =
         "What\0"
index c8c302ab3737cbbd91539abe7e2312c0cfd78400..9692d6a247a6f0d8e52b8714c6b217b9d305568c 100644 (file)
@@ -41,7 +41,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_path_interface[] = BUS_PATH_INTERFACE;
+const char bus_path_interface[] _introspect_("Path") = BUS_PATH_INTERFACE;
 
 static int bus_path_append_paths(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Path *p = data;
index a79f769e9405c3c27e7f2db3a5146f1b32bce37b..f929627666eb5202f23ac6302c2a7cc8a69ad816 100644 (file)
@@ -90,7 +90,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_service_interface[] = BUS_SERVICE_INTERFACE;
+const char bus_service_interface[] _introspect_("Service") = BUS_SERVICE_INTERFACE;
 
 const char bus_service_invalidating_properties[] =
         "ExecStartPre\0"
index efaec7df3dcc613734247fb20b808eb4be83308a..a9903ec484ef19297f07d73e50bb1144f4b311cd 100644 (file)
@@ -38,7 +38,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_snapshot_interface[] = BUS_SNAPSHOT_INTERFACE;
+const char bus_snapshot_interface[] _introspect_("Snapshot") = BUS_SNAPSHOT_INTERFACE;
 
 DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
         const BusProperty properties[] = {
index 5931f006c202f75957b5958c9aea0dfcb4dcb288..a9cb1c38f8b8c0c604a0d9283b4229683fae4653 100644 (file)
@@ -64,7 +64,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_socket_interface[] = BUS_SOCKET_INTERFACE;
+const char bus_socket_interface[] _introspect_("Socket") = BUS_SOCKET_INTERFACE;
 
 const char bus_socket_invalidating_properties[] =
         "ExecStartPre\0"
index 70cccdcab8f41e379b0c3ee627383613f9227a2d..06acb22dccff33816f74604bab37ba47615d2d44 100644 (file)
@@ -47,7 +47,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_swap_interface[] = BUS_SWAP_INTERFACE;
+const char bus_swap_interface[] _introspect_("Swap") = BUS_SWAP_INTERFACE;
 
 const char bus_swap_invalidating_properties[] =
         "What\0"
index 69e82120764e7f8365ef102934287a3b7667e2bf..1eb3c249f87d6bea15e10b0c3a94ca3c3a2aad31 100644 (file)
@@ -38,7 +38,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_target_interface[] = BUS_TARGET_INTERFACE;
+const char bus_target_interface[] _introspect_("Target") = BUS_TARGET_INTERFACE;
 
 DBusHandlerResult bus_target_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
         const BusProperty properties[] = {
index e57e97303ae97fd0fc469ce9cbd6bf18cf93a88e..56044661e7f09fed01d776b2db163d68dd6c4087 100644 (file)
@@ -42,7 +42,7 @@
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
-const char bus_timer_interface[] = BUS_TIMER_INTERFACE;
+const char bus_timer_interface[] _introspect_("Timer") = BUS_TIMER_INTERFACE;
 
 const char bus_timer_invalidating_properties[] =
         "Timers\0"
index 47aa8d338c34ac81aa23b32877f4aad396eb8140..835eeda3292494b06bffaf623024eb235c074e13 100644 (file)
@@ -26,7 +26,7 @@
 #include "dbus-unit.h"
 #include "bus-errors.h"
 
-const char bus_unit_interface[] = BUS_UNIT_INTERFACE;
+const char bus_unit_interface[] _introspect_("Unit") = BUS_UNIT_INTERFACE;
 
 #define INVALIDATING_PROPERTIES                 \
         "LoadState\0"                           \
index b3da60f13e51e926c967c5c07c0222080861a801..85a7fbccfdb4a8dd153780368859ebac08657047 100644 (file)
@@ -45,6 +45,7 @@
 #define _public_ __attribute__ ((visibility("default")))
 #define _hidden_ __attribute__ ((visibility("hidden")))
 #define _weakref_(x) __attribute__((weakref(#x)))
+#define _introspect_(x) __attribute__((section("introspect." x)))
 
 /* Rounds up */
 static inline size_t ALIGN(size_t l) {