Skip to content

Commit 9ffeb94

Browse files
committed
Add an option to only build the tools
1 parent 9e72da1 commit 9ffeb94

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ TESTS =
2828

2929
###################
3030

31+
if BUILD_UNIT_TESTS
3132
include Bootloader/firmware/src/Makefile.mk
3233
include firmware/src/Makefile.mk
3334
include tests/Makefile.mk
35+
endif
36+
3437
include tools/Makefile.mk
3538

3639
check_PROGRAMS = $(TESTS)

configure.ac

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ AC_LANG_PUSH(C)
2525
AC_PROG_CC_C99
2626
AC_LANG_POP(C)
2727

28-
# Check we have -std=c++11 support
29-
AX_CXX_COMPILE_STDCXX_11(noext,mandatory)
28+
# Allow us to just build the tools without the unit tests
29+
AC_ARG_ENABLE(
30+
[unit-tests],
31+
[AS_HELP_STRING([--disable-unit-tests],
32+
[Just build the tools without the unit tests])])
33+
AM_CONDITIONAL(BUILD_UNIT_TESTS, test "x$enable_unit_tests" != xno)
34+
35+
# Check we have -std=c++11 support if required
36+
AM_COND_IF([BUILD_UNIT_TESTS],
37+
[AX_CXX_COMPILE_STDCXX_11(noext,mandatory)])
3038

3139
# Checks for header files.
3240
AC_CHECK_HEADERS([arpa/inet.h stdint.h stdlib.h string.h])
@@ -84,7 +92,10 @@ GTEST_LIBS="$with_gmock/googletest/lib/libgtest.la $with_gmock/googletest/lib/li
8492
old_cppflags=$CPPFLAGS
8593
CPPFLAGS="$GMOCK_INCLUDES $GTEST_INCLUDES"
8694

87-
AC_CHECK_HEADER([gmock/gmock.h], [], [AC_MSG_ERROR([Missing gmock/gmock.h])])
95+
AM_COND_IF([BUILD_UNIT_TESTS],
96+
[AC_CHECK_HEADER([gmock/gmock.h],
97+
[],
98+
[AC_MSG_ERROR([Missing gmock/gmock.h])])])
8899

89100
# restore CPPFLAGS
90101
CPPFLAGS=$old_cppflags
@@ -104,12 +115,11 @@ AC_ARG_WITH(
104115
[ola],
105116
[AS_HELP_STRING([--without-ola],
106117
[Skip OLA checks, unittests will not work correctly])])
107-
AS_IF([test "x$with_ola" != xno],
108-
[PKG_CHECK_MODULES(
109-
OLA,
110-
[libola],
111-
[],
112-
[AC_MSG_ERROR([Missing OLA, please install])])])
118+
AS_IF([test "x$enable_unit_tests" != xno && test "x$with_ola" != xno],
119+
[PKG_CHECK_MODULES(OLA,
120+
[libola],
121+
[],
122+
[AC_MSG_ERROR([Missing OLA, please install])])])
113123

114124
# Output
115125
#####################################################
@@ -125,6 +135,8 @@ C++ Compiler: '${CXX} ${CXXFLAGS} ${CPPFLAGS}'
125135
C Compiler: '${CC} ${CFLAGS} ${CPPFLAGS}'
126136
Linker: '${LD} ${LDFLAGS} ${LIBS}'
127137

138+
Unit Tests: ${enable_unit_tests}
139+
128140
Now type 'make @<:@<target>@:>@'
129141
where the optional <target> is:
130142
check - run the tests

0 commit comments

Comments
 (0)