[devhelp/wip/completion: 1/2] build: be able to unit-test private functions
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/wip/completion: 1/2] build: be able to unit-test private functions
- Date: Sat, 6 Jan 2018 12:00:24 +0000 (UTC)
commit 35857c46564a067b409bbc06410f21f8fba09d03
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jan 6 10:45:28 2018 +0100
build: be able to unit-test private functions
I've documented this technique here:
https://blogs.gnome.org/swilmet/2016/04/17/libtool-convenience-library-to-unit-test-private-functions/
src/Makefile.am | 31 +++++++++++++++++++++----------
unit-tests/Makefile.am | 2 +-
2 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 574e80f..46cb1be 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -79,30 +79,41 @@ BUILT_SOURCES = \
$(libdevhelp_built_sources) \
$(NULL)
-# The library
-lib_LTLIBRARIES = libdevhelp-3.la
-
-devhelpincludedir = $(includedir)/devhelp-3.0/devhelp
-devhelpinclude_HEADERS = $(libdevhelp_public_headers)
-nodist_devhelpinclude_HEADERS = $(libdevhelp_built_public_headers)
+# Helper Libtool library, so that the private functions can be used in unit
+# tests.
+noinst_LTLIBRARIES = libdevhelp-core.la
-libdevhelp_3_la_SOURCES = \
+libdevhelp_core_la_SOURCES = \
$(libdevhelp_public_headers) \
$(libdevhelp_public_c_files) \
$(libdevhelp_private_headers) \
$(libdevhelp_private_c_files)
# Do not distribute generated files.
-nodist_libdevhelp_3_la_SOURCES = \
+nodist_libdevhelp_core_la_SOURCES = \
$(libdevhelp_built_sources)
-libdevhelp_3_la_CPPFLAGS = \
+libdevhelp_core_la_CPPFLAGS = \
$(AM_CPPFLAGS)
-libdevhelp_3_la_CFLAGS = \
+libdevhelp_core_la_CFLAGS = \
$(DEVHELP_CFLAGS)
+libdevhelp_core_la_LDFLAGS = \
+ $(AM_LDFLAGS) \
+ -no-undefined
+
+# The library
+lib_LTLIBRARIES = libdevhelp-3.la
+
+devhelpincludedir = $(includedir)/devhelp-3.0/devhelp
+devhelpinclude_HEADERS = $(libdevhelp_public_headers)
+nodist_devhelpinclude_HEADERS = $(libdevhelp_built_public_headers)
+
+libdevhelp_3_la_SOURCES =
+
libdevhelp_3_la_LIBADD = \
+ libdevhelp-core.la \
$(DEVHELP_LIBS) \
$(LIBM)
diff --git a/unit-tests/Makefile.am b/unit-tests/Makefile.am
index 66c58c2..64c029f 100644
--- a/unit-tests/Makefile.am
+++ b/unit-tests/Makefile.am
@@ -6,7 +6,7 @@ AM_CPPFLAGS = \
AM_LDFLAGS = $(WARN_LDFLAGS)
-LDADD = $(top_builddir)/src/libdevhelp-3.la \
+LDADD = $(top_builddir)/src/libdevhelp-core.la \
$(DEVHELP_LIBS) \
$(LIBM)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]