build: Only run each instance of gdbus-codegen once

A rule of the form

    foo.c foo.h: foo.in
        some-generator --output=foo foo.in

is essentially equivalent to writing the same rule once for each target:

    foo.c: foo.in
        some-generator --output=foo foo.in
    foo.h: foo.in
        some-generator --output=foo foo.in

In a parallel build, this can result in some-generator being run more
than once with the same inputs and outputs, leading to unpredictable
results if the outputs are overwritten in-place by two parallel copies
(particularly if the generator does not use the standard atomic-writing
trick of writing out a temporary file and renaming it over the top of
the intended name, which gdbus-codegen does not).

gdbus-codegen happens to write the .h file before the .c file, so
use the real build rules to generate the .c file, and consider the
.h file to be a side-effect.

Signed-off-by: Simon McVittie <smcv@collabora.com>
tingping/wmclass
Simon McVittie 2017-06-30 13:31:35 +01:00 committed by Alexander Larsson
parent 8776d3c1f8
commit f4c4abfb1e
3 changed files with 13 additions and 4 deletions

View File

@ -3,7 +3,7 @@ noinst_LTLIBRARIES += libflatpak-common.la
dbus_built_sources = common/flatpak-dbus.c common/flatpak-dbus.h
systemd_dbus_built_sources = common/flatpak-systemd-dbus.c common/flatpak-systemd-dbus.h
$(dbus_built_sources) : data/org.freedesktop.Flatpak.xml
common/flatpak-dbus.c: data/org.freedesktop.Flatpak.xml
mkdir -p $(builddir)/common
$(AM_V_GEN) $(GDBUS_CODEGEN) \
--interface-prefix org.freedesktop.Flatpak. \
@ -12,7 +12,7 @@ $(dbus_built_sources) : data/org.freedesktop.Flatpak.xml
$(srcdir)/data/org.freedesktop.Flatpak.xml \
$(NULL)
$(systemd_dbus_built_sources) : data/org.freedesktop.systemd1.xml
common/flatpak-systemd-dbus.c: data/org.freedesktop.systemd1.xml
mkdir -p $(builddir)/common
$(AM_V_GEN) $(GDBUS_CODEGEN) \
--interface-prefix org.freedesktop.systemd1. \
@ -21,6 +21,9 @@ $(systemd_dbus_built_sources) : data/org.freedesktop.systemd1.xml
$(srcdir)/data/org.freedesktop.systemd1.xml \
$(NULL)
common/%-dbus.h: common/%-dbus.c
@true # Built as a side-effect of the rules for the .c
nodist_libflatpak_common_la_SOURCES = \
$(dbus_built_sources) \
$(systemd_dbus_built_sources) \

View File

@ -5,7 +5,7 @@ libexec_PROGRAMS += \
xdp_dbus_built_sources = document-portal/xdp-dbus.c document-portal/xdp-dbus.h
BUILT_SOURCES += $(xdp_dbus_built_sources)
$(xdp_dbus_built_sources) : data/org.freedesktop.portal.Documents.xml
document-portal/xdp-dbus.c: data/org.freedesktop.portal.Documents.xml
mkdir -p $(builddir)/document-portal
$(AM_V_GEN) $(GDBUS_CODEGEN) \
--interface-prefix org.freedesktop.portal. \
@ -16,6 +16,9 @@ $(xdp_dbus_built_sources) : data/org.freedesktop.portal.Documents.xml
$(srcdir)/data/org.freedesktop.portal.Documents.xml \
$(NULL)
document-portal/%-dbus.h: document-portal/%-dbus.c
@true # Built as a side-effect of the rules for the .c
service_in_files += document-portal/xdg-document-portal.service.in
systemduserunit_DATA += document-portal/xdg-document-portal.service

View File

@ -12,7 +12,7 @@ nodist_xdg_permission_store_SOURCES = permission-store/permission-store-dbus.c p
BUILT_SOURCES += $(nodist_xdg_permission_store_SOURCES)
CLEANFILES += $(nodist_xdg_permission_store_SOURCES)
$(nodist_xdg_permission_store_SOURCES) : data/org.freedesktop.impl.portal.PermissionStore.xml
permission-store/permission-store-dbus.c: data/org.freedesktop.impl.portal.PermissionStore.xml
mkdir -p $(builddir)/permission-store
$(AM_V_GEN) $(GDBUS_CODEGEN) \
--interface-prefix org.freedesktop.impl.portal. \
@ -21,6 +21,9 @@ $(nodist_xdg_permission_store_SOURCES) : data/org.freedesktop.impl.portal.Permis
$(srcdir)/data/org.freedesktop.impl.portal.PermissionStore.xml \
$(NULL)
permission-store/%-dbus.h: permission-store/%-dbus.c
@true # Built as a side-effect of the rules for the .c
# also used by the document portal
ps_dbus_built_sources = $(nodist_xdg_permission_store_SOURCES)