forked from sogou/workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
161 changed files
with
34,068 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
# all files | ||
[*] | ||
indent_style = tab | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
cmake_minimum_required(VERSION 3.6) | ||
|
||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "build type") | ||
set(CMAKE_INSTALL_PREFIX /opt/sogou CACHE PATH "install prefix") | ||
set(CMAKE_SKIP_RPATH TRUE) | ||
|
||
project(workflow | ||
VERSION 1.12.6 | ||
LANGUAGES C CXX | ||
) | ||
|
||
if (CYGWIN) | ||
message(FATAL_ERROR "Sorry, DO NOT support Cygwin") | ||
endif () | ||
|
||
if (MINGW) | ||
message(FATAL_ERROR "Sorry, DO NOT support MinGW") | ||
endif () | ||
|
||
include(GNUInstallDirs) | ||
|
||
set(CMAKE_CONFIG_INSTALL_FILE ${PROJECT_BINARY_DIR}/config.toinstall.cmake) | ||
set(CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) | ||
set(INC_DIR ${PROJECT_SOURCE_DIR}/_include CACHE PATH "workflow inc") | ||
set(LIB_DIR ${PROJECT_SOURCE_DIR}/_lib CACHE PATH "workflow lib") | ||
|
||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_DIR}) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_DIR}) | ||
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIB_DIR}) | ||
|
||
add_custom_target( | ||
LINK_HEADERS ALL | ||
COMMENT "link headers..." | ||
) | ||
|
||
INCLUDE(CMakeLists_Headers.txt) | ||
|
||
macro(makeLink src dest target) | ||
add_custom_command( | ||
TARGET ${target} PRE_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${src} ${dest} | ||
DEPENDS ${dest} | ||
) | ||
endmacro() | ||
|
||
add_custom_command( | ||
TARGET LINK_HEADERS PRE_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${INC_DIR}/${PROJECT_NAME} | ||
) | ||
|
||
foreach(header_file ${INCLUDE_HEADERS} ${INCLUDE_KERNEL_HEADERS}) | ||
#file(COPY ${PROJECT_SOURCE_DIR}/${header_file} DESTINATION ${INC_DIR}/${PROJECT_NAME}) | ||
string(REPLACE "/" ";" arr ${header_file}) | ||
list(GET arr -1 file_name) | ||
makeLink(${PROJECT_SOURCE_DIR}/${header_file} ${INC_DIR}/${PROJECT_NAME}/${file_name} LINK_HEADERS) | ||
endforeach() | ||
|
||
message("CMAKE_C_FLAGS_DEBUG is ${CMAKE_C_FLAGS_DEBUG}") | ||
message("CMAKE_C_FLAGS_RELEASE is ${CMAKE_C_FLAGS_RELEASE}") | ||
message("CMAKE_C_FLAGS_RELWITHDEBINFO is ${CMAKE_C_FLAGS_RELWITHDEBINFO}") | ||
message("CMAKE_C_FLAGS_MINSIZEREL is ${CMAKE_C_FLAGS_MINSIZEREL}") | ||
|
||
message("CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}") | ||
message("CMAKE_CXX_FLAGS_RELEASE is ${CMAKE_CXX_FLAGS_RELEASE}") | ||
message("CMAKE_CXX_FLAGS_RELWITHDEBINFO is ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") | ||
message("CMAKE_CXX_FLAGS_MINSIZEREL is ${CMAKE_CXX_FLAGS_MINSIZEREL}") | ||
|
||
if (WIN32) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /wd4200") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4200 /std:c++14") | ||
else () | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC -pipe -std=gnu90") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -pipe -std=c++11 -fno-exceptions") | ||
endif () | ||
|
||
add_subdirectory(src) | ||
|
||
####CONFIG | ||
|
||
include(CMakePackageConfigHelpers) | ||
set(CONFIG_INC_DIR ${INC_DIR}) | ||
set(CONFIG_LIB_DIR ${LIB_DIR}) | ||
configure_package_config_file( | ||
${PROJECT_NAME}-config.cmake.in | ||
${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-config.cmake | ||
INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR} | ||
PATH_VARS CONFIG_INC_DIR CONFIG_LIB_DIR | ||
) | ||
|
||
set(CONFIG_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR}) | ||
set(CONFIG_LIB_DIR ${CMAKE_INSTALL_LIBDIR}) | ||
configure_package_config_file( | ||
${PROJECT_NAME}-config.cmake.in | ||
${CMAKE_CONFIG_INSTALL_FILE} | ||
INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR} | ||
PATH_VARS CONFIG_INC_DIR CONFIG_LIB_DIR | ||
) | ||
|
||
install( | ||
FILES ${CMAKE_CONFIG_INSTALL_FILE} | ||
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR} | ||
COMPONENT devel | ||
RENAME ${PROJECT_NAME}-config.cmake | ||
) | ||
|
||
#### PACK | ||
|
||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sogou C++ Workflow") | ||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) | ||
|
||
# set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/pre_script.sh) | ||
# set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/post_script.sh) | ||
|
||
execute_process( | ||
COMMAND git log -n1 --format=%ad --date=short | ||
RESULT_VARIABLE GIT_LOG_RET | ||
OUTPUT_VARIABLE GIT_YMD | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
if (NOT GIT_LOG_RET EQUAL 0) | ||
set(GIT_YMD 0) | ||
endif() | ||
|
||
string(REPLACE "-" "" RELEASE_LABEL ${GIT_YMD}) | ||
set(CPACK_RPM_PACKAGE_RELEASE ${RELEASE_LABEL}) | ||
|
||
set(CPACK_RPM_COMPONENT_INSTALL ON) | ||
set(CPACK_COMPONENTS_ALL devel) | ||
set(CPACK_RPM_FILE_NAME RPM-DEFAULT) | ||
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) | ||
|
||
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/lib64/cmake) | ||
|
||
set(CPACK_RPM_DEVEL_PACKAGE_REQUIRES "openssl-devel >= 1.0.1") | ||
|
||
install( | ||
FILES ${INCLUDE_HEADERS} ${INCLUDE_KERNEL_HEADERS} | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
COMPONENT devel | ||
) | ||
|
||
install( | ||
FILES README.md | ||
DESTINATION "${CMAKE_INSTALL_DOCDIR}-${PROJECT_VERSION}" | ||
COMPONENT devel | ||
) | ||
|
||
set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true") # disable strip | ||
set(CPACK_GENERATOR "RPM") | ||
|
||
include(CPack) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
cmake_minimum_required(VERSION 3.6) | ||
|
||
set(COMMOM_KERNEL_HEADERS | ||
src/kernel/CommRequest.h | ||
src/kernel/CommScheduler.h | ||
src/kernel/Communicator.h | ||
src/kernel/SleepRequest.h | ||
src/kernel/ExecRequest.h | ||
src/kernel/IORequest.h | ||
src/kernel/Executor.h | ||
src/kernel/list.h | ||
src/kernel/mpoller.h | ||
src/kernel/poller.h | ||
src/kernel/rbtree.h | ||
src/kernel/SubTask.h | ||
src/kernel/thrdpool.h | ||
) | ||
|
||
if (WIN32) | ||
set(INCLUDE_KERNEL_HEADERS | ||
src/kernel_win/list.h | ||
) | ||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
set(INCLUDE_KERNEL_HEADERS | ||
${COMMOM_KERNEL_HEADERS} | ||
src/kernel/IOService_linux.h | ||
) | ||
elseif (UNIX) | ||
set(INCLUDE_KERNEL_HEADERS | ||
${COMMOM_KERNEL_HEADERS} | ||
src/kernel/IOService_thread.h | ||
) | ||
else () | ||
message(FATAL_ERROR "IOService unsupported.") | ||
endif () | ||
|
||
set(INCLUDE_HEADERS | ||
src/algorithm/DNSRoutine.h | ||
src/algorithm/MapReduce.h | ||
src/algorithm/MapReduce.inl | ||
src/protocol/ProtocolMessage.h | ||
src/protocol/http_parser.h | ||
src/protocol/HttpMessage.h | ||
src/protocol/HttpUtil.h | ||
src/protocol/redis_parser.h | ||
src/protocol/RedisMessage.h | ||
src/protocol/mysql_stream.h | ||
src/protocol/MySQLMessage.h | ||
src/protocol/MySQLMessage.inl | ||
src/protocol/MySQLResult.h | ||
src/protocol/MySQLResult.inl | ||
src/protocol/mysql_parser.h | ||
src/protocol/mysql_types.h | ||
src/protocol/mysql_byteorder.h | ||
src/server/WFServer.h | ||
src/server/WFHttpServer.h | ||
src/server/WFRedisServer.h | ||
src/server/WFMySQLServer.h | ||
src/client/WFMySQLConnection.h | ||
src/manager/DNSCache.h | ||
src/manager/WFGlobal.h | ||
src/manager/UpstreamManager.h | ||
src/manager/RouteManager.h | ||
src/manager/EndpointParams.h | ||
src/manager/WFFuture.h | ||
src/manager/WFFacilities.h | ||
src/manager/WFFacilities.inl | ||
src/util/EncodeStream.h | ||
src/util/LRUCache.h | ||
src/util/Mutex.h | ||
src/util/StringUtil.h | ||
src/util/URIParser.h | ||
src/util/MD5Util.h | ||
src/factory/WFConnection.h | ||
src/factory/WFTask.h | ||
src/factory/WFTask.inl | ||
src/factory/WFTaskError.h | ||
src/factory/WFTaskFactory.h | ||
src/factory/WFTaskFactory.inl | ||
src/factory/WFAlgoTaskFactory.h | ||
src/factory/WFAlgoTaskFactory.inl | ||
src/factory/Workflow.h | ||
src/factory/WFOperator.h | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
ALL_TARGETS := all base check install preinstall package rpm clean tutorial example | ||
MAKE_FILE := Makefile | ||
|
||
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;) | ||
|
||
.PHONY: $(ALL_TARGETS) | ||
|
||
all: base | ||
make -C $(BUILD_DIR) -f Makefile | ||
|
||
base: | ||
mkdir -p $(BUILD_DIR) | ||
ifeq ($(DEBUG),y) | ||
cd $(BUILD_DIR) && $(CMAKE3) -D CMAKE_BUILD_TYPE=Debug $(ROOT_DIR) | ||
else | ||
cd $(BUILD_DIR) && $(CMAKE3) $(ROOT_DIR) | ||
endif | ||
|
||
tutorial: all | ||
make -C tutorial | ||
|
||
example: all | ||
make -C example | ||
|
||
check: all | ||
make -C test check | ||
|
||
install preinstall package: base | ||
mkdir -p $(BUILD_DIR) | ||
cd $(BUILD_DIR) && $(CMAKE3) $(ROOT_DIR) | ||
make -C $(BUILD_DIR) -f Makefile $@ | ||
|
||
rpm: package | ||
ifneq ($(BUILD_DIR),.) | ||
mv $(BUILD_DIR)/*.rpm ./ | ||
endif | ||
|
||
clean: | ||
ifeq (build, $(wildcard build)) | ||
-make -C build clean | ||
endif | ||
-make -C test clean | ||
-make -C tutorial clean | ||
-make -C example clean | ||
rm -rf $(DEFAULT_BUILD_DIR) | ||
rm -rf _include | ||
rm -rf _lib | ||
rm -f SRCINFO SRCNUMVER SRCVERSION | ||
rm -f ./*.rpm | ||
find . -name CMakeCache.txt | xargs rm -f | ||
find . -name Makefile | xargs rm -f | ||
find . -name "*.cmake" | xargs rm -f | ||
find . -name CMakeFiles | xargs rm -rf | ||
|
Oops, something went wrong.