build: split object to enable coverage
Split the object into two pieces so we can pass part of it to the
unit-tests.
Tested: Verified the coverage output processed the files.
Change-Id: Idf1bdf9d21eb1324395eb9a2c09ff8f1b4ecad6b
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/Makefile.am b/Makefile.am
index 853bcce..974f338 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,16 +35,34 @@
@CODE_COVERAGE_RULES@
endif
-libblobcmdsdir = ${libdir}/ipmid-providers
-libblobcmds_LTLIBRARIES = libblobcmds.la
-libblobcmds_la_SOURCES = \
- main.cpp \
- ipmi.cpp \
+noinst_LTLIBRARIES = libblobcmds_common.la
+libblobcmds_common_la_SOURCES = \
+ fs.cpp \
manager.cpp \
+ ipmi.cpp \
process.cpp \
utils.cpp \
- internal/sys.cpp \
- fs.cpp
+ internal/sys.cpp
+libblobcmds_common_la_CXXFLAGS = \
+ $(SYSTEMD_CFLAGS) \
+ $(PHOSPHOR_LOGGING_CFLAGS) \
+ $(LIBIPMID_CFLAGS) \
+ $(CODE_COVERAGE_CXXFLAGS) \
+ $(IPMIBLOB_CFLAGS) \
+ -flto
+libblobcmds_common_la_LDFLAGS = \
+ $(SYSTEMD_LIBS) \
+ $(LIBADD_DLOPEN) \
+ $(PHOSPHOR_LOGGING_LIBS) \
+ $(LIBIPMID_LIBS) \
+ $(CODE_COVERAGE_LIBS) \
+ $(IPMIBLOB_LIBS) \
+ -lstdc++fs
+
+libblobcmdsdir = ${libdir}/ipmid-providers
+libblobcmds_LTLIBRARIES = libblobcmds.la
+libblobcmds_la_SOURCES = main.cpp
+libblobcmds_la_LIBADD = libblobcmds_common.la
libblobcmds_la_LDFLAGS = \
$(SYSTEMD_LIBS) \
diff --git a/test/Makefile.am b/test/Makefile.am
index dc862c4..ea45d7b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -48,79 +48,79 @@
TESTS = $(check_PROGRAMS)
ipmi_unittest_SOURCES = ipmi_unittest.cpp
-ipmi_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_getcount_unittest_SOURCES = ipmi_getcount_unittest.cpp
-ipmi_getcount_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_getcount_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_enumerate_unittest_SOURCES = ipmi_enumerate_unittest.cpp
-ipmi_enumerate_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_enumerate_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_open_unittest_SOURCES = ipmi_open_unittest.cpp
-ipmi_open_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_open_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_close_unittest_SOURCES = ipmi_close_unittest.cpp
-ipmi_close_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_close_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_delete_unittest_SOURCES = ipmi_delete_unittest.cpp
-ipmi_delete_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_delete_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_stat_unittest_SOURCES = ipmi_stat_unittest.cpp
-ipmi_stat_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_stat_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_sessionstat_unittest_SOURCES = ipmi_sessionstat_unittest.cpp
-ipmi_sessionstat_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_sessionstat_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_commit_unittest_SOURCES = ipmi_commit_unittest.cpp
-ipmi_commit_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_commit_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_read_unittest_SOURCES = ipmi_read_unittest.cpp
-ipmi_read_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_read_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_write_unittest_SOURCES = ipmi_write_unittest.cpp
-ipmi_write_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_write_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_writemeta_unittest_SOURCES = ipmi_writemeta_unittest.cpp
-ipmi_writemeta_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_writemeta_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
ipmi_validate_unittest_SOURCES = ipmi_validate_unittest.cpp
-ipmi_validate_unittest_LDADD = $(top_builddir)/ipmi.o
+ipmi_validate_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_unittest_SOURCES = manager_unittest.cpp
-manager_unittest_LDADD = $(top_builddir)/manager.o
+manager_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_getsession_unittest_SOURCES = manager_getsession_unittest.cpp
-manager_getsession_unittest_LDADD = $(top_builddir)/manager.o
+manager_getsession_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_open_unittest_SOURCES = manager_open_unittest.cpp
-manager_open_unittest_LDADD = $(top_builddir)/manager.o
+manager_open_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_stat_unittest_SOURCES = manager_stat_unittest.cpp
-manager_stat_unittest_LDADD = $(top_builddir)/manager.o
+manager_stat_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_sessionstat_unittest_SOURCES = manager_sessionstat_unittest.cpp
-manager_sessionstat_unittest_LDADD = $(top_builddir)/manager.o
+manager_sessionstat_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_commit_unittest_SOURCES = manager_commit_unittest.cpp
-manager_commit_unittest_LDADD = $(top_builddir)/manager.o
+manager_commit_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_close_unittest_SOURCES = manager_close_unittest.cpp
-manager_close_unittest_LDADD = $(top_builddir)/manager.o
+manager_close_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_delete_unittest_SOURCES = manager_delete_unittest.cpp
-manager_delete_unittest_LDADD = $(top_builddir)/manager.o
+manager_delete_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_write_unittest_SOURCES = manager_write_unittest.cpp
-manager_write_unittest_LDADD = $(top_builddir)/manager.o
+manager_write_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_read_unittest_SOURCES = manager_read_unittest.cpp
-manager_read_unittest_LDADD = $(top_builddir)/manager.o
+manager_read_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
manager_writemeta_unittest_SOURCES = manager_writemeta_unittest.cpp
-manager_writemeta_unittest_LDADD = $(top_builddir)/manager.o
+manager_writemeta_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
process_unittest_SOURCES = process_unittest.cpp
-process_unittest_LDADD = $(top_builddir)/process.o $(top_builddir)/ipmi.o
+process_unittest_LDADD = $(top_builddir)/libblobcmds_common.la
utils_unittest_SOURCES = utils_unittest.cpp
-utils_unittest_LDADD = $(top_builddir)/utils.o $(PHOSPHOR_LOGGING_LIBS)
+utils_unittest_LDADD = $(top_builddir)/libblobcmds_common.la $(PHOSPHOR_LOGGING_LIBS)