ref: aa0fa56cdc1358292f7e743ddf9e2e88a07d27b0
parent: 0e99473a463e24624223268e9694d2ab36a8a914
author: Martin Storsjö <[email protected]>
date: Fri Apr 17 11:51:14 EDT 2015
Simplify the makefile handling of building the unit test library Instead of repeating everything hardcoded with platform ifdefs, use a common define BUILD_UT_EXE to define whether we should build an executable or a library of the unit test suite. Later factorize all other platform differences into smaller and simpler ifdefs.
--- a/Makefile
+++ b/Makefile
@@ -159,15 +159,19 @@
ifeq ($(HAVE_GTEST),Yes)
-test: codec_unittest$(EXEEXT)
ifneq (android,$(OS))
ifneq (ios,$(OS))
ifneq (msvc-wp,$(OS))
- ./codec_unittest
+BUILD_UT_EXE=Yes
endif
endif
endif
+test: codec_unittest$(EXEEXT)
+ifeq ($(BUILD_UT_EXE), Yes)
+ ./codec_unittest
+endif
+
else
test:
@echo "./gtest : No such file or directory."
@@ -200,10 +204,6 @@
libraries: $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX)
endif
-ifeq (msvc-wp, $(OS))
-libraries: $(LIBPREFIX)ut.$(SHAREDLIBSUFFIX)
-endif
-
LIBRARIES += $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER)
$(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX): $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
@@ -295,39 +295,35 @@
binaries: codec_unittest$(EXEEXT)
BINARIES += codec_unittest$(EXEEXT)
+ifeq ($(BUILD_UT_EXE), Yes)
+# Build a normal command line executable
+codec_unittest$(EXEEXT): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(COMMON_UNITTEST_OBJS) $(CODEC_UNITTEST_DEPS) | res
+ $(QUIET)rm -f $@
+ $(QUIET_CXX)$(CXX) $(CXX_LINK_O) $+ $(CODEC_UNITTEST_LDFLAGS) $(LDFLAGS)
+
+res:
+ $(QUIET)if [ ! -e res ]; then ln -s $(SRC_PATH)res .; fi
+else
+
+# Build the unit test suite into a library that is included in a project file
ifeq (ios,$(OS))
codec_unittest$(EXEEXT): $(LIBPREFIX)ut.$(LIBSUFFIX) $(LIBPREFIX)gtest.$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX)
-
else
+codec_unittest$(EXEEXT): $(LIBPREFIX)ut.$(SHAREDLIBSUFFIX)
+endif
+
ifeq (android,$(OS))
ifeq (./,$(SRC_PATH))
-codec_unittest$(EXEEXT): $(LIBPREFIX)ut.$(SHAREDLIBSUFFIX)
+codec_unittest$(EXEEXT):
cd ./test/build/android && $(NDKROOT)/ndk-build -B APP_ABI=$(APP_ABI) && android update project -t $(TARGET) -p . && ant debug
clean_Android: clean_Android_ut
clean_Android_ut:
-cd ./test/build/android && $(NDKROOT)/ndk-build APP_ABI=$(APP_ABI) clean && ant clean
-
-else
-codec_unittest$(EXEEXT):
- @:
endif
-else
-ifneq (msvc-wp,$(OS))
-codec_unittest$(EXEEXT): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(COMMON_UNITTEST_OBJS) $(CODEC_UNITTEST_DEPS) | res
- $(QUIET)rm -f $@
- $(QUIET_CXX)$(CXX) $(CXX_LINK_O) $+ $(CODEC_UNITTEST_LDFLAGS) $(LDFLAGS)
-
-res:
- $(QUIET)if [ ! -e res ]; then ln -s $(SRC_PATH)res .; fi
-else
-codec_unittest$(EXEEXT):
- @:
endif
endif
-endif
-
endif
-include $(OBJS:.$(OBJ)=.d)