no message

master
caiyuzheng 2021-03-10 22:21:52 +08:00
parent 403f17a599
commit 7443d203fb
7 changed files with 67 additions and 57 deletions

24
.vscode/settings.json vendored
View File

@ -1,13 +1,13 @@
{ {
"files.associations": { "files.associations": {
"*.rh": "cpp" "*.rh": "cpp",
}, "iostream": "cpp"
"cmake.buildDirectory":"${workspaceFolder}/build", },
"cmake.mingwSearchDirs": [ "cmake.buildDirectory": "${workspaceFolder}/build",
"D:\\qt\\Tools\\mingw730_32", "cmake.mingwSearchDirs": [
"D:\\qt\\Tools\\mingw730_64" "H:\\Qt\\5.14.0\\mingw73_64",
], "H:\\Qt\\5.14.0\\mingw73_32"
"terminal.integrated.env.windows": { ],
}, "terminal.integrated.env.windows": {},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
} }

View File

@ -5,9 +5,10 @@ add_subdirectory(general)
find_package(libevent REQUIRED) find_package(libevent REQUIRED)
set(EVENT__HAVE_LIBEVENT 1) set(EVENT__HAVE_LIBEVENT 1)
message(STATUS "PATH: " $ENV{CMAKE_MODULE_PATH})
message(STATUS "libevent include: " ${libevent_INCLUDE_DIR}) message(STATUS "libevent include: " ${libevent_INCLUDE_DIRS})
message(STATUS "libevent lib: " ${libevent_LIBRARIES}) message(STATUS "libevent lib: " ${libevent_INCLUDE_DIR})
message(STATUS "libevent lib Dirs: " ${libevent_LIB_DIRS}) message(STATUS "libevent lib Dirs: " ${libevent_LIB_DIRS})
SET(SRC_SDK sdk_main.c )# SET(SRC_SDK sdk_main.c )#
@ -77,7 +78,7 @@ add_custom_command(TARGET generallib PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/general/src/math/eigen ${LIBRARY_OUTPUT_PATH}/inc/math/eigen) COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/general/src/math/eigen ${LIBRARY_OUTPUT_PATH}/inc/math/eigen)
message( "copy third library") message( "copy third library")
file(GLOB THIRD ${PROJECT_SOURCE_DIR}/general/third/include/*) file(GLOB THIRD ${PROJECT_SOURCE_DIR}/general/third/include/*)
file(COPY ${THIRD} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/third/ file(COPY ${THIRD} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/third/include/
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
message( "copy net ") message( "copy net ")

View File

@ -1,5 +1,6 @@
from conans import ConanFile, CMake, tools from conans import ConanFile, CMake, tools
from conans import tools from conans import tools
import shutil
class GenerallibConan(ConanFile): class GenerallibConan(ConanFile):
source_folder = "pkgsrc" source_folder = "pkgsrc"
@ -9,15 +10,17 @@ class GenerallibConan(ConanFile):
author = "caiyuzheng" author = "caiyuzheng"
url = "https://gitee.com/290198252/generallib" url = "https://gitee.com/290198252/generallib"
description = "a simple cpp basic library" description = "a simple cpp basic library"
exports_sources = "general*", "test*" generators = "cmake_find_package"
def source(self): def source(self):
tools.rmdir("pkgsrc") tools.rmdir("pkgsrc")
git = tools.Git(folder=self.source_folder + "/pkgsrc") git = tools.Git(folder=self.source_folder + "/pkgsrc", verify_ssl=False)
git.clone("https://gitee.com/290198252/generallib.git") git.clone("https://gitee.com/290198252/generallib.git")
def package(self): def package(self):
self.copy(pattern ="*.h", dst="include", src="general",keep_path=True) self.copy(pattern = "*.a",src ="pkgsrc\\obj\\",dst = "lib",keep_path=True)
self.copy(pattern ="*.hpp", dst="include", src="general",keep_path=True) shutil.copytree(self.build_folder + '\\pkgsrc\\obj\\inc', self.package_folder + "\\include\\generallib")
def build(self): def build(self):
cmake = CMake(self) cmake = CMake(self)
@ -31,8 +34,11 @@ class GenerallibConan(ConanFile):
print("cygwin build") print("cygwin build")
if tools.get_env("BUILD_ENV")=="msys": if tools.get_env("BUILD_ENV")=="msys":
print("msys build") print("msys build")
tools.run_in_windows_bash(self, subsystem="msys",cwd="pkgsrc",msys_mingw=True,bashcmd="cmake build -G\"MinGW Makefiles\" " + tools.unix_path(self.source_folder + "/pkgsrc")) tools.run_in_windows_bash(self, subsystem="msys", cwd="pkgsrc", bashcmd="cmake build -DCMAKE_MODULE_PATH=" + tools.unix_path(self.source_folder)
tools.run_in_windows_bash(self, subsystem="msys",cwd="pkgsrc",msys_mingw=True,bashcmd="cmake --build . ") + " -G\"MinGW Makefiles\" " + tools.unix_path(self.source_folder) + "//pkgsrc")
tools.run_in_windows_bash(
self, subsystem="msys", cwd="pkgsrc", bashcmd="cmake --build .")
def requirements(self): def requirements(self):
self.requires("libevent/2.1.2", private=True, override=False) self.requires("libevent/2.1.2")

View File

@ -1,9 +1,7 @@
cmake_minimum_required(VERSION 3.11) cmake_minimum_required(VERSION 3.11)
enable_language(CXX) enable_language(CXX)
project(General) project(General)
set(MINGW_PATH $ENV{MINGW_TOOLCHAIN})
message("path is " ${MINGW_PATH})
message( "libevent path " ${CONAN_LIBEVENT_ROOT})
message( "current compiler " ${CMAKE_CXX_COMPILER_ID}) message( "current compiler " ${CMAKE_CXX_COMPILER_ID})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
@ -25,6 +23,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
endif() endif()
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj) SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj)
message( "LIBRARY_OUTPUT_PATH " ${LIBRARY_OUTPUT_PATH})
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
INCLUDE_DIRECTORIES (./) INCLUDE_DIRECTORIES (./)
INCLUDE_DIRECTORIES (inc) INCLUDE_DIRECTORIES (inc)

View File

@ -3,7 +3,7 @@
// ======= // =======
// High Resolution Timer. // High Resolution Timer.
// This timer is able to measure the elapsed time with 1 micro-second accuracy // This timer is able to measure the elapsed time with 1 micro-second accuracy
// in both Windows, Linux and Unix system // in both Windows, Linux and Unix system
// //
// AUTHOR: Song Ho Ahn (song.ahn@gmail.com) // AUTHOR: Song Ho Ahn (song.ahn@gmail.com)
// CREATED: 2003-01-13 // CREATED: 2003-01-13
@ -15,41 +15,37 @@
#ifndef TIMER_H_DEF #ifndef TIMER_H_DEF
#define TIMER_H_DEF #define TIMER_H_DEF
#if defined(WIN32) || defined(_WIN32) // Windows system specific #if defined(WIN32) || defined(_WIN32) // Windows system specific
#include <windows.h> #include <windows.h>
#else // Unix based system specific #else // Unix based system specific
#include <sys/time.h> #include <sys/time.h>
#endif #endif
class Timer class Timer
{ {
public: public:
Timer(); // default constructor Timer(); // default constructor
~Timer(); // default destructor ~Timer(); // default destructor
void start(); // start timer
void stop(); // stop the timer
double getElapsedTime(); // get elapsed time in second
double getElapsedTimeInSec(); // get elapsed time in second (same as getElapsedTime)
double getElapsedTimeInMilliSec(); // get elapsed time in milli-second
double getElapsedTimeInMicroSec(); // get elapsed time in micro-second
void start(); // start timer
void stop(); // stop the timer
double getElapsedTime(); // get elapsed time in second
double getElapsedTimeInSec(); // get elapsed time in second (same as getElapsedTime)
double getElapsedTimeInMilliSec(); // get elapsed time in milli-second
double getElapsedTimeInMicroSec(); // get elapsed time in micro-second
protected: protected:
private: private:
double startTimeInMicroSec; // starting time in micro-second double startTimeInMicroSec; // starting time in micro-second
double endTimeInMicroSec; // ending time in micro-second double endTimeInMicroSec; // ending time in micro-second
int stopped; // stop flag int stopped; // stop flag
#if defined(WIN32) || defined(_WIN32) #if defined(WIN32) || defined(_WIN32)
LARGE_INTEGER frequency; // ticks per second LARGE_INTEGER frequency; // ticks per second
LARGE_INTEGER startCount; // LARGE_INTEGER startCount; //
LARGE_INTEGER endCount; // LARGE_INTEGER endCount; //
#else #else
timeval startCount; // timeval startCount; //
timeval endCount; // timeval endCount; //
#endif #endif
}; };

View File

@ -1,13 +1,18 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.11)
project(tcptest) project(tcptest)
message("cmake module " $ENV{CMAKE_MODULE_PATH})
message("project dir " ${PROJECT_SOURCE_DIR})
message("current dir " ${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc)
message("current dir" ../..) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc)
include_directories(../../../../general/obj/inc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../general/obj/inc/third/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake-build-debug/libgenerallib.a) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../build)
link_libraries(libGeneral.a) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../obj)
link_libraries(libgenerallib.a)
link_libraries(ws2_32) link_libraries(ws2_32)
link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../../third/lib/libevent.a) link_libraries(libevent.la)
link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../../third/lib/libevent_core.a) link_libraries(libevent_core.la)
add_executable(tcptest tcpclient_test.cpp) add_executable(tcptest tcpclient_test.cpp)
target_include_directories(tcptest SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../obj/inc/third/include())

View File

@ -1,5 +1,8 @@
#include "TcpClient.h" #include "TcpClient.h"
#include <iostream>
#include <atomic>
using namespace std;
int main(){ int main(){
TcpClientLibevent mTcp("127.0.0.1",8443, nullptr); TcpClientLibevent mTcp("127.0.0.1",8443, nullptr);
} }