]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
build: Compile most bus/ files into static libraries
authorSimon McVittie <smcv@collabora.com>
Mon, 3 Sep 2018 22:27:29 +0000 (15:27 -0700)
committerSimon McVittie <smcv@collabora.com>
Mon, 21 Jan 2019 15:14:29 +0000 (15:14 +0000)
This means we can share them between tests without having to compile
the same file repeatedly, and makes them easier to share between
directories when we move test executables into test/.

Signed-off-by: Simon McVittie <smcv@collabora.com>
bus/Makefile.am
cmake/bus/CMakeLists.txt

index fe0f92b16b4f36ba895c433b40736cc56d960c3e..3b049df52155e51a86cb552f27e32438cf5a9665 100644 (file)
@@ -82,7 +82,9 @@ DIR_WATCH_SOURCE=dir-watch-default.c
 endif
 endif
 
-BUS_SOURCES=                                   \
+noinst_LTLIBRARIES = libdbus-daemon-internal.la
+
+libdbus_daemon_internal_la_SOURCES =           \
        activation.c                            \
        activation.h                            \
        activation-exit-codes.h                 \
@@ -127,17 +129,17 @@ BUS_SOURCES=                                      \
        utils.h                                 \
        $(NULL)
 
-dbus_daemon_SOURCES=                           \
-       $(BUS_SOURCES)                          \
-       main.c
+libdbus_daemon_internal_la_LIBADD = \
+       $(top_builddir)/dbus/libdbus-1.la \
+       $(top_builddir)/dbus/libdbus-internal.la \
+       $(EFENCE) \
+       $(DBUS_BUS_LIBS) \
+       $(NULL)
 
-dbus_daemon_LDADD=                                     \
-       $(top_builddir)/dbus/libdbus-1.la       \
-       $(top_builddir)/dbus/libdbus-internal.la        \
-       $(EFENCE)                                       \
-       $(DBUS_BUS_LIBS)
+dbus_daemon_SOURCES = main.c
+dbus_daemon_LDADD = libdbus-daemon-internal.la
 
-LAUNCH_HELPER_SOURCES=                         \
+liblaunch_helper_internal_la_SOURCES =         \
        config-loader-expat.c                   \
        config-parser-common.c                  \
        config-parser-common.h                  \
@@ -149,28 +151,33 @@ LAUNCH_HELPER_SOURCES=                            \
        utils.h                                 \
        activation-exit-codes.h                 \
        activation-helper.h                     \
-       activation-helper.c
+       $(NULL)
 
 ## This is the installed launch helper with the setuid checks
-dbus_daemon_launch_helper_SOURCES=             \
-       activation-helper-bin.c                 \
-       $(LAUNCH_HELPER_SOURCES)
+## All files that have special cases #ifdef ACTIVATION_LAUNCHER_TEST must
+## be here and in dbus_daemon_launch_helper_test_SOURCES, not in
+## liblaunch-helper-internal.la.
+dbus_daemon_launch_helper_SOURCES = \
+       activation-helper.c \
+       activation-helper-bin.c \
+       $(NULL)
+dbus_daemon_launch_helper_LDADD = liblaunch-helper-internal.la
 
-dbus_daemon_launch_helper_LDADD=               \
+liblaunch_helper_internal_la_LIBADD = \
        $(top_builddir)/dbus/libdbus-1.la \
-       $(top_builddir)/dbus/libdbus-internal.la        \
+       $(top_builddir)/dbus/libdbus-internal.la \
        $(DBUS_LAUNCHER_LIBS)
 
 ## we build another binary so we can do the launch testing without root privs.
 ## DO NOT INSTALL THIS FILE
+## All files that have special cases #ifdef ACTIVATION_LAUNCHER_TEST must
+## be here and in dbus_daemon_launch_helper_SOURCES, not in
+## liblaunch-helper-internal.la.
 dbus_daemon_launch_helper_test_SOURCES=                \
-       activation-helper-bin.c                 \
-       $(LAUNCH_HELPER_SOURCES)
-
-dbus_daemon_launch_helper_test_LDADD=          \
-       $(top_builddir)/dbus/libdbus-1.la \
-       $(top_builddir)/dbus/libdbus-internal.la \
-       $(DBUS_LAUNCHER_LIBS)
+       activation-helper.c \
+       activation-helper-bin.c \
+       $(NULL)
+dbus_daemon_launch_helper_test_LDADD = liblaunch-helper-internal.la
 
 dbus_daemon_launch_helper_test_CPPFLAGS = \
        $(AM_CPPFLAGS) \
@@ -178,15 +185,11 @@ dbus_daemon_launch_helper_test_CPPFLAGS = \
 
 ## we build yet another binary so we can do the OOM tests
 ## DO NOT INSTALL THIS FILE
-test_bus_launch_helper_SOURCES=                \
-       test-launch-helper.c            \
-       $(LAUNCH_HELPER_SOURCES)
-
-test_bus_launch_helper_LDADD=          \
-       $(top_builddir)/dbus/libdbus-1.la \
-       $(top_builddir)/dbus/libdbus-internal.la \
-       $(DBUS_LAUNCHER_LIBS)
+test_bus_launch_helper_SOURCES = \
+       activation-helper.c \
+       test-launch-helper.c \
        $(NULL)
+test_bus_launch_helper_LDADD = liblaunch-helper-internal.la
 
 test_bus_launch_helper_CPPFLAGS = \
        $(AM_CPPFLAGS) \
