提交 16ea34ff 编写于 作者: A Adam Lee

s3ext: refactor Makefiles

Put Makefile in each subdirectory, instead of using one Makefile at top
directory to do all the things, and extract the common parts.
Signed-off-by: NAdam Lee <ali@pivotal.io>
Signed-off-by: NHaozhou Wang <hawang@pivotal.io>
上级 3d134b34
# Include
include ./include/makefile.inc
# Options
DEBUG_S3_SYMBOL = y
# Flags
SHLIB_LINK += -lstdc++ -lxml2 -lpthread -lcrypto -lcurl -lz
PG_CPPFLAGS += -O2 -std=c++98 -Wall -fPIC -Iinclude -Ilib -I/usr/include/libxml2 -I$(libpq_srcdir) -I$(libpq_srcdir)/postgresql/server/utils
SHLIB_LINK += $(COMMON_LINK_OPTIONS)
PG_CPPFLAGS += $(COMMON_CPP_FLAGS) -Iinclude -Ilib -I$(libpq_srcdir) -I$(libpq_srcdir)/postgresql/server/utils
ifeq ($(DEBUG_S3_SYMBOL),y)
PG_CPPFLAGS += -g
......@@ -11,25 +14,37 @@ endif
# Targets
MODULE_big = gps3ext
OBJS = lib/http_parser.o lib/ini.o src/gps3ext.o src/s3conf.o src/s3common.o src/gpreader.o src/s3utils.o src/s3log.o src/s3url_parser.o src/s3http_headers.o src/s3extbase.o src/s3interface.o src/s3restful_service.o src/uncompress_reader.o src/s3key_reader.o
OBJS = src/gps3ext.o lib/http_parser.o lib/ini.o $(addprefix src/,$(COMMON_OBJS))
# Launch
PGXS := $(shell pg_config --pgxs)
include $(PGXS)
format:
@make -f Makefile.others format
gpcheckcloud:
@make -C bin/gpcheckcloud
lint:
@make -f Makefile.others lint
test: format
@make -C test test
coverage: format
@make -C test coverage
tags:
@make -f Makefile.others tags
ctags --c++-kinds=+p --fields=+iaS --extra=+q src/*.cpp test/*.cpp include/*.h lib/*.cpp lib/*.h
cscope -bq src/*.cpp test/*.cpp include/*.h lib/*.cpp lib/*.h
test: format
@make -f Makefile.others test
lint:
cppcheck -v --enable=warning src/*.cpp test/*.cpp include/*.h
coverage: format
@make -f Makefile.others coverage
format:
clang-format -style="{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 100, AllowShortFunctionsOnASingleLine: None}" -i src/*.cpp test/*.cpp include/*.h
cleanall:
@-make clean # incase PGXS not included
@-make -C bin/gpcheckcloud clean
@make -C test clean
rm -f *.o *.so *.a
rm -f *.gcov src/*.gcov src/*.gcda src/*.gcno
rm -f src/*.o src/*.d test/*.o test/*.d test/*.a lib/*.o lib/*.d
.PHONY: format lint tags test coverage
.PHONY: format lint tags test coverage cleanall
# Include
include ../../include/makefile.inc
# Options
DEBUG_S3_SYMBOL = y
# Flags
PG_LIBS += -lstdc++ -lxml2 -lpthread -lcrypto -lcurl -lz
PG_CPPFLAGS += -O2 -std=c++98 -Wall -fPIC -DS3_CHK_CFG -DS3_STANDALONE -Iinclude -Ilib -I/usr/include/libxml2
PG_LIBS += $(COMMON_LINK_OPTIONS)
PG_CPPFLAGS += $(COMMON_CPP_FLAGS) -I../../include -I../../lib -DS3_CHK_CFG -DS3_STANDALONE
ifeq ($(DEBUG_S3_SYMBOL),y)
PG_CPPFLAGS += -g
......@@ -11,7 +14,7 @@ endif
# Targets
PROGRAM = gpcheckcloud
OBJS = src/gpcheckcloud.o src/s3conf.o src/gpreader.o src/s3utils.o src/s3log.o src/s3common.o lib/http_parser.o lib/ini.o src/s3url_parser.o src/s3http_headers.o src/s3extbase.o src/s3interface.o src/s3restful_service.o src/uncompress_reader.o src/s3key_reader.o
OBJS = gpcheckcloud.o ../../lib/http_parser.o ../../lib/ini.o $(addprefix ../../,$(COMMON_OBJS))
# Launch
PGXS := $(shell pg_config --pgxs)
......
COMMON_OBJS = s3conf.o s3common.o s3utils.o s3log.o s3url_parser.o s3http_headers.o s3interface.o s3restful_service.o uncompress_reader.o s3key_reader.o s3bucket_reader.o #gpreader.o s3extbase.o
COMMON_LINK_OPTIONS = -lstdc++ -lxml2 -lpthread -lcrypto -lcurl -lz
COMMON_CPP_FLAGS = -O2 -std=c++98 -Wall -fPIC -I/usr/include/libxml2
TEST_OBJS = $(patsubst %.o,%_test.o,$(COMMON_OBJS))
# Include
include ../include/makefile.inc
# Options
ARCH = $(shell uname -s)
# Flags
CPP = g++
INCLUDES = -Isrc -Iinclude -Ilib -I/usr/include/libxml2
LDFLAGS = -lpthread -lcrypto -lcurl -lxml2 -lz
CPPFLAGS = -O2 -g3 -std=c++98 -Wall -fPIC -DS3_STANDALONE -fprofile-arcs -ftest-coverage
INCLUDES = -I../src -I../include -I../lib
LDFLAGS = $(COMMON_LINK_OPTIONS)
CPPFLAGS = $(COMMON_CPP_FLAGS) -g3 -DS3_STANDALONE -fprofile-arcs -ftest-coverage
ifeq "$(ARCH)" "Darwin"
LDFLAGS += -coverage
......@@ -16,16 +19,16 @@ endif
all: test
# Google TEST
TEST_SRC_FILES = test/s3conf_test.cpp test/s3utils_test.cpp test/s3common_test.cpp test/s3log_test.cpp test/s3url_parser_test.cpp test/s3http_headers_test.cpp test/s3bucket_reader_test.cpp test/s3interface_test.cpp test/s3restful_service_test.cpp test/uncompress_reader_test.cpp test/s3key_reader_test.cpp
TEST_OBJS = $(TEST_SRC_FILES:.cpp=.o)
TEST_SRC = $(TEST_OBJS:.o=.cpp)
TEST_APP = s3test
gtest_filter ?= *
DEP_FILES := $(patsubst %.cpp,%.d,$(TEST_SRC_FILES))
DEP_FILES := $(patsubst %.o,%.d,$(TEST_OBJS))
TEST_SRC = $(TEST_OBJS:.o=.cpp)
-include $(DEP_FILES)
GMOCK_DIR = ../gmock
GTEST_DIR = ../gtest
GMOCK_DIR = ../../gmock
GTEST_DIR = ../../gtest
$(TEST_OBJS) gtest_main.o gtest-all.o gmock-all.o: INCLUDES += -I$(GTEST_DIR)/ -I$(GMOCK_DIR)/ -I$(GTEST_DIR)/src -I$(GMOCK_DIR)/src -I$(GTEST_DIR)/include -I$(GMOCK_DIR)/include
......@@ -51,27 +54,13 @@ $(TEST_APP): $(TEST_OBJS) gtest_main.a
$(CPP) $(CPPFLAGS) $(INCLUDES) -MMD -MP -c $< -o $@
test: $(TEST_APP)
-rm -rf *.gcda *.gcov test/*.gcda test/*.gcov
@-rm -f *.gcda test/*.gcda # workaround for XCode/Clang
@-./$(TEST_APP) --gtest_filter=$(gtest_filter)
coverage: test
@gcov $(TEST_SRC_FILES) | grep -A 1 "src/.*.cpp"
@gcov $(TEST_SRC) | grep -A 1 "src/.*.cpp"
clean:
rm -f *.gcov src/*.gcov src/*.gcda src/*.gcno
rm -f $(TEST_APP) *.so src/*.o src/*.d lib/*.o lib/*.d *.o *.a test/*.o
distclean: clean
rm -f tags cscope.*
tags:
ctags --c++-kinds=+p --fields=+iaS --extra=+q src/*.cpp test/*.cpp include/*.h lib/*.cpp lib/*.h
cscope -bq src/*.cpp test/*.cpp include/*.h lib/*.cpp lib/*.h
lint:
cppcheck -v --enable=warning src/*.cpp test/*.cpp include/*.h
format:
clang-format -style="{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 100, AllowShortFunctionsOnASingleLine: None}" -i src/*.cpp test/*.cpp include/*.h
rm -f *.o *.d *.a *.gcov *.gcda *.gcno $(TEST_APP)
.PHONY: buildtest test coverage clean distclean tags lint format
.PHONY: buildtest test coverage clean
......@@ -9,7 +9,7 @@ TEST(Config, NonExistFile) {
}
TEST(Config, Basic) {
InitConfig("test/data/s3test.conf", "default");
InitConfig("data/s3test.conf", "default");
EXPECT_STREQ("secret_test", s3ext_secret.c_str());
EXPECT_STREQ("accessid_test", s3ext_accessid.c_str());
......@@ -37,7 +37,7 @@ TEST(Config, Basic) {
}
TEST(Config, SpecialSectionValues) {
InitConfig("test/data/s3test.conf", "special_over");
InitConfig("data/s3test.conf", "special_over");
EXPECT_EQ(8, s3ext_threadnum);
EXPECT_EQ(128 * 1024 * 1024, s3ext_chunksize);
......@@ -49,22 +49,22 @@ TEST(Config, SpecialSectionValues) {
}
TEST(Config, SpecialSectionLowValues) {
InitConfig("test/data/s3test.conf", "special_low");
InitConfig("data/s3test.conf", "special_low");
EXPECT_EQ(1, s3ext_threadnum);
EXPECT_EQ(2 * 1024 * 1024, s3ext_chunksize);
}
TEST(Config, SpecialSectionWrongKeyName) {
InitConfig("test/data/s3test.conf", "special_wrongkeyname");
InitConfig("data/s3test.conf", "special_wrongkeyname");
EXPECT_EQ(4, s3ext_threadnum);
EXPECT_EQ(64 * 1024 * 1024, s3ext_chunksize);
}
TEST(Config, SpecialSwitches) {
InitConfig("test/data/s3test.conf", "special_switches");
InitConfig("data/s3test.conf", "special_switches");
EXPECT_FALSE(s3ext_encryption);
EXPECT_TRUE(s3ext_debug_curl);
}
\ No newline at end of file
}
......@@ -66,7 +66,7 @@ TEST(Utils, sha256hmac) {
}
TEST(Utils, Config) {
Config c("test/data/s3test.conf");
Config c("data/s3test.conf");
EXPECT_STREQ(c.Get("configtest", "config1", "aaaaaa").c_str(), "abcdefg");
EXPECT_STREQ(c.Get("configtest", "config2", "tttt").c_str(), "12345");
EXPECT_STREQ(c.Get("configtest", "config3", "tttt").c_str(), "aaaaa");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册