Commit 70d77b20 authored by gejun's avatar gejun

Combine all libs into one

parent 27db3d61
......@@ -7,8 +7,8 @@ include config.mk
# 3. Removed -Werror: Not block compilation for non-vital warnings, especially when the
# code is tested on newer systems. If the code is used in production, add -Werror back
CPPFLAGS=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\"$(shell git rev-parse --short HEAD)\"
CXXFLAGS=$(CPPFLAGS) -O2 -g -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x -include brpc/config.h
CFLAGS=$(CPPFLAGS) -O2 -g -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer
CXXFLAGS=$(CPPFLAGS) -g -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x -include brpc/config.h
CFLAGS=$(CPPFLAGS) -g -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer
HDRPATHS=-I./src $(addprefix -I, $(HDRS))
LIBPATHS = $(addprefix -L, $(LIBS))
SRCEXTS = .c .cc .cpp .proto
......@@ -26,7 +26,6 @@ endif
BASE_SOURCES = \
src/base/third_party/dmg_fp/g_fmt.cc \
src/base/third_party/dmg_fp/dtoa_wrapper.cc \
src/base/third_party/dmg_fp/dtoa.cc \
src/base/third_party/dynamic_annotations/dynamic_annotations.c \
src/base/third_party/icu/icu_utf.cc \
src/base/third_party/superfasthash/superfasthash.c \
......@@ -180,29 +179,24 @@ BASE_SOURCES = \
src/base/iobuf.cpp
BASE_OBJS = $(addsuffix .o, $(basename $(BASE_SOURCES)))
BASE_DEBUG_OBJS = $(BASE_OBJS:.o=.dbg.o)
BVAR_DIRS = src/bvar src/bvar/detail
BVAR_SOURCES = $(foreach d,$(BVAR_DIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
BVAR_OBJS = $(addsuffix .o, $(basename $(BVAR_SOURCES)))
BVAR_DEBUG_OBJS = $(BVAR_OBJS:.o=.dbg.o)
BTHREAD_DIRS = src/bthread
BTHREAD_SOURCES = $(foreach d,$(BTHREAD_DIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
BTHREAD_OBJS = $(addsuffix .o, $(basename $(BTHREAD_SOURCES)))
BTHREAD_DEBUG_OBJS = $(BTHREAD_OBJS:.o=.dbg.o)
JSON2PB_DIRS = src/json2pb
JSON2PB_SOURCES = $(foreach d,$(JSON2PB_DIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
JSON2PB_OBJS = $(addsuffix .o, $(basename $(JSON2PB_SOURCES)))
JSON2PB_DEBUG_OBJS = $(JSON2PB_OBJS:.o=.dbg.o)
BRPC_DIRS = src/brpc src/brpc/details src/brpc/builtin src/brpc/policy
BRPC_SOURCES = $(foreach d,$(BRPC_DIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
BRPC_PROTOS = $(filter %.proto,$(BRPC_SOURCES))
BRPC_CFAMILIES = $(filter-out %.proto,$(BRPC_SOURCES))
BRPC_OBJS = $(BRPC_PROTOS:.proto=.pb.o) $(addsuffix .o, $(basename $(BRPC_CFAMILIES)))
BRPC_DEBUG_OBJS = $(BRPC_OBJS:.o=.dbg.o)
MCPACK2PB_SOURCES = \
src/mcpack2pb/field_type.cpp \
......@@ -210,78 +204,37 @@ MCPACK2PB_SOURCES = \
src/mcpack2pb/parser.cpp \
src/mcpack2pb/serializer.cpp
MCPACK2PB_OBJS = src/idl_options.pb.o $(addsuffix .o, $(basename $(MCPACK2PB_SOURCES)))
MCPACK2PB_DEBUG_OBJS = $(MCPACK2PB_OBJS:.o=.dbg.o)
OBJS=$(BASE_OBJS) $(BVAR_OBJS) $(BTHREAD_OBJS) $(JSON2PB_OBJS) $(MCPACK2PB_OBJS) $(BRPC_OBJS)
DEBUG_OBJS = $(OBJS:.o=.dbg.o)
.PHONY:all
all: libbase.a libbvar.a libbthread.a libjson2pb.a libmcpack2pb.a protoc-gen-mcpack libbrpc.a output/include output/lib output/bin
all: protoc-gen-mcpack libbrpc.a output/include output/lib output/bin
.PHONY:debug
debug: libbase.dbg.a libbvar.dbg.a libbthread.dbg.a libjson2pb.dbg.a libmcpack2pb.dbg.a libbrpc.dbg.a
debug: libbrpc.dbg.a
.PHONY:clean
clean:clean_debug
@echo "Cleaning"
@rm -rf libbase.a libbvar.a libbthread.a libjson2pb.a libmcpack2pb.a mcpack2pb/generator.o protoc-gen-mcpack libbrpc.a \
$(BASE_OBJS) $(BVAR_OBJS) $(BTHREAD_OBJS) $(JSON2PB_OBJS) $(MCPACK2PB_OBJS) $(BRPC_OBJS) \
output/include output/lib output/bin
@rm -rf mcpack2pb/generator.o protoc-gen-mcpack libbrpc.a $(OBJS) output/include output/lib output/bin
.PHONY:clean_debug
clean_debug:
@rm -rf libbase.dbg.a libbvar.dbg.a libbthread.dbg.a libjson2pb.dbg.a libmcpack2pb.dbg.a libbrpc.dbg.a \
$(BASE_DEBUG_OBJS) $(BVAR_DEBUG_OBJS) $(BTHREAD_DEBUG_OBJS) $(JSON2PB_DEBUG_OBJS) $(MCPACK2PB_DEBUG_OBJS) $(BRPC_DEBUG_OBJS)
libbase.a:$(BASE_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libbase.dbg.a:$(BASE_DEBUG_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libbvar.a:$(BVAR_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libbvar.dbg.a:$(BVAR_DEBUG_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libbthread.a:$(BTHREAD_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libbthread.dbg.a:$(BTHREAD_DEBUG_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libjson2pb.a:$(JSON2PB_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libjson2pb.dbg.a:$(JSON2PB_DEBUG_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libmcpack2pb.a:$(MCPACK2PB_OBJS)
@echo "Packing $@"
@ar crs $@ $^
libmcpack2pb.dbg.a:$(MCPACK2PB_DEBUG_OBJS)
@echo "Packing $@"
@ar crs $@ $^
@rm -rf libbrpc.dbg.a $(DEBUG_OBJS)
protoc-gen-mcpack:src/mcpack2pb/generator.o libmcpack2pb.a libbase.a libbthread.a libbvar.a
protoc-gen-mcpack:src/mcpack2pb/generator.o libbrpc.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
# force generation of pb headers before compiling to avoid fail-to-import issues in compiling pb.cc
libbrpc.a:$(BRPC_PROTOS:.proto=.pb.h) $(BRPC_OBJS)
libbrpc.a:$(BRPC_PROTOS:.proto=.pb.h) $(OBJS)
@echo "Packing $@"
@ar crs $@ $^
@ar crs $@ $(OBJS)
libbrpc.dbg.a:$(BRPC_PROTOS:.proto=.pb.h) $(BRPC_DEBUG_OBJS)
libbrpc.dbg.a:$(BRPC_PROTOS:.proto=.pb.h) $(DEBUG_OBJS)
@echo "Packing $@"
@ar crs $@ $^
@ar crs $@ $(DEBUG_OBJS)
.PHONY:output/include
output/include:
......@@ -291,7 +244,7 @@ output/include:
@cp src/idl_options.proto src/idl_options.pb.h $@
.PHONY:output/lib
output/lib:libbase.a libbvar.a libbthread.a libjson2pb.a libmcpack2pb.a libbrpc.a
output/lib:libbrpc.a
@echo "Copying to $@"
@mkdir -p $@
@cp $^ $@
......
......@@ -6,7 +6,7 @@ include $(BRPC_PATH)/config.mk
CXXFLAGS = -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS += -lbase -lbvar -lbthread -lbrpc -ljson2pb -lmcpack2pb
STATIC_LINKINGS += -lbrpc
CLIENT_SOURCES = client.cpp
SERVER_SOURCES = server.cpp
......@@ -27,7 +27,7 @@ clean:
echo_client:$(PROTO_OBJS) $(CLIENT_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
echo_server:$(PROTO_OBJS) $(SERVER_OBJS)
@echo "Linking $@"
......
......@@ -10,7 +10,7 @@ ifeq ($(NEED_GPERFTOOLS), 1)
endif
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS += -lbase -lbvar -lbthread -lbrpc -ljson2pb -lmcpack2pb
STATIC_LINKINGS += -lbrpc
CLIENT_SOURCES = http_client.cpp
BENCHMARK_SOURCES = benchmark_http.cpp
......
......@@ -3,7 +3,7 @@ include $(BRPC_PATH)/config.mk
CXXFLAGS = -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS += -lbase -lbvar -lbthread -lbrpc -ljson2pb -lmcpack2pb
STATIC_LINKINGS += -lbrpc
SOURCES = $(wildcard *.cpp)
OBJS = $(addsuffix .o, $(basename $(SOURCES)))
......
......@@ -10,7 +10,7 @@ ifeq ($(NEED_GPERFTOOLS), 1)
endif
HDRPATHS=-I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS=-L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS+=-lbase -lbvar -lbthread -lbrpc -ljson2pb -lmcpack2pb
STATIC_LINKINGS+=-lbrpc
CLIENT_SOURCES = client.cpp
SERVER_SOURCES = server.cpp
......@@ -31,7 +31,7 @@ clean:
echo_client:$(PROTO_OBJS) $(CLIENT_OBJS)
@echo "Linking $@"
@$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
$(CXX) $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS) -o $@
echo_server:$(PROTO_OBJS) $(SERVER_OBJS)
@echo "Linking $@"
......
......@@ -4,7 +4,7 @@ CXXFLAGS = -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
DYNAMIC_LINKINGS += -lreadline -lncurses
STATIC_LINKINGS += -lbase -lbvar -lbthread -lbrpc -ljson2pb -lmcpack2pb
STATIC_LINKINGS += -lbrpc
PRESS_SOURCES = redis_press.cpp
CLI_SOURCES = redis_cli.cpp
......
......@@ -160,37 +160,22 @@ clean:clean_bins
clean_bins:
@rm -rf $(TEST_BINS)
../libbase.dbg.a:
@$(MAKE) -C.. libbase.dbg.a
../libbvar.dbg.a:
@$(MAKE) -C.. libbvar.dbg.a
../libbthread.dbg.a:
@$(MAKE) -C.. libbthread.dbg.a
../libbrpc.dbg.a:
@$(MAKE) -C.. libbrpc.dbg.a
../libmcpack2pb.dbg.a:
@$(MAKE) -C.. libmcpack2pb.dbg.a
../libjson2pb.dbg.a:
@$(MAKE) -C.. libjson2pb.dbg.a
test_base:$(TEST_BASE_OBJS) ../libbase.dbg.a
test_base:$(TEST_BASE_OBJS) ../libbrpc.dbg.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
test_bvar:$(TEST_BVAR_OBJS) ../libbase.dbg.a ../libbvar.dbg.a
test_bvar:$(TEST_BVAR_OBJS) ../libbrpc.dbg.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
bthread%unittest:bthread%unittest.o ../libbase.dbg.a ../libbvar.dbg.a ../libbthread.dbg.a
bthread%unittest:bthread%unittest.o ../libbrpc.dbg.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
brpc_%_unittest:$(TEST_PROTO_OBJS) brpc_%_unittest.o ../libbase.dbg.a ../libbvar.dbg.a ../libbthread.dbg.a ../libbrpc.dbg.a ../libmcpack2pb.dbg.a ../libjson2pb.dbg.a
brpc_%_unittest:$(TEST_PROTO_OBJS) brpc_%_unittest.o ../libbrpc.dbg.a
@echo "Linking $@"
@$(CXX) -o $@ $(LIBPATHS) -Xlinker "-(" $^ -Wl,-Bstatic $(STATIC_LINKINGS) -Wl,-Bdynamic -Xlinker "-)" $(DYNAMIC_LINKINGS)
......
......@@ -5,7 +5,6 @@ if [ -z "$1" ]; then
exit 1
fi
PATCHFILE=$1
FILTER_TARGET_DIR_CMD=
if [ -d "$1/.svn" ]; then
if [ -z "$2" ]; then
echo "Second argument must be a SVN revision"
......@@ -13,12 +12,11 @@ if [ -d "$1/.svn" ]; then
fi
CURRENT_DIR=`pwd`
SVN_DIR=$1
# replace the filepaths in diff
FILTER_TARGET_DIR_CMD=-e\ "s|$SVN_DIR|$CURRENT_DIR/src/|g"
REV=$2
PATCHFILE=$REV.patch
PATCHFILE=$CURRENT_DIR/$REV.patch
echo "*** Generating diff of $SVN_DIR@$REV"
svn diff $SVN_DIR -c $REV > $PATCHFILE
cd $SVN_DIR && svn diff . -c $REV > $PATCHFILE
cd $CURRENT_DIR
fi
MODIFIED_PATCHFILE="$(basename $PATCHFILE).brpc_os"
......@@ -48,7 +46,6 @@ cat $PATCHFILE | sed -e 's/src\/baidu\/rpc\//src\/brpc\//g' \
-e 's/ base\// src\/base\//g' \
-e 's/ bthread\// src\/bthread\//g' \
-e 's/ bvar\// src\/bvar\//g' \
$FILTER_TARGET_DIR_CMD \
> $MODIFIED_PATCHFILE
EXTRA_ARGS=
if [ -z "$DO_RUN" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment