update cmake file

This commit is contained in:
wzlsuccess
2021-06-22 23:03:48 +08:00
parent f1f4c340a4
commit 48635daf07
13 changed files with 140 additions and 90 deletions

View File

@@ -6,6 +6,11 @@ DEFAULT_BUILD_DIR := build
BUILD_DIR := $(shell if [ -f $(MAKE_FILE) ]; then echo "."; else echo $(DEFAULT_BUILD_DIR); fi)
CMAKE3 := $(shell if which cmake3>/dev/null ; then echo cmake3; else echo cmake; fi;)
KAFKA ?= n
MYSQL ?= y
REDIS ?= y
UPSTREAM ?= y
.PHONY: $(ALL_TARGETS)
all: base
@@ -14,18 +19,12 @@ all: base
base:
mkdir -p $(BUILD_DIR)
ifeq ($(KAFKA),y)
KAFKA=y
else
KAFKA=n
endif
ifeq ($(DEBUG),y)
cd $(BUILD_DIR) && $(CMAKE3) -D CMAKE_BUILD_TYPE=Debug -D KAFKA=$(KAFKA) $(ROOT_DIR)
cd $(BUILD_DIR) && $(CMAKE3) -D CMAKE_BUILD_TYPE=Debug -D KAFKA=$(KAFKA) -D MYSQL=$(MYSQL) -D REDIS=$(REDIS) -D UPSTREAM=$(UPSTREAM) $(ROOT_DIR)
else ifneq ("${INSTALL_PREFIX}install_prefix", "install_prefix")
cd $(BUILD_DIR) && $(CMAKE3) -DCMAKE_INSTALL_PREFIX:STRING=${INSTALL_PREFIX} -D KAFKA=$(KAFKA) $(ROOT_DIR)
cd $(BUILD_DIR) && $(CMAKE3) -DCMAKE_INSTALL_PREFIX:STRING=${INSTALL_PREFIX} -D KAFKA=$(KAFKA) -D MYSQL=$(MYSQL) -D REDIS=$(REDIS) -D UPSTREAM=$(UPSTREAM) $(ROOT_DIR)
else
cd $(BUILD_DIR) && $(CMAKE3) -D KAFKA=$(KAFKA) $(ROOT_DIR)
cd $(BUILD_DIR) && $(CMAKE3) -D KAFKA=$(KAFKA) -D MYSQL=$(MYSQL) -D REDIS=$(REDIS) -D UPSTREAM=$(UPSTREAM) $(ROOT_DIR)
endif
tutorial: all
@@ -52,4 +51,3 @@ endif
find . -name Makefile | xargs rm -f
find . -name "*.cmake" | xargs rm -f
find . -name CMakeFiles | xargs rm -rf

View File

@@ -3,9 +3,15 @@ project(client)
set(SRC
WFDnsClient.cc
WFMySQLConnection.cc
)
if (MYSQL STREQUAL "y")
set(SRC
${SRC}
WFMySQLConnection.cc
)
endif ()
add_library(${PROJECT_NAME} OBJECT ${SRC})
if (KAFKA STREQUAL "y")

View File

@@ -587,23 +587,18 @@ void ComplexKafkaTask::kafka_meta_callback(__WFKafkaTask *task)
kafka_merge_broker_list(&t->client_broker_map,
task->get_resp()->get_broker_list());
char name[64];
snprintf(name, 64, "%p.meta", t->client);
t->lock_status.get_mutex()->unlock();
WFTaskFactory::count_by_name(name, (unsigned int)-1);
}
else
{
t->state = WFT_STATE_TASK_ERROR;
t->error = WFT_ERR_KAFKA_META_FAILED;
t->finish = true;
char name[64];
snprintf(name, 64, "%p.meta", t->client);
t->lock_status.get_mutex()->unlock();
WFTaskFactory::count_by_name(name, (unsigned int)-1);
}
char name[64];
snprintf(name, 64, "%p.meta", t->client);
t->lock_status.get_mutex()->unlock();
WFTaskFactory::count_by_name(name, (unsigned int)-1);
}
void ComplexKafkaTask::kafka_cgroup_callback(__WFKafkaTask *task)

View File

@@ -4,13 +4,25 @@ project(factory)
set(SRC
WFGraphTask.cc
DnsTaskImpl.cc
HttpTaskImpl.cc
RedisTaskImpl.cc
MySQLTaskImpl.cc
WFTaskFactory.cc
Workflow.cc
HttpTaskImpl.cc
)
if (MYSQL STREQUAL "y")
set(SRC
${SRC}
MySQLTaskImpl.cc
)
endif ()
if (REDIS STREQUAL "y")
set(SRC
${SRC}
RedisTaskImpl.cc
)
endif ()
add_library(${PROJECT_NAME} OBJECT ${SRC})
if (KAFKA STREQUAL "y")
@@ -20,4 +32,3 @@ if (KAFKA STREQUAL "y")
add_library("factory_kafka" OBJECT ${SRC})
set_property(SOURCE KafkaTaskImpl.cc APPEND PROPERTY COMPILE_OPTIONS "-fno-rtti")
endif ()

View File

@@ -113,13 +113,9 @@ CommMessageOut *__ComplexKafkaTask::message_out()
if (seqid == 0)
{
KafkaConnectionInfo *conn_info = new KafkaConnectionInfo;
auto&& deleter = [] (void *ctx)
{
KafkaConnectionInfo *conn_info = (KafkaConnectionInfo *)ctx;
delete conn_info;
};
this->get_connection()->set_context(conn_info, std::move(deleter));
this->get_connection()->set_context(conn_info, std::move([](void *ctx) {
delete (KafkaConnectionInfo *)ctx;
}));
this->get_req()->set_api(&conn_info->api);
if (!this->get_req()->get_config()->get_broker_version())
@@ -143,7 +139,7 @@ CommMessageOut *__ComplexKafkaTask::message_out()
p = (kafka_api_version_t *)malloc(api_cnt * sizeof(*p));
if (p)
{
memcpy(p, api, sizeof(kafka_api_version_t) * api_cnt);
memcpy(p, api, api_cnt * sizeof(kafka_api_version_t));
conn_info->api.api = p;
conn_info->api.elements = api_cnt;
conn_info->api.features = kafka_get_features(p, api_cnt);

View File

@@ -3,10 +3,15 @@ project(manager)
set(SRC
DnsCache.cc
UpstreamManager.cc
RouteManager.cc
WFGlobal.cc
)
add_library(${PROJECT_NAME} OBJECT ${SRC})
if (UPSTREAM STREQUAL "y")
set(SRC
${SRC}
UpstreamManager.cc
)
endif ()
add_library(${PROJECT_NAME} OBJECT ${SRC})

View File

@@ -4,9 +4,14 @@ project(nameservice)
set(SRC
WFNameService.cc
WFDnsResolver.cc
WFServiceGovernance.cc
UpstreamPolicies.cc
)
add_library(${PROJECT_NAME} OBJECT ${SRC})
if (UPSTREAM STREQUAL "y")
set(SRC
${SRC}
WFServiceGovernance.cc
UpstreamPolicies.cc
)
endif ()
add_library(${PROJECT_NAME} OBJECT ${SRC})

View File

@@ -3,21 +3,33 @@ project(protocol)
set(SRC
dns_parser.c
http_parser.c
redis_parser.c
mysql_stream.c
mysql_parser.c
mysql_byteorder.c
DnsMessage.cc
DnsUtil.cc
MySQLMessage.cc
MySQLResult.cc
HttpMessage.cc
RedisMessage.cc
HttpUtil.cc
SSLWrapper.cc
http_parser.c
HttpMessage.cc
HttpUtil.cc
)
if (MYSQL STREQUAL "y")
set(SRC
${SRC}
mysql_stream.c
mysql_parser.c
mysql_byteorder.c
MySQLMessage.cc
MySQLResult.cc
)
endif ()
if (REDIS STREQUAL "y")
set(SRC
${SRC}
redis_parser.c
RedisMessage.cc
)
endif ()
add_library(${PROJECT_NAME} OBJECT ${SRC})
if (KAFKA STREQUAL "y")
@@ -32,4 +44,3 @@ if (KAFKA STREQUAL "y")
set_property(SOURCE KafkaDataTypes.cc APPEND PROPERTY COMPILE_OPTIONS "-fno-rtti")
set_property(SOURCE KafkaResult.cc APPEND PROPERTY COMPILE_OPTIONS "-fno-rtti")
endif ()

View File

@@ -426,6 +426,30 @@ std::string RedisValue::debug_string() const
return ret;
}
RedisMessage::RedisMessage():
parser_(new redis_parser_t),
stream_(new EncodeStream),
cur_size_(0),
asking_(false)
{
redis_parser_init(parser_);
}
RedisMessage::~RedisMessage()
{
if (parser_)
{
redis_parser_deinit(parser_);
delete parser_;
delete stream_;
}
}
RedisValue::~RedisValue()
{
free_data();
}
RedisMessage::RedisMessage(RedisMessage&& move) :
ProtocolMessage(std::move(move))
{
@@ -672,4 +696,3 @@ bool RedisResponse::set_result(const RedisValue& value)
}
}

View File

