Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TUBEMQ-274]Support CMake compilation #197

Merged
merged 2 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target/
!.gitignore
!.gitkeep
!.travis.yml
tubemq-client-twins/tubemq-client-cpp/build/
50 changes: 50 additions & 0 deletions tubemq-client-twins/tubemq-client-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#


cmake_minimum_required (VERSION 3.1)

project (TubeMQ)


INCLUDE_DIRECTORIES(include)

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/third_party/rapidjson/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/third_party/log4cplus/include)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/third_party/log4cplus/include)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/third_party/log4cplus/lib)

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(third_party)
ADD_SUBDIRECTORY(example)


if (UNIX)
SET(CMAKE_CXX_FLAGS_DEBUG "-O1 -g -ggdb -D_DEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -ggdb -DNDEBUG")
SET(DEPENDENT_LIBRARIES log4cplus pthread)
else (UNIX)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it repeated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cmake syntax is like this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I get it, thanks!

SET(DEPENDENT_LIBRARIES log4cplus)
endif (UNIX)






31 changes: 31 additions & 0 deletions tubemq-client-twins/tubemq-client-cpp/build_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#


#!/bin/bash

cd ../../
git submodule foreach --recursive git submodule init
git submodule foreach --recursive git submodule update
cd -

mkdir build
cd build
cmake ../
make
32 changes: 32 additions & 0 deletions tubemq-client-twins/tubemq-client-cpp/example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#


# A function to set up a test, since it's the same for each one. Note:
# unit_tests test is not set up using this function because it does not like
# the additional argument on commmand line and consequently does not run any
# test.
function(tubemq_add_example _name)
set(_srcs ${ARGN})
message (STATUS "${_name} sources: ${_srcs}")
add_executable (${_name} ${_srcs})
TARGET_LINK_LIBRARIES (${_name} tubemq log4cplus pthread)
endfunction()

add_subdirectory (log)
21 changes: 21 additions & 0 deletions tubemq-client-twins/tubemq-client-cpp/example/log/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#


tubemq_add_example(log main.cc)
2 changes: 1 addition & 1 deletion tubemq-client-twins/tubemq-client-cpp/example/log/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <string>
#include <thread>

#include "logger.h"
#include "tubemq/logger.h"