@@ -196,6 +199,7 @@ test_bus_launch_helper_CPPFLAGS = \
 noinst_PROGRAMS =
 dbus_daemon_exec_PROGRAMS = dbus-daemon
 if DBUS_UNIX
+noinst_LTLIBRARIES += liblaunch-helper-internal.la
 libexec_PROGRAMS = dbus-daemon-launch-helper
 endif DBUS_UNIX
 
@@ -220,31 +224,11 @@ endif DBUS_UNIX
 
 endif DBUS_ENABLE_EMBEDDED_TESTS
 
-test_bus_system_SOURCES=                       \
-       config-loader-expat.c                   \
-       config-parser-common.c                  \
-       config-parser-common.h                  \
-       config-parser-trivial.c                 \
-       config-parser-trivial.h                 \
-       utils.c                                 \
-       utils.h                                 \
-       test-system.c
+test_bus_system_SOURCES = test-system.c
+test_bus_system_LDADD = liblaunch-helper-internal.la
 
-test_bus_system_LDADD = \
-       $(top_builddir)/dbus/libdbus-1.la \
-       $(top_builddir)/dbus/libdbus-internal.la \
-       $(DBUS_BUS_LIBS) \
-       $(NULL)
-
-test_bus_SOURCES=                              \
-       $(BUS_SOURCES)                          \
-       test-main.c
-
-test_bus_LDADD = \
-       $(top_builddir)/dbus/libdbus-1.la \
-       $(top_builddir)/dbus/libdbus-internal.la \
-       $(DBUS_BUS_LIBS) \
-       $(NULL)
+test_bus_SOURCES = test-main.c
+test_bus_LDADD = libdbus-daemon-internal.la
 
 install-data-hook:
        $(mkinstalldirs) $(DESTDIR)$(dbusdatadir)/session.d
index 8c0c8e66898e21c315191c3d0a0a24f33c934b3f..24f3bf69e02739d269f331366da347661c8002fc 100644 (file)
@@ -98,8 +98,11 @@ if(WIN32)
     list(APPEND BUS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc)
 endif()
 
-add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c)
-target_link_libraries(dbus-daemon ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
+add_library(dbus-daemon-internal STATIC ${BUS_SOURCES})
+target_link_libraries(dbus-daemon-internal ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
+
+add_executable(dbus-daemon ${BUS_DIR}/main.c)
+target_link_libraries(dbus-daemon dbus-daemon-internal)
 set_target_properties(dbus-daemon PROPERTIES OUTPUT_NAME ${DBUS_DAEMON_NAME})
 set_target_properties(dbus-daemon PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
 
@@ -142,35 +145,29 @@ set(LAUNCH_HELPER_SOURCES
     ${BUS_DIR}/config-parser-trivial.c
     ${BUS_DIR}/desktop-file.c
     ${BUS_DIR}/utils.c
-    ${BUS_DIR}/activation-helper.c
 )
 
 if(NOT WIN32)
-       add_executable(dbus-daemon-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c )
-       target_link_libraries(dbus-daemon-launch-helper ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES} )
-       install(TARGETS dbus-daemon-launch-helper ${INSTALL_TARGETS_DEFAULT_ARGS} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
+       add_library(launch-helper-internal STATIC ${LAUNCH_HELPER_SOURCES})
+       target_link_libraries(launch-helper-internal ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
+
+       add_executable(dbus-daemon-launch-helper ${BUS_DIR}/activation-helper.c ${BUS_DIR}/activation-helper-bin.c )
+       target_link_libraries(dbus-daemon-launch-helper launch-helper-internal)
 endif(NOT WIN32)
 
 if (DBUS_ENABLE_EMBEDDED_TESTS)
-       set(SOURCES ${BUS_SOURCES} ${BUS_DIR}/test-main.c)
-       add_test_executable(test-bus "${SOURCES}"  ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
+       set(SOURCES ${BUS_DIR}/test-main.c)
+       add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
        set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
        if (NOT WIN32)
-               set(test_bus_system_SOURCES
-                       ${BUS_DIR}/config-loader-expat.c
-                       ${BUS_DIR}/config-parser-common.c
-                       ${BUS_DIR}/config-parser-trivial.c
-                       ${BUS_DIR}/utils.c
-                       ${BUS_DIR}/test-system.c
-               )
-               add_test_executable(test-bus-system "${test_bus_system_SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES} ${DBUS_BUS_LIBS})
-
-               add_executable(dbus-daemon-launch-helper-test ${LAUNCH_HELPER_SOURCES}     ${BUS_DIR}/activation-helper-bin.c)
+               add_test_executable(test-bus-system ${BUS_DIR}/test-system.c launch-helper-internal)
+
+               add_executable(dbus-daemon-launch-helper-test ${BUS_DIR}/activation-helper.c ${BUS_DIR}/activation-helper-bin.c)
                set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST")
-               target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES} )
+               target_link_libraries(dbus-daemon-launch-helper-test launch-helper-internal)
 
-               set (SOURCES ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c)
-               add_test_executable(test-bus-launch-helper "${SOURCES}"  ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES})
+               set (SOURCES ${BUS_DIR}/activation-helper.c ${BUS_DIR}/test-launch-helper.c)
+               add_test_executable(test-bus-launch-helper "${SOURCES}" launch-helper-internal)
                set_target_properties(test-bus-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM")
        endif()
 endif (DBUS_ENABLE_EMBEDDED_TESTS)