@@ -216,11 +216,6 @@ inline RedisValue::RedisValue():
{
}
inline RedisValue::~RedisValue()
{
free_data();
}
inline RedisValue::RedisValue(const RedisValue& copy):
type_(REDIS_REPLY_TYPE_NIL),
data_(NULL)
@@ -304,25 +299,6 @@ inline void RedisValue::clear()
set_nil();
}
inline RedisMessage::RedisMessage():
parser_(new redis_parser_t),
stream_(new EncodeStream),
cur_size_(0),
asking_(false)
{
redis_parser_init(parser_);
}
inline RedisMessage::~RedisMessage()
{
if (parser_)
{
redis_parser_deinit(parser_);
delete parser_;
delete stream_;
}
}
inline bool RedisMessage::parse_success() const { return parser_->parse_succ; }
inline bool RedisMessage::is_asking() const { return asking_; }
@@ -345,4 +321,3 @@ inline void RedisResponse::get_result(RedisValue& value) const
}
#endif

View File

@@ -3,8 +3,13 @@ project(server)
set(SRC
WFServer.cc
WFMySQLServer.cc
)
add_library(${PROJECT_NAME} OBJECT ${SRC})
if (MYSQL STREQUAL "y")
set(SRC
${SRC}
WFMySQLServer.cc
)
endif ()
add_library(${PROJECT_NAME} OBJECT ${SRC})

View File

@@ -25,16 +25,13 @@ endif ()
set(TUTORIAL_LIST
tutorial-00-helloworld
tutorial-01-wget
tutorial-02-redis_cli
tutorial-03-wget_to_redis
tutorial-04-http_echo_server
tutorial-05-http_proxy
tutorial-06-parallel_wget
tutorial-09-http_file_server
tutorial-07-sort_task
tutorial-08-matrix_multiply
tutorial-09-http_file_server
tutorial-11-graph_task
tutorial-12-mysql_cli
)
if (APPLE)
@@ -50,6 +47,31 @@ foreach(src ${TUTORIAL_LIST})
target_link_libraries(${bin_name} ${WORKFLOW_LIB})
endforeach()
if (REDIS STREQUAL "y")
set(TUTORIAL_LIST
tutorial-02-redis_cli
tutorial-03-wget_to_redis
)
foreach(src ${TUTORIAL_LIST})
string(REPLACE "-" ";" arr ${src})
list(GET arr -1 bin_name)
add_executable(${bin_name} ${src}.cc)
target_link_libraries(${bin_name} ${WORKFLOW_LIB})
endforeach()
endif()
if (MYSQL STREQUAL "y")
set(TUTORIAL_LIST
tutorial-12-mysql_cli
)
foreach(src ${TUTORIAL_LIST})
string(REPLACE "-" ";" arr ${src})
list(GET arr -1 bin_name)
add_executable(${bin_name} ${src}.cc)
target_link_libraries(${bin_name} ${WORKFLOW_LIB})
endforeach()
endif()
if (KAFKA STREQUAL "y")
add_executable("kafka_cli" "tutorial-13-kafka_cli.cc")
target_link_libraries("kafka_cli" wfkafka workflow z snappy lz4 zstd rt)

View File

@@ -6,21 +6,20 @@ DEFAULT_BUILD_DIR := build
BUILD_DIR := $(shell if [ -f $(MAKE_FILE) ]; then echo "."; else echo $(DEFAULT_BUILD_DIR); fi)
CMAKE3 := $(shell if which cmake3>/dev/null ; then echo cmake3; else echo cmake; fi;)
KAFKA ?= n
MYSQL ?= y
REDIS ?= y
UPSTREAM ?= y
.PHONY: $(ALL_TARGETS)
all:
mkdir -p $(BUILD_DIR)
ifeq ($(KAFKA),y)
KAFKA=y
else
KAFKA=n
endif
ifeq ($(DEBUG),y)
cd $(BUILD_DIR) && $(CMAKE3) -D CMAKE_BUILD_TYPE=Debug -D KAFKA=$(KAFKA) $(ROOT_DIR)
cd $(BUILD_DIR) && $(CMAKE3) -D CMAKE_BUILD_TYPE=Debug -D KAFKA=$(KAFKA) -D MYSQL=$(MYSQL) -D REDIS=$(REDIS) -D UPSTREAM=$(UPSTREAM) $(ROOT_DIR)
else
cd $(BUILD_DIR) && $(CMAKE3) -D KAFKA=$(KAFKA) $(ROOT_DIR)
cd $(BUILD_DIR) && $(CMAKE3) -D KAFKA=$(KAFKA) -D MYSQL=$(MYSQL) -D REDIS=$(REDIS) -D UPSTREAM=$(UPSTREAM) $(ROOT_DIR)
endif
make -C $(BUILD_DIR) -f Makefile
@@ -31,4 +30,3 @@ else ifeq (build, $(wildcard build))
-make -C build clean
endif
rm -rf build