tc: Apply autotools on tpl-test build system 30/152730/1
authorHoyub Lee <hoyub.lee@samsung.com>
Mon, 25 Sep 2017 08:25:00 +0000 (17:25 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 27 Sep 2017 03:57:35 +0000 (12:57 +0900)
This patch replace manually written Makefile to autotools on tpl-test.

Change-Id: I0a4040c3e5d259fe530c6b688de66283df93faa6
Signed-off-by: Hoyub Lee <hoyub.lee@samsung.com>
Makefile.am
configure.ac
tc/Makefile [deleted file]
tc/Makefile.am [new file with mode: 0644]

index d3be4f4..66af45b 100644 (file)
@@ -1,4 +1,10 @@
+if WITH_UTEST
 SUBDIRS = src \
           src/wayland-egl \
+          tc \
           pkgconfig
-
+else
+SUBDIRS = src \
+          src/wayland-egl \
+          pkgconfig
+endif
index 0c97ec7..5acc7a9 100644 (file)
@@ -141,6 +141,19 @@ AS_IF([test "${enable_ttrace}" = "yes" || test "${enable_ttrace}" = "1"],
 
 AM_CONDITIONAL([ENABLE_TTRACE], [test "${enable_ttrace}" = "yes" || test "${enable_ttrace}" = "1"])
 
+AC_ARG_WITH([utest],
+   [AS_HELP_STRING([--with-utest=yes|no],[Build tpl unit test. @<:@default=disabled@:>@])],
+   [],
+   [])
+
+# TODO: Apply pkgconfig on gtest
+AS_IF([test "${with_utest}" = "yes" || test "${with_utest}" = "1"],
+         [TPL_TEST_CFLAGS=
+          TPL_TEST_LIBS+="-lgtest"],
+         [])
+
+AM_CONDITIONAL([WITH_UTEST], [test "${with_utest}" = "yes" || test "${with_utest}" = "1"])
+
 TPL_CFLAGS+="$TPL_ESSENTIAL_CFLAGS"
 TPL_LIBS+="$TPL_ESSENTIAL_LIBS"
 
@@ -172,8 +185,11 @@ AC_CONFIG_FILES([
                                 pkgconfig/wayland-egl.pc
                                 ])
 
-AC_OUTPUT
+AM_COND_IF([WITH_UTEST],
+                  [AC_SUBST([TPL_TEST_CFLAGS])
+                       AC_SUBST([TPL_TEST_LIBS])
+                       AC_CONFIG_FILES([tc/Makefile])
+                  ])
 
-# TODO: TC
-# AC_CONFIG_SUBDIRS([tc/]) ... like this
+AC_OUTPUT
 
diff --git a/tc/Makefile b/tc/Makefile
deleted file mode 100644 (file)
index b17f511..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#######################################################
-##### Makefile to build tpl-test using libgtest.a #####
-#######################################################
-
-BIN_NAME := tpl-test
-
-CXX ?= g++
-
-
-########## Helper Functions ##########
-#$(call is-feature-enabled,featurename)
-#returns non-empty string if enabled, empty if not
-define is-feature-enabled
-$(findstring -$1-,-$(TPL_OPTIONS)-)
-endef
-
-
-########## Build Environments ##########
-TC_DIR := $(shell pwd)
-
-TC_CXXFLAGS =
-TC_LDFLAGS =
-
-# src include
-TC_CXXFLAGS += -I./
-TC_CXXFLAGS += -I../src/
-
-# gtest
-GTEST_DIR := $(TC_DIR)/libs/gtest
-GTEST_INCLUDE := -I$(GTEST_DIR)/googletest -I$(GTEST_DIR)/googletest/include \
-                                -I$(GTEST_DIR)/googlemock -I$(GTEST_DIR)/googlemock/include
-GTEST_FLAGS := -g -Wall -pthread
-GTEST_LIB_PATH := $(GTEST_DIR)/build/gtest/libgtest.a  # googletest output path
-GMOCK_LIB_PATH := $(GTEST_DIR)/build/libgmock.a                        # googlemock output path
-
-# libtpl-egl, libwayland-egl
-TPL_LIB_PATH = ../libtpl-egl.so.$(TPL_VERSION_MAJOR).$(TPL_VERSION_MINOR).$(TPL_VERSION_PATCH)
-WAYLAND_EGL_OBJ_PATH = ../src/wayland-egl/wayland-egl.o
-
-
-########## Backend Setup ##########
-ifneq ($(call is-feature-enabled,winsys_wl),)
-       TC_CXXFLAGS += `pkg-config --cflags gbm libtdm-client`
-       TC_LDFLAGS += `pkg-config --libs gbm wayland-tbm-client wayland-tbm-server libtdm-client`
-endif
-
-
-########## tpl-test srcs ##########
-SRCS = $(wildcard src/*.cpp)
-SRCS += $(wildcard mocked/*.cpp)
-HEADERS = $(wildcard src/*.h)
-HEADERS += $(wildcard mocked/*.h)
-
-
-########## tpl-test test cases srcs ##########
-TESTS  = $(wildcard test/*.cpp)
-
-OBJS   = $(SRCS:%.cpp=%.o) \
-                 $(TESTS:%.cpp=%.o) \
-                 $(NULL)
-
-
-########## Build Commands ##########
-all : gtest $(BIN_NAME)
-
-gtest :
-       mkdir $(GTEST_DIR)/build && \
-       cd $(GTEST_DIR)/build && \
-       cmake ../googlemock && \
-       make
-
-clean :
-       rm -f $(BIN_NAME)
-
-%.o: %.cpp
-       $(CXX) -c -o $@ $< $(GTEST_INCLUDE) $(GTEST_FLAGS) $(TC_CXXFLAGS) $(TC_LDFLAGS)
-
-$(BIN_NAME) : $(OBJS) $(GTEST_LIB_PATH) $(GMOCK_LIB_PATH) $(TPL_LIB_PATH) $(WAYLAND_EGL_OBJ_PATH)
-       cd ${TC_DIR} && \
-       $(CXX) -lpthread $^ -o $@ $(GTEST_FLAGS) $(TC_CXXFLAGS) $(TC_LDFLAGS)
-
diff --git a/tc/Makefile.am b/tc/Makefile.am
new file mode 100644 (file)
index 0000000..0c864ed
--- /dev/null
@@ -0,0 +1,29 @@
+# TODO
+# - Replace LDADD value using $(srcdir)
+# - Test cases wildcard alternative (autotools doesn't support wildcard)
+
+tpl_test_bin_PROGRAMS = tpl-test
+tpl_test_bindir = $(bindir)
+
+# Test module sources
+tpl_test_SOURCES  = src/main.cpp       \
+                                       src/tpl-test_base.cpp           \
+                                       src/tpl-test_base.h                     \
+                                       src/tpl-test_wayland.cpp        \
+                                       src/tpl-test_wayland.h
+
+# Test case sources
+tpl_test_SOURCES += test/tpl-test_display_test.cpp             \
+                                       test/tpl-test_object_test.cpp           \
+                                       test/tpl-test_surface_test.cpp
+
+tpl_test_CXXFLAGS =    ${CXXFLAGS}     \
+                                       @TPL_TEST_CFLAGS@ \
+                                       -I./    \
+                                       -I../src
+
+tpl_test_LDFLAGS = ${LDFLAGS}  \
+                                  @TPL_TEST_LIBS@
+
+tpl_test_LDADD = ../src/libtpl-egl.la  \
+                                ../src/wayland-egl/libwayland-egl.la