using namespace std;
using namespace tubemq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ class Logger {

static const char* Level2String(Level level) {
static const char* level_names[] = {
"TRACE",
"DEBUG"
"INFO",
"WARN",
"ERROR",
"TRACE", "DEBUG", "INFO", "WARN", "ERROR",
};
return level_names[level];
}
Expand Down
32 changes: 32 additions & 0 deletions tubemq-client-twins/tubemq-client-cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#


cmake_minimum_required (VERSION 3.1)


set(CMAKE_C_FLAGS "-O2 -g -Wall -Werror -Wsign-compare -fno-strict-aliasing -fPIC")
set(CMAKE_CXX_FLAGS "-std=c++11 -O2 -g -Wall -Werror -Wsign-compare -fno-strict-aliasing -fPIC")

AUX_SOURCE_DIRECTORY(. CURRENT_DIR_SRCS)
ADD_LIBRARY(tubemq STATIC ${CURRENT_DIR_SRCS})
TARGET_LINK_LIBRARIES (tubemq)



9 changes: 4 additions & 5 deletions tubemq-client-twins/tubemq-client-cpp/src/client_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@

namespace tubemq {

using std::stringstream;
using std::set;
using std::stringstream;
using std::vector;


BaseConfig::BaseConfig() {
this->master_addrinfo_ = "";
this->auth_enable_ = false;
Expand Down Expand Up @@ -335,8 +334,8 @@ bool ConsumerConfig::setGroupConsumeTarget(
string tmp_filteritem;
set<string> tgt_filters;
// check topic_name info
is_success =
Utils::ValidString(err_info, it_map->first, false, true, true, tb_config::kTopicNameMaxLength);
is_success = Utils::ValidString(err_info, it_map->first, false, true, true,
tb_config::kTopicNameMaxLength);
if (!is_success) {
stringstream ss;
ss << "Check parameter subscribed_topic_and_filter_map error: topic ";
Expand Down Expand Up @@ -503,7 +502,7 @@ void ConsumerConfig::SetWaitPeriodIfConfirmWaitRebalanceMs(int reb_confirm_wait_
this->reb_confirm_wait_period_ms_ = reb_confirm_wait_period_ms;
}

const int ConsumerConfig::GetMaxConfirmWaitPeriodMs() const { this->max_confirm_wait_period_ms_; }
const int ConsumerConfig::GetMaxConfirmWaitPeriodMs() const { return max_confirm_wait_period_ms_; }

void ConsumerConfig::SetMaxConfirmWaitPeriodMs(int max_confirm_wait_period_ms) {
this->max_confirm_wait_period_ms_ = max_confirm_wait_period_ms;
Expand Down
16 changes: 8 additions & 8 deletions tubemq-client-twins/tubemq-client-cpp/src/flowctrl_def.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,13 @@ FlowCtrlRuleHandler::~FlowCtrlRuleHandler() { pthread_rwlock_destroy(&configrw_l

void FlowCtrlRuleHandler::UpdateDefFlowCtrlInfo(bool is_default, int32_t qrypriority_id,
int64_t flowctrl_id, const string& flowctrl_info) {
bool result;
map<int32_t, vector<FlowCtrlItem> > tmp_flowctrl_map;
if (flowctrl_id == this->flowctrl_id_.Get()) {
return;
}
int64_t curr_flowctrl_id = this->flowctrl_id_.Get();
if (flowctrl_info.length() > 0) {
result = parseFlowCtrlInfo(flowctrl_info, tmp_flowctrl_map);
parseFlowCtrlInfo(flowctrl_info, tmp_flowctrl_map);
}
pthread_rwlock_wrlock(&this->configrw_lock_);
this->flowctrl_id_.Set(flowctrl_id);
Expand Down Expand Up @@ -266,7 +265,8 @@ void FlowCtrlRuleHandler::clearStatisData() {
this->filter_ctrl_item_.Clear();
}

bool FlowCtrlRuleHandler::GetCurDataLimit(int64_t last_datadlt, FlowCtrlResult& flowctrl_result) const {
bool FlowCtrlRuleHandler::GetCurDataLimit(int64_t last_datadlt,
FlowCtrlResult& flowctrl_result) const {
struct tm utc_tm;
vector<FlowCtrlItem>::const_iterator it_vec;
map<int, vector<FlowCtrlItem> >::const_iterator it_map;
Expand All @@ -291,7 +291,8 @@ bool FlowCtrlRuleHandler::GetCurDataLimit(int64_t last_datadlt, FlowCtrlResult&
return false;
}

int32_t FlowCtrlRuleHandler::GetCurFreqLimitTime(int32_t msg_zero_cnt, int32_t received_limit) const {
int32_t FlowCtrlRuleHandler::GetCurFreqLimitTime(int32_t msg_zero_cnt,
int32_t received_limit) const {
int32_t rule_val = -2;
vector<FlowCtrlItem>::const_iterator it_vec;
map<int, vector<FlowCtrlItem> >::const_iterator it_map;
Expand Down Expand Up @@ -402,7 +403,6 @@ bool FlowCtrlRuleHandler::parseDataLimit(string& err_info, const rapidjson::Valu
int32_t type_val;
stringstream ss;
string attr_sep = delimiter::kDelimiterColon;
string::size_type pos1;
if (!parseIntMember(err_info, root, "type", type_val, true, 0)) {
ss << "Decode Failure: ";
ss << err_info;
Expand Down Expand Up @@ -573,13 +573,13 @@ bool FlowCtrlRuleHandler::parseLowFetchLimit(string& err_info, const rapidjson::
return false;
}
// parse rule info
const rapidjson::Value& node_item = root["rule"];
for (uint32_t i = 0; i < node_item.Size(); i++) {
const rapidjson::Value& nodes = root["rule"];
for (uint32_t i = 0; i < nodes.Size(); ++i) {
int32_t norm_freq_ms = 0;
int32_t filter_freq_ms = 0;
int32_t min_filter_freq_ms = 0;
FlowCtrlItem flowctrl_item;
const rapidjson::Value& node_item = node_item[i];
const rapidjson::Value& node_item = nodes[i];
if (!node_item.IsObject()) {
err_info = "Illegal rule'value item, must be dict type";
return false;
Expand Down
25 changes: 25 additions & 0 deletions tubemq-client-twins/tubemq-client-cpp/third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#


CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
PROJECT(TubeMQThirdParty)

ADD_SUBDIRECTORY(log4cplus)

Submodule log4cplus updated 98 files
+10 −9 .travis.yml
+3 −3 CMakeLists.txt
+147 −3 ChangeLog
+0 −1 ConfigureChecks.cmake
+0 −36 Makefile.am
+1 −1 Makefile.am.def
+1 −5 Makefile.am.tpl
+451 −425 Makefile.in
+16 −44 README.md
+1 −1 acinclude.m4
+0 −1 aclocal.m4
+36 −16 appveyor.yml
+1 −1 catch
+142 −1,876 configure
+6 −21 configure.ac
+6 −6 cygport/log4cplus.cygport
+2 −2 docs/doxygen.config
+7 −6 docs/latex-header.tex
+10 −9 docs/release.txt
+2 −2 docs/webpage_doxygen.config
+6 −7 include/Makefile.in
+13 −0 include/log4cplus/asyncappender.h
+0 −3 include/log4cplus/config/defines.hxx.in
+3 −3 include/log4cplus/helpers/stringhelper.h
+7 −8 include/log4cplus/hierarchy.h
+73 −20 include/log4cplus/internal/customloglevelmanager.h
+8 −8 include/log4cplus/logger.h
+2 −2 include/log4cplus/loggingmacros.h
+43 −34 include/log4cplus/loglevel.h
+2 −2 include/log4cplus/spi/loggerfactory.h
+3 −3 include/log4cplus/spi/loggerimpl.h
+21 −23 include/log4cplus/spi/loggingevent.h
+6 −6 include/log4cplus/thread/syncprims-pub-impl.h
+1 −1 include/log4cplus/thread/syncprims.h
+2 −28 include/log4cplus/tstring.h
+2 −2 include/log4cplus/version.h
+1 −1 log4cplus.spec
+0 −948 m4/ax_cxx_compile_stdcxx.m4
+142 −0 m4/ax_cxx_compile_stdcxx_11.m4
+0 −35 m4/ax_cxx_compile_stdcxx_17.m4
+2 −2 mingw-log4cplus.spec
+14 −16 scripts/build-pdf.pl
+0 −7 scripts/propagate-version.pl
+9 −6 src/appender.cxx
+6 −3 src/appenderattachableimpl.cxx
+3 −3 src/asyncappender.cxx
+2 −1 src/callbackappender.cxx
+9 −6 src/clfsappender.cxx
+17 −86 src/clogger.cxx
+17 −10 src/configurator.cxx
+6 −4 src/connectorthread.cxx
+4 −3 src/env.cxx
+21 −11 src/factory.cxx
+13 −48 src/fileappender.cxx
+2 −2 src/fileinfo.cxx
+13 −8 src/filter.cxx
+16 −6 src/global-init.cxx
+13 −8 src/hierarchy.cxx
+3 −2 src/hierarchylocker.cxx
+10 −5 src/layout.cxx
+2 −2 src/lockfile.cxx
+4 −4 src/log4judpappender.cxx
+13 −12 src/logger.cxx
+8 −6 src/loggerimpl.cxx
+32 −41 src/loggingevent.cxx
+3 −3 src/loggingmacros.cxx
+54 −109 src/loglevel.cxx
+4 −3 src/loglog.cxx
+5 −3 src/mdc.cxx
+12 −8 src/msttsappender.cxx
+8 −3 src/ndc.cxx
+3 −1 src/nullappender.cxx
+5 −4 src/objectregistry.cxx
+49 −29 src/patternlayout.cxx
+4 −4 src/pointer.cxx
+8 −6 src/property.cxx
+6 −4 src/queue.cxx
+2 −2 src/rootlogger.cxx
+3 −3 src/snprintf.cxx
+7 −39 src/socket-unix.cxx
+4 −3 src/socket.cxx
+3 −3 src/socketbuffer.cxx
+14 −27 src/stringhelper-clocale.cxx
+14 −27 src/stringhelper-cxxlocale.cxx
+6 −24 src/stringhelper-iconv.cxx
+14 −22 src/stringhelper.cxx
+8 −2 src/syncprims.cxx
+5 −6 src/threads.cxx
+2 −2 src/timehelper.cxx
+2 −2 src/tls.cxx
+1 −1 src/version.cxx
+1 −1 tests/customloglevel_test/CMakeLists.txt
+1 −0 tests/customloglevel_test/Makefile.am
+35 −0 tests/customloglevel_test/customloglevel.cxx
+11 −12 tests/customloglevel_test/customloglevel.h
+11 −7 tests/customloglevel_test/func.cxx
+1 −5 tests/customloglevel_test/main.cxx
+1 −1 threadpool