Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
4c2c7802
Commit
4c2c7802
authored
Jul 31, 2017
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support dynamic linking of deps
Change-Id: Ifb03869fddec3e67f10f0aa7efd7d28a49b2b260
parent
a4562980
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
222 additions
and
429 deletions
+222
-429
Makefile
Makefile
+5
-2
config.mk
config.mk
+0
-1
config_brpc.sh
config_brpc.sh
+104
-36
Makefile
example/asynchronous_echo_c++/Makefile
+5
-4
Makefile
example/backup_request_c++/Makefile
+5
-4
Makefile
example/cancel_c++/Makefile
+5
-4
Makefile
example/cascade_echo_c++/Makefile
+5
-5
Makefile
example/dynamic_partition_echo_c++/Makefile
+5
-5
Makefile
example/echo_c++/Makefile
+5
-4
Makefile
example/echo_c++_hulu_pbrpc/Makefile
+5
-4
Makefile
example/echo_c++_sofa_pbrpc/Makefile
+5
-4
Makefile
example/echo_c++_ubrpc_compack/Makefile
+5
-4
Makefile
example/http_c++/Makefile
+8
-8
Makefile
example/memcache_c++/Makefile
+4
-3
Makefile
example/multi_threaded_echo_c++/Makefile
+5
-5
Makefile
example/multi_threaded_echo_fns_c++/Makefile
+5
-5
Makefile
example/multi_threaded_mcpack_c++/Makefile
+5
-5
Makefile
example/multi_threaded_ubrpc_compack_c++/Makefile
+0
-50
client.cpp
example/multi_threaded_ubrpc_compack_c++/client.cpp
+0
-146
echo.proto
example/multi_threaded_ubrpc_compack_c++/echo.proto
+0
-19
server.cpp
example/multi_threaded_ubrpc_compack_c++/server.cpp
+0
-74
Makefile
example/nshead_extension_c++/Makefile
+5
-4
Makefile
example/nshead_pb_extension_c++/Makefile
+5
-4
Makefile
example/parallel_echo_c++/Makefile
+5
-5
Makefile
example/partition_echo_c++/Makefile
+5
-5
Makefile
example/redis_c++/Makefile
+6
-4
Makefile
example/selective_echo_c++/Makefile
+5
-5
Makefile
example/session_data_and_thread_local/Makefile
+5
-5
Makefile
example/streaming_echo_c++/Makefile
+5
-4
make_all_examples
tools/make_all_examples
+0
-1
No files found.
Makefile
View file @
4c2c7802
...
...
@@ -4,9 +4,12 @@ CXXFLAGS=$(CPPFLAGS) -O2 -g -pipe -Wall -W -Werror -fPIC -fstrict-aliasing -Wno-
CFLAGS
=
$(CPPFLAGS)
-O2
-g
-pipe
-Wall
-W
-Werror
-fPIC
-fstrict-aliasing
-Wno-unused-parameter
INCPATH
=
-I
.
$
(
addprefix
-I
,
$(INCS)
)
LIBPATH
=
$
(
addprefix
-L
,
$(LIBS)
)
SRCEXTS
=
.c .cc .cpp .proto
HDREXTS
=
.h .hpp
LDFLAGS
=
-lpthread
-lrt
-ldl
-lz
-lssl
-lcrypto
#dyanmic linking of libprotoc.so crashes on ubuntu when protoc-gen-mcpack is invoked
STATIC_LINKING
+=
-lprotoc
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
BASE_SOURCES
=
\
base/third_party/dmg_fp/g_fmt.cc
\
...
...
@@ -226,7 +229,7 @@ libmcpack2pb.a:$(MCPACK2PB_OBJS)
protoc-gen-mcpack
:
mcpack2pb/generator.o libmcpack2pb.a libbase.a libbthread.a libbvar.a
@
echo
"Linking
$@
"
@
$(CXX)
-o
protoc-gen-mcpack
-
Xlinker
"-("
$^
$(LIBS)
$(PROTOC_LIB)
-Xlinker
"-)"
$(LDFLAGS)
@
$(CXX)
-o
protoc-gen-mcpack
-
L
$(LIBPATH)
-Xlinker
"-("
$^
-Xlinker
"-)"
$(LDFLAGS)
libbrpc.a
:
$(BRPC_OBJS)
@
echo
"Linking
$@
"
...
...
config.mk
deleted
100644 → 0
View file @
a4562980
$(error Run config_brpc.sh first)
config_brpc.sh
View file @
4c2c7802
#!/bin/bash
if
[
-z
"
$BASH
"
]
;
then
ECHO
=
echo
ERROR
=
'>&2 echo'
else
ECHO
=
'echo -e'
ERROR
=
'>&2 echo -e'
fi
# NOTE: This requires GNU getopt. On Mac OS X and FreeBSD, you have to install this
# separately; see below.
TEMP
=
`
getopt
-o
v:
--long
incs:,libs:,cc:,cxx:
-n
'config_brpc'
--
"
$@
"
`
if
[
$?
!=
0
]
;
then
echo
"Terminating..."
>
&2
;
exit
1
;
fi
if
[
$?
!=
0
]
;
then
$ERROR
"Terminating..."
;
exit
1
;
fi
# Note the quotes around `$TEMP': they are essential!
eval set
--
"
$TEMP
"
...
...
@@ -22,69 +28,131 @@ while true; do
esac
done
if
[
-z
"
$INCS
"
]
||
[
-z
"
$LIBS
"
]
;
then
>
&2
echo
"config_brpc: --incs=INCPATHS --libs=LIBPATHS must be specified"
$ERROR
"config_brpc: --incs=INCPATHS --libs=LIBPATHS must be specified"
exit
1
fi
find_lib
()
{
find
${
LIBS
}
-name
"
$1
"
|
head
-n1
find_
dir_of_
lib
()
{
dirname
$(
find
${
LIBS
}
-name
"lib
${
1
}
.a"
-o
-name
"lib
${
1
}
.so"
|
head
-n1
)
}
find_lib_or_die
()
{
local
lib
=
$(
find
_lib
$1
)
if
[
-z
"
$
lib
"
]
;
then
>
&2
echo
"fail to find
$1
from -libs"
find_
dir_of_
lib_or_die
()
{
local
dir
=
$(
find_dir_of
_lib
$1
)
if
[
-z
"
$
dir
"
]
;
then
$ERROR
"fail to find
$1
from -libs"
exit
1
else
echo
$lib
$ECHO
$dir
fi
}
find_dir_of_header
()
{
find
${
INCS
}
-path
"*/
$1
"
|
sed
"s|
$1
||g"
}
find_dir_of_header_or_die
()
{
local dir
=
$(
find_dir_of_header
$1
)
if
[
-z
"
$dir
"
]
;
then
>
&2
echo
"fail to find
$1
from -incs"
$ERROR
"fail to find
$1
from -incs"
exit
1
else
echo
$dir
$ECHO
$dir
fi
}
STATIC_LINKING
=
DYNAMIC_LINKING
=
"-lpthread -lrt -lssl -lcrypto -ldl -lz"
append_linking
()
{
if
[
-f
$1
/lib
${
2
}
.a
]
;
then
STATIC_LINKING
=
"
${
STATIC_LINKING
}
-l
$2
"
else
DYNAMIC_LINKING
=
"
${
DYNAMIC_LINKING
}
-l
$2
"
fi
}
GFLAGS_LIB
=
$(
find_lib_or_die libgflags.a
)
PROTOBUF_LIB
=
$(
find_lib_or_die libprotobuf.a
)
PROTOC_LIB
=
$(
find_lib_or_die libprotoc.a
)
GFLAGS_DIR
=
$(
find_dir_of_lib_or_die gflags
)
append_linking
$GFLAGS_DIR
gflags
PROTOBUF_DIR
=
$(
find_dir_of_lib_or_die protobuf
)
append_linking
$PROTOBUF_DIR
protobuf
PROTOC_DIR
=
$(
find_dir_of_lib_or_die protoc
)
LEVELDB_DIR
=
$(
find_dir_of_lib_or_die leveldb
)
append_linking
$LEVELDB_DIR
leveldb
# required by leveldb
SNAPPY_DIR
=
$(
find_dir_of_lib snappy
)
if
[
!
-z
"
$SNAPPY_DIR
"
]
;
then
append_linking
$SNAPPY_DIR
snappy
fi
PROTOC
=
$(
which protoc 2>/dev/null
)
if
[
-z
"
$PROTOC
"
]
;
then
PROTOC
=
$(
find_
lib_or_die protoc
)
PROTOC
=
$(
find_
dir_of_lib_or_die protoc
)
/protoc
fi
LEVELDB_LIB
=
$(
find_lib_or_die libleveldb.a
)
SNAPPY_LIB
=
$(
find_lib libsnappy.a
)
GFLAGS_INC
=
$(
find_dir_of_header gflags/gflags.h
)
PROTOBUF_INC
=
$(
find_dir_of_header google/protobuf/message.h
)
LEVELDB_INC
=
$(
find_dir_of_header leveldb/db.h
)
NEW_INCS
=
$(
echo
$GFLAGS_INC
$PROTOBUF_INC
$LEVELDB_INC
|
sort
|
uniq
)
INCS
=
$(
$ECHO
"
$GFLAGS_INC
\n
$PROTOBUF_INC
\n
$LEVELDB_INC
"
|
sort
|
uniq
)
LIBS
=
$(
$ECHO
"
$GFLAGS_DIR
\n
$PROTOBUF_DIR
\n
$LEVELDB_DIR
\n
$SNAPPY_DIR
\n
$PROTOC_DIR
"
|
sort
|
uniq
)
absent_in_the_list
()
{
TMP
=
$(
$ECHO
"
`
$ECHO
"
$1
\n
$2
"
|
sort
|
uniq
`
"
)
if
[
"
${
TMP
}
"
=
"
$2
"
]
;
then
return
1
fi
return
0
}
#can't use \n in texts because sh does not support -e
echo
"INCS=
$NEW_INCS
"
>
config.mk
echo
"LIBS=
$GFLAGS_LIB
$PROTOBUF_LIB
$LEVELDB_LIB
$SNAPPY_LIB
"
>>
config.mk
echo
"PROTOC_LIB=
$PROTOC_LIB
"
>>
config.mk
echo
"PROTOC=
$PROTOC
"
>>
config.mk
echo
"PROTOBUF_INC=
$PROTOBUF_INC
"
>>
config.mk
echo
"CC=
$CC
"
>>
config.mk
echo
"CXX=
$CXX
"
>>
config.mk
echo
"ifeq (
\$
(LINK_PERFTOOLS), 1)"
>>
config.mk
TCMALLOC_LIB
=
$(
find_lib libtcmalloc_and_profiler.a
)
if
[
!
-z
"
$TCMALLOC_LIB
"
]
;
then
echo
" LIBS+=
$TCMALLOC_LIB
"
>>
config.mk
CONTENT
=
"INCS=
$(
$ECHO
$INCS
)
"
CONTENT
=
"
${
CONTENT
}
\n
LIBS=
$(
$ECHO
$LIBS
)
"
CONTENT
=
"
${
CONTENT
}
\n
PROTOC=
$PROTOC
"
CONTENT
=
"
${
CONTENT
}
\n
PROTOBUF_INC=
$PROTOBUF_INC
"
CONTENT
=
"
${
CONTENT
}
\n
CC=
$CC
"
CONTENT
=
"
${
CONTENT
}
\n
CXX=
$CXX
"
CONTENT
=
"
${
CONTENT
}
\n
STATIC_LINKING=
$STATIC_LINKING
"
CONTENT
=
"
${
CONTENT
}
\n
DYNAMIC_LINKING=
$DYNAMIC_LINKING
"
CONTENT
=
"
${
CONTENT
}
\n
ifeq (
\$
(LINK_PERFTOOLS), 1)"
# required by cpu/heap profiler
TCMALLOC_DIR
=
$(
find_dir_of_lib tcmalloc_and_profiler
)
if
[
!
-z
"
$TCMALLOC_DIR
"
]
;
then
if
absent_in_the_list
"
$TCMALLOC_DIR
"
"
$LIBS
"
;
then
CONTENT
=
"
${
CONTENT
}
\n
LIBS+=
$TCMALLOC_DIR
"
LIBS
=
"
${
LIBS
}
\n
$TCMALLOC_DIR
"
fi
TCMALLOC_INC
=
$(
find_dir_of_header google/tcmalloc.h
)
if
[
!
-z
"
$TCMALLOC_INC
"
]
&&
[
"
$TCMALLOC_INC
"
!=
"
$INCS
"
]
;
then
echo
" INCS+=
$TCMALLOC_INC
"
>>
config.mk
if
absent_in_the_list
"
$TCMALLOC_INC
"
"
$INCS
"
;
then
CONTENT
=
"
${
CONTENT
}
\n
INCS+=
$TCMALLOC_INC
"
fi
if
[
-f
$TCMALLOC_DIR
/libtcmalloc_and_profiler.a
]
;
then
CONTENT
=
"
${
CONTENT
}
\n
STATIC_LINKING+=-ltcmalloc_and_profiler"
else
CONTENT
=
"
${
CONTENT
}
\n
DYNAMIC_LINKING+=-ltcmalloc_and_profiler"
fi
fi
UNWIND_LIB
=
$(
find_lib libunwind.a
)
if
[
!
-z
"
$UNWIND_LIB
"
]
;
then
echo
" LIBS+=
$UNWIND_LIB
"
>>
config.mk
# required by tcmalloc('s profiler)
UNWIND_DIR
=
$(
find_dir_of_lib unwind
)
if
[
!
-z
"
$UNWIND_DIR
"
]
;
then
if
absent_in_the_list
"
$UNWIND_DIR
"
"
$LIBS
"
;
then
CONTENT
=
"
${
CONTENT
}
\n
LIBS+=
$UNWIND_DIR
"
LIBS
=
"
${
LIBS
}
\n
$UNWIND_DIR
"
fi
if
[
-f
$UNWIND_DIR
/libunwind.a
]
;
then
CONTENT
=
"
${
CONTENT
}
\n
STATIC_LINKING+=-lunwind"
else
CONTENT
=
"
${
CONTENT
}
\n
DYNAMIC_LINKING+=-lunwind"
fi
fi
# required by libunwind
LZMA_DIR
=
$(
find_dir_of_lib lzma
)
if
[
!
-z
"
$LZMA_DIR
"
]
;
then
if
absent_in_the_list
"
$LZMA_DIR
"
"
$LIBS
"
;
then
CONTENT
=
"
${
CONTENT
}
\n
LIBS+=
$LZMA_DIR
"
LIBS
=
"
${
LIBS
}
\n
$LZMA_DIR
"
fi
if
[
-f
$LZMA_DIR
/liblzma.a
]
;
then
CONTENT
=
"
${
CONTENT
}
\n
STATIC_LINKING+=-llzma"
else
CONTENT
=
"
${
CONTENT
}
\n
DYNAMIC_LINKING+=-llzma"
fi
fi
echo
"endif"
>>
config.mk
CONTENT
=
"
${
CONTENT
}
\n
endif"
$ECHO
"
$CONTENT
"
>
config.mk
example/asynchronous_echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/backup_request_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/cancel_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/cascade_echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/dynamic_partition_echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/echo_c++_hulu_pbrpc/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/echo_c++_sofa_pbrpc/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/echo_c++_ubrpc_compack/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/http_c++/Makefile
View file @
4c2c7802
...
...
@@ -4,12 +4,11 @@ BRPC_PATH=../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
-I
$(GFLAGS_PATH)
/include
-I
$(LEVELDB_PATH)
/include
-I
$(PROTOBUF_PATH)
/include
-I
$(TCMALLOC_PATH)
/include
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
LIBS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
endif
CLIENT_SOURCES
=
http_client.cpp
...
...
@@ -22,6 +21,7 @@ PROTO_GENS = $(addsuffix .pb.h, $(basename $(PROTOS))) $(addsuffix .pb.cc, $(bas
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
BENCHMARK_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(BENCHMARK_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
http_client benchmark_http http_server
...
...
@@ -33,15 +33,15 @@ clean:
http_client
:
$(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
benchmark_http
:
$(BENCHMARK_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
http_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/memcache_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,11 +3,12 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
SOURCES
=
$
(
wildcard
*
.cpp
)
OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
memcache_client
...
...
@@ -19,7 +20,7 @@ clean:
memcache_client
:
$(OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.o
:
%.cpp
@
echo
"Compiling
$@
"
...
...
example/multi_threaded_echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/multi_threaded_echo_fns_c++/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/multi_threaded_mcpack_c++/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/multi_threaded_ubrpc_compack_c++/Makefile
deleted
100644 → 0
View file @
a4562980
LINK_PERFTOOLS
=
1
include
../../config.mk
BRPC_PATH
=
../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIBS
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
PROTOS
=
echo.proto
PROTO_OBJS
=
$
(
addsuffix .pb.o,
$
(
basename
$(PROTOS)
))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
.PHONY
:
all
all
:
echo_client echo_server
.PHONY
:
clean
clean
:
@
echo
"Cleaning"
@
rm
-rf
echo_client echo_server
$(PROTO_GENS)
$(PROTO_OBJS)
$(CLIENT_OBJS)
$(SERVER_OBJS)
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
@
$(PROTOC)
--plugin
=
protoc-gen-mcpack
=
$(BRPC_PATH)
/bin/protoc-gen-mcpack
--proto_path
=
.
--proto_path
=
$(BRPC_PATH)
/include
--proto_path
=
$(PROTOBUF_INC)
--cpp_out
=
.
--mcpack_out
=
.
$<
%.o
:
%.cpp
@
echo
"Compiling
$@
"
@
$(CXX)
-c
$(INCPATH)
$(CXXFLAGS)
$<
-o
$@
%.o
:
%.cc
@
echo
"Compiling
$@
"
@
$(CXX)
-c
$(INCPATH)
$(CXXFLAGS)
$<
-o
$@
example/multi_threaded_ubrpc_compack_c++/client.cpp
deleted
100644 → 0
View file @
a4562980
// Baidu RPC - A framework to host and access services throughout Baidu.
// Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
//
// If you have any problem, contact us:
// Baidu Hi : group 1296497
// Email : pbrpc@baidu.com
// Wiki : http://wiki.baidu.com/display/RPC/baidu-rpc
// A client sending requests to server by multiple threads.
#include <gflags/gflags.h>
#include <bthread/bthread.h>
#include <base/logging.h>
#include <base/string_printf.h>
#include <base/time.h>
#include <base/macros.h>
#include <brpc/server.h>
#include <brpc/channel.h>
#include <deque>
#include "echo.pb.h"
#include <bvar/bvar.h>
DEFINE_int32
(
thread_num
,
50
,
"Number of threads to send requests"
);
DEFINE_bool
(
use_bthread
,
false
,
"Use bthread to send requests"
);
DEFINE_int32
(
attachment_size
,
0
,
"Carry so many byte attachment along with requests"
);
DEFINE_int32
(
request_size
,
16
,
"Bytes of each request"
);
DEFINE_string
(
server
,
"0.0.0.0:8002"
,
"IP Address of server"
);
DEFINE_string
(
load_balancer
,
""
,
"The algorithm for load balancing"
);
DEFINE_int32
(
timeout_ms
,
100
,
"RPC timeout in milliseconds"
);
DEFINE_int32
(
max_retry
,
3
,
"Max retries(not including the first RPC)"
);
DEFINE_bool
(
dont_fail
,
false
,
"Print fatal when some call failed"
);
DEFINE_int32
(
dummy_port
,
0
,
"Launch dummy server at this port"
);
std
::
string
g_request
;
std
::
string
g_attachment
;
bvar
::
LatencyRecorder
g_latency_recorder
(
"client"
);
bvar
::
Adder
<
int
>
g_error_count
(
"client_error_count"
);
static
void
*
sender
(
void
*
arg
)
{
// Normally, you should not call a Channel directly, but instead construct
// a stub Service wrapping it. stub can be shared by all threads as well.
example
::
EchoService_Stub
stub
(
static_cast
<
google
::
protobuf
::
RpcChannel
*>
(
arg
));
int
log_id
=
0
;
while
(
!
brpc
::
IsAskedToQuit
())
{
// We will receive response synchronously, safe to put variables
// on stack.
example
::
EchoRequest
request
;
example
::
EchoResponse
response
;
brpc
::
Controller
cntl
;
request
.
set_message
(
g_request
);
cntl
.
set_log_id
(
log_id
++
);
// set by user
if
(
!
g_attachment
.
empty
())
{
// Set attachment which is wired to network directly instead of
// being serialized into protobuf messages.
cntl
.
request_attachment
().
append
(
g_attachment
);
}
// Because `done'(last parameter) is NULL, this function waits until
// the response comes back or error occurs(including timedout).
stub
.
Echo
(
&
cntl
,
&
request
,
&
response
,
NULL
);
if
(
!
cntl
.
Failed
())
{
g_latency_recorder
<<
cntl
.
latency_us
();
}
else
{
g_error_count
<<
1
;
CHECK
(
brpc
::
IsAskedToQuit
()
||
!
FLAGS_dont_fail
)
<<
"error="
<<
cntl
.
ErrorText
()
<<
" latency="
<<
cntl
.
latency_us
();
// We can't connect to the server, sleep a while. Notice that this
// is a specific sleeping to prevent this thread from spinning too
// fast. You should continue the business logic in a production
// server rather than sleeping.
bthread_usleep
(
50000
);
}
}
return
NULL
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
// Parse gflags. We recommend you to use gflags as well.
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
// A Channel represents a communication line to a Server. Notice that
// Channel is thread-safe and can be shared by all threads in your program.
brpc
::
Channel
channel
;
// Initialize the channel, NULL means using default options.
brpc
::
ChannelOptions
options
;
options
.
protocol
=
"ubrpc_compack"
;
options
.
timeout_ms
=
FLAGS_timeout_ms
/*milliseconds*/
;
options
.
max_retry
=
FLAGS_max_retry
;
if
(
channel
.
Init
(
FLAGS_server
.
c_str
(),
FLAGS_load_balancer
.
c_str
(),
&
options
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to initialize channel"
;
return
-
1
;
}
if
(
FLAGS_attachment_size
>
0
)
{
g_attachment
.
resize
(
FLAGS_attachment_size
,
'a'
);
}
if
(
FLAGS_request_size
<=
0
)
{
LOG
(
ERROR
)
<<
"Bad request_size="
<<
FLAGS_request_size
;
return
-
1
;
}
g_request
.
resize
(
FLAGS_request_size
,
'r'
);
if
(
FLAGS_dummy_port
>
0
)
{
brpc
::
StartDummyServerAt
(
FLAGS_dummy_port
);
}
std
::
vector
<
bthread_t
>
tids
;
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
}
}
else
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
bthread_start_background
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create bthread"
;
return
-
1
;
}
}
}
while
(
!
brpc
::
IsAskedToQuit
())
{
sleep
(
1
);
LOG
(
INFO
)
<<
"Sending EchoRequest at qps="
<<
g_latency_recorder
.
qps
(
1
)
<<
" latency="
<<
g_latency_recorder
.
latency
(
1
);
}
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
}
return
0
;
}
example/multi_threaded_ubrpc_compack_c++/echo.proto
deleted
100644 → 0
View file @
a4562980
// Converted from echo.idl by public/mcpack2pb/idl2proto
syntax
=
"proto2"
;
import
"idl_options.proto"
;
option
(
idl_support
)
=
true
;
option
cc_generic_services
=
true
;
package
example
;
message
EchoRequest
{
required
string
message
=
1
;
}
message
EchoResponse
{
required
string
message
=
1
;
}
service
EchoService
{
rpc
Echo
(
EchoRequest
)
returns
(
EchoResponse
);
}
example/multi_threaded_ubrpc_compack_c++/server.cpp
deleted
100644 → 0
View file @
a4562980
// Baidu RPC - A framework to host and access services throughout Baidu.
// Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
//
// If you have any problem, contact us:
// Baidu Hi : group 1296497
// Email : pbrpc@baidu.com
// Wiki : http://wiki.baidu.com/display/RPC/baidu-rpc
// A server to receive EchoRequest and send back EchoResponse.
#include <gflags/gflags.h>
#include <base/logging.h>
#include <brpc/server.h>
#include <brpc/policy/ubrpc2pb_protocol.h>
#include "echo.pb.h"
DEFINE_int32
(
port
,
8002
,
"TCP Port of this server"
);
DEFINE_int32
(
idle_timeout_s
,
-
1
,
"Connection will be closed if there is no "
"read/write operations during the last `idle_timeout_s'"
);
DEFINE_int32
(
logoff_ms
,
2000
,
"Maximum duration of server's LOGOFF state "
"(waiting for client to close connection before server stops)"
);
DEFINE_int32
(
max_concurrency
,
0
,
"Limit of request processing in parallel"
);
DEFINE_int32
(
internal_port
,
-
1
,
"Only allow builtin services at this port"
);
namespace
example
{
// Your implementation of EchoService
class
EchoServiceImpl
:
public
EchoService
{
public
:
EchoServiceImpl
()
{}
~
EchoServiceImpl
()
{};
void
Echo
(
google
::
protobuf
::
RpcController
*
cntl_base
,
const
EchoRequest
*
request
,
EchoResponse
*
response
,
google
::
protobuf
::
Closure
*
done
)
{
brpc
::
ClosureGuard
done_guard
(
done
);
response
->
set_message
(
request
->
message
());
}
};
}
// namespace example
int
main
(
int
argc
,
char
*
argv
[])
{
// Parse gflags. We recommend you to use gflags as well.
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
// Generally you only need one Server.
brpc
::
Server
server
;
// Instance of your service.
example
::
EchoServiceImpl
echo_service_impl
;
// Add the service into server. Notice the second parameter, because the
// service is put on stack, we don't want server to delete it, otherwise
// use brpc::SERVER_OWNS_SERVICE.
if
(
server
.
AddService
(
&
echo_service_impl
,
brpc
::
SERVER_DOESNT_OWN_SERVICE
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to add service"
;
return
-
1
;
}
// Start the server.
brpc
::
ServerOptions
options
;
options
.
idle_timeout_sec
=
FLAGS_idle_timeout_s
;
options
.
nshead_service
=
new
brpc
::
policy
::
UbrpcCompackAdaptor
;
options
.
max_concurrency
=
FLAGS_max_concurrency
;
options
.
internal_port
=
FLAGS_internal_port
;
if
(
server
.
Start
(
FLAGS_port
,
&
options
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to start EchoServer"
;
return
-
1
;
}
// Wait until Ctrl-C is pressed, then Stop() and Join() the server.
server
.
RunUntilAskedToQuit
();
return
0
;
}
example/nshead_extension_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/nshead_pb_extension_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/parallel_echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/partition_echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/redis_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,14 +3,16 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIBS
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
-lreadline
-lncurses
LIBPATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
DYNAMIC_LINKING
+=
-lreadline
-lncurses
PRESS_SOURCES
=
redis_press.cpp
CLI_SOURCES
=
redis_cli.cpp
PRESS_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(PRESS_SOURCES)
))
CLI_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLI_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
redis_press redis_cli
...
...
@@ -22,11 +24,11 @@ clean:
redis_press
:
$(PRESS_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
redis_cli
:
$(CLI_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.o
:
%.cpp
@
echo
"Compiling
$@
"
...
...
example/selective_echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/session_data_and_thread_local/Makefile
View file @
4c2c7802
...
...
@@ -5,11 +5,10 @@ CPPFLAGS=-std=c++0x -g -DNDEBUG -O2 -pipe -W -Wall -Werror -fPIC -Wno-deprecated
CXXFLAGS
=
$(CPPFLAGS)
CFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
ifeq
($(LINK_PERFTOOLS),
1)
CPPFLAGS
+=
-DBRPC_ENABLE_CPU_PROFILER
-DBRPC_ENABLE_HEAP_PROFILER
LDFLAGS
+=
-llzma
endif
CLIENT_SOURCES
=
client.cpp
...
...
@@ -20,6 +19,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -31,11 +31,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
example/streaming_echo_c++/Makefile
View file @
4c2c7802
...
...
@@ -3,8 +3,8 @@ BRPC_PATH = ../../output
CPPFLAGS
=
-std
=
c++0x
-g
-DNDEBUG
-O2
-pipe
-W
-Wall
-Werror
-fPIC
-Wno-deprecated
-Wno-unused-parameter
-D__const__
=
CXXFLAGS
=
$(CPPFLAGS)
INCPATH
=
-I
$(BRPC_PATH)
/include
$
(
addprefix
-I
,
$(INCS)
)
LIB
S
+=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
LDFLAGS
=
-lpthread
-lrt
-lssl
-lcrypto
-ldl
-lz
LIB
PATH
=
$
(
addprefix
-L
,
$(LIBS)
)
BRPC_LIBS
=
$
(
wildcard
$(BRPC_PATH)
/lib/lib
*
.a
)
CLIENT_SOURCES
=
client.cpp
SERVER_SOURCES
=
server.cpp
...
...
@@ -14,6 +14,7 @@ PROTO_OBJS = $(addsuffix .pb.o, $(basename $(PROTOS)))
PROTO_GENS
=
$
(
addsuffix .pb.h,
$
(
basename
$(PROTOS)
))
$
(
addsuffix .pb.cc,
$
(
basename
$(PROTOS)
))
CLIENT_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(CLIENT_SOURCES)
))
SERVER_OBJS
=
$
(
addsuffix .o,
$
(
basename
$(SERVER_SOURCES)
))
LDFLAGS
=
-Wl
,-Bstatic
$(STATIC_LINKING)
-Wl
,-Bdynamic
$(DYNAMIC_LINKING)
.PHONY
:
all
all
:
echo_client echo_server
...
...
@@ -25,11 +26,11 @@ clean:
echo_client
:
$(PROTO_OBJS) $(CLIENT_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
echo_server
:
$(PROTO_OBJS) $(SERVER_OBJS)
@
echo
"Linking
$@
"
@
$(CXX)
-Xlinker
"-("
$^
$(
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
@
$(CXX)
$(LIBPATH)
-Xlinker
"-("
$^
$(BRPC_
LIBS)
-Xlinker
"-)"
$(LDFLAGS)
-o
$@
%.pb.cc
:
%.proto
@
echo
"Generating
$@
"
...
...
tools/make_all_examples
View file @
4c2c7802
#!/bin/bash
saved_pwd_before_making=$PWD
for file in `find example -name Makefile`; do
cd $(dirname $file)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment