From 3d7b5967429bc933bff0606cc241b1a67d80e096 Mon Sep 17 00:00:00 2001 From: neverchanje Date: Mon, 10 Sep 2018 13:13:16 +0800 Subject: [PATCH 1/3] service_api: remove useless code --- include/dsn/c/api_layer1.h | 26 ------- src/core/core/disk_engine.cpp | 30 +------- src/core/core/disk_engine.h | 14 +--- src/core/core/service_api_c.cpp | 125 ++------------------------------ 4 files changed, 11 insertions(+), 184 deletions(-) diff --git a/include/dsn/c/api_layer1.h b/include/dsn/c/api_layer1.h index f4970594e6..e41779adf1 100644 --- a/include/dsn/c/api_layer1.h +++ b/include/dsn/c/api_layer1.h @@ -24,16 +24,6 @@ * THE SOFTWARE. */ -/* - * Description: - * Service API in rDSN - * - * Revision history: - * Mar., 2015, @imzhenyu (Zhenyu Guo), first version - * Feb., 2016, @imzhenyu (Zhenyu Guo), add comments for V1 release - * xxxx-xx-xx, author, fix bug about xxx - */ - #pragma once #include @@ -267,11 +257,6 @@ extern DSN_API dsn::message_ex *dsn_rpc_call_wait(dsn::rpc_address server, /*! one-way RPC from client, no rpc response is expected */ extern DSN_API void dsn_rpc_call_one_way(dsn::rpc_address server, dsn::message_ex *request); -/*! this is to mimic a response is received when no real rpc is called */ -extern DSN_API void dsn_rpc_enqueue_response(dsn::rpc_response_task *rpc_call, - dsn::error_code err, - dsn::message_ex *response); - /*@}*/ /*@}*/ @@ -291,14 +276,6 @@ typedef struct int size; } dsn_file_buffer_t; -/*! the following ctrl code are used by \ref dsn_file_ctrl. */ -typedef enum dsn_ctrl_code_t { - CTL_BATCH_INVALID = 0, - CTL_BATCH_WRITE = 1, ///< (batch) set write batch size - CTL_MAX_CON_READ_OP_COUNT = 2, ///< (throttling) maximum concurrent read ops - CTL_MAX_CON_WRITE_OP_COUNT = 3, ///< (throttling) maximum concurrent write ops -} dsn_ctrl_code_t; - /*! open file @@ -316,9 +293,6 @@ extern DSN_API dsn::error_code dsn_file_close(dsn_handle_t file); /*! flush the buffer of the given file */ extern DSN_API dsn::error_code dsn_file_flush(dsn_handle_t file); -/*! get native handle: HANDLE for windows, int for non-windows */ -extern DSN_API void *dsn_file_native_handle(dsn_handle_t file); - /*! read file asynchronously diff --git a/src/core/core/disk_engine.cpp b/src/core/core/disk_engine.cpp index a92d2d1f27..43e922e415 100644 --- a/src/core/core/disk_engine.cpp +++ b/src/core/core/disk_engine.cpp @@ -24,20 +24,7 @@ * THE SOFTWARE. */ -/* - * Description: - * What is this file about? - * - * Revision history: - * xxxx-xx-xx, author, first version - * xxxx-xx-xx, author, fix bug about xxx - */ - #include "disk_engine.h" -#include -#include -#include -#include using namespace dsn::utils; @@ -89,12 +76,6 @@ aio_task *disk_write_queue::unlink_next_workload(void *plength) disk_file::disk_file(dsn_handle_t handle) : _handle(handle) {} -void disk_file::ctrl(dsn_ctrl_code_t code, int param) -{ - // TODO: - dassert(false, "NOT IMPLEMENTED"); -} - aio_task *disk_file::read(aio_task *tsk) { tsk->add_ref(); // release on completion @@ -170,15 +151,6 @@ void disk_engine::start(aio_provider *provider) _is_running = true; } -void disk_engine::ctrl(dsn_handle_t fh, dsn_ctrl_code_t code, int param) -{ - if (nullptr == fh) - return; - - auto df = (disk_file *)fh; - df->ctrl(code, param); -} - dsn_handle_t disk_engine::open(const char *file_name, int flag, int pmode) { dsn_handle_t nh = _provider->open(file_name, flag, pmode); @@ -365,4 +337,4 @@ void disk_engine::complete_io(aio_task *aio, error_code err, uint32_t bytes, int } } -} // end namespace +} // namespace dsn diff --git a/src/core/core/disk_engine.h b/src/core/core/disk_engine.h index 76be4d2e74..b21874233f 100644 --- a/src/core/core/disk_engine.h +++ b/src/core/core/disk_engine.h @@ -24,18 +24,10 @@ * THE SOFTWARE. */ -/* - * Description: - * What is this file about? - * - * Revision history: - * xxxx-xx-xx, author, first version - * xxxx-xx-xx, author, fix bug about xxx - */ - #pragma once #include "service_engine.h" + #include #include #include @@ -61,7 +53,6 @@ class disk_file { public: disk_file(dsn_handle_t handle); - void ctrl(dsn_ctrl_code_t code, int param); aio_task *read(aio_task *tsk); aio_task *write(aio_task *tsk, void *ctx); @@ -91,7 +82,6 @@ class disk_engine void read(aio_task *aio); void write(aio_task *aio); - void ctrl(dsn_handle_t fh, dsn_ctrl_code_t code, int param); disk_aio *prepare_aio_context(aio_task *tsk) { return _provider->prepare_aio_context(tsk); } service_node *node() const { return _node; } @@ -107,4 +97,4 @@ class disk_engine service_node *_node; }; -} // end namespace +} // namespace dsn diff --git a/src/core/core/service_api_c.cpp b/src/core/core/service_api_c.cpp index 215777d0e6..430ba1d717 100644 --- a/src/core/core/service_api_c.cpp +++ b/src/core/core/service_api_c.cpp @@ -24,45 +24,18 @@ * THE SOFTWARE. */ -/* - * Description: - * What is this file about? - * - * Revision history: - * xxxx-xx-xx, author, first version - * xxxx-xx-xx, author, fix bug about xxx - */ - #include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include - -#include #include -#include #include +#include + #include "service_engine.h" #include "rpc_engine.h" #include "disk_engine.h" #include "task_engine.h" #include "coredump.h" -#include - -#ifndef _WIN32 -#include -#include -#else -#include -#endif // // global state @@ -328,17 +301,6 @@ DSN_API void dsn_rpc_forward(dsn::message_ex *request, dsn::rpc_address addr) ::dsn::rpc_address(addr)); } -DSN_API void dsn_rpc_enqueue_response(dsn::rpc_response_task *rpc_call, - dsn::error_code err, - dsn::message_ex *response) -{ - dassert(rpc_call->spec().type == TASK_TYPE_RPC_RESPONSE, - "invalid task_type, type = %s", - enum_to_string(rpc_call->spec().type)); - auto resp = ((::dsn::message_ex *)response); - rpc_call->enqueue(err, resp); -} - //------------------------------------------------------------------------------ // // file operations @@ -360,13 +322,6 @@ DSN_API dsn::error_code dsn_file_flush(dsn_handle_t file) return ::dsn::task::get_current_disk()->flush(file); } -// native HANDLE: HANDLE for windows, int for non-windows -DSN_API void *dsn_file_native_handle(dsn_handle_t file) -{ - auto dfile = (::dsn::disk_file *)file; - return dfile->native_handle(); -} - DSN_API void dsn_file_read(dsn_handle_t file, char *buffer, int count, uint64_t offset, dsn::aio_task *cb) { @@ -451,74 +406,13 @@ DSN_API bool dsn_run_config(const char *config, bool sleep_after_init) return run(config, nullptr, sleep_after_init, name); } -#ifdef _WIN32 -static BOOL SuspendAllThreads() -{ - std::map threads; - uint32_t dwCurrentThreadId = ::GetCurrentThreadId(); - uint32_t dwCurrentProcessId = ::GetCurrentProcessId(); - HANDLE hSnapshot; - bool bChange = TRUE; - - while (bChange) { - hSnapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); - if (hSnapshot == INVALID_HANDLE_VALUE) { - derror("CreateToolhelp32Snapshot failed, err = %d", ::GetLastError()); - return FALSE; - } - - THREADENTRY32 ti; - ZeroMemory(&ti, sizeof(ti)); - ti.dwSize = sizeof(ti); - bChange = FALSE; - - if (FALSE == ::Thread32First(hSnapshot, &ti)) { - derror("Thread32First failed, err = %d", ::GetLastError()); - goto err; - } - - do { - if (ti.th32OwnerProcessID == dwCurrentProcessId && - ti.th32ThreadID != dwCurrentThreadId && - threads.find(ti.th32ThreadID) == threads.end()) { - HANDLE hThread = ::OpenThread(THREAD_ALL_ACCESS, FALSE, ti.th32ThreadID); - if (hThread == NULL) { - derror("OpenThread failed, err = %d", ::GetLastError()); - goto err; - } - ::SuspendThread(hThread); - ddebug("thread %d find and suspended ...", ti.th32ThreadID); - threads.insert(std::make_pair(ti.th32ThreadID, hThread)); - bChange = TRUE; - } - } while (::Thread32Next(hSnapshot, &ti)); - - ::CloseHandle(hSnapshot); - } - - return TRUE; - -err: - ::CloseHandle(hSnapshot); - return FALSE; -} -#endif - NORETURN DSN_API void dsn_exit(int code) { printf("dsn exit with code %d\n", code); fflush(stdout); ::dsn::tools::sys_exit.execute(::dsn::SYS_EXIT_NORMAL); -#if defined(_WIN32) - // TODO: do not use std::map above, coz when suspend the other threads, they may stop - // inside certain locks which causes deadlock - // SuspendAllThreads(); - ::TerminateProcess(::GetCurrentProcess(), code); -#else _exit(code); -// kill(getpid(), SIGKILL); -#endif } DSN_API bool dsn_mimic_app(const char *app_role, int index) @@ -611,11 +505,13 @@ DSN_API void dsn_run(int argc, char **argv, bool sleep_after_init) namespace dsn { namespace tools { + bool is_engine_ready() { return dsn_all.is_engine_ready(); } tool_app *get_current_tool() { return dsn_all.tool; } -} -} + +} // namespace tools +} // namespace dsn extern void dsn_log_init(); extern void dsn_core_init(); @@ -653,11 +549,7 @@ bool run(const char *config_file, "pause_on_start", false, "whether to pause at startup time for easier debugging")) { -#if defined(_WIN32) - printf("\nPause for debugging (pid = %d)...\n", static_cast(::GetCurrentProcessId())); -#else printf("\nPause for debugging (pid = %d)...\n", static_cast(getpid())); -#endif getchar(); } @@ -724,12 +616,10 @@ bool run(const char *config_file, // init logging dsn_log_init(); -#ifndef _WIN32 ddebug("init rdsn runtime, pid = %d, dsn_runtime_init_time_ms = %" PRIu64 " (%s)", (int)getpid(), dsn_runtime_init_time_ms(), init_time_buf); -#endif // init toollets for (auto it = spec.toollets.begin(); it != spec.toollets.end(); ++it) { @@ -859,4 +749,5 @@ void service_app::get_all_service_apps(std::vector *apps) apps->push_back(const_cast(node->get_service_app())); } } -} + +} // namespace dsn From b88f903fdeb747a3340b65387e51a949a720f30f Mon Sep 17 00:00:00 2001 From: neverchanje Date: Mon, 10 Sep 2018 17:02:39 +0800 Subject: [PATCH 2/3] build-scripts: no longer specify language (PROJ_LANG) in dsn.cmake. --- bin/dsn.cmake | 166 +++++++----------- .../test/meta_test/unit_test/CMakeLists.txt | 2 +- 2 files changed, 63 insertions(+), 105 deletions(-) diff --git a/bin/dsn.cmake b/bin/dsn.cmake index 248f020841..7823fce185 100644 --- a/bin/dsn.cmake +++ b/bin/dsn.cmake @@ -5,9 +5,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/compiler_info.cmake) # See http://clang.llvm.org/docs/JSONCompilationDatabase.html set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) -function(ms_add_project PROJ_LANG PROJ_TYPE PROJ_NAME PROJ_SRC PROJ_INC_PATH PROJ_LIBS PROJ_LIB_PATH PROJ_BINPLACES PROJ_BINDIRS DO_INSTALL) +function(ms_add_project PROJ_TYPE PROJ_NAME PROJ_SRC PROJ_INC_PATH PROJ_LIBS PROJ_LIB_PATH PROJ_BINPLACES PROJ_BINDIRS DO_INSTALL) if(DEFINED DSN_DEBUG_CMAKE) - message(STATUS "PROJ_LANG = ${PROJ_LANG}") message(STATUS "PROJ_TYPE = ${PROJ_TYPE}") message(STATUS "PROJ_NAME = ${PROJ_NAME}") message(STATUS "PROJ_SRC = ${PROJ_SRC}") @@ -18,10 +17,6 @@ function(ms_add_project PROJ_LANG PROJ_TYPE PROJ_NAME PROJ_SRC PROJ_INC_PATH PRO message(STATUS "DO_INSTALL = ${DO_INSTALL}") endif() - if(PROJ_LANG STREQUAL "") - message(FATAL_ERROR "Invalid project language.") - endif() - if(NOT((PROJ_TYPE STREQUAL "STATIC") OR (PROJ_TYPE STREQUAL "SHARED") OR (PROJ_TYPE STREQUAL "EXECUTABLE") OR (PROJ_TYPE STREQUAL "OBJECT"))) #"MODULE" is not used yet @@ -60,43 +55,38 @@ function(ms_add_project PROJ_LANG PROJ_TYPE PROJ_NAME PROJ_SRC PROJ_INC_PATH PRO message(STATUS "OUTPUT_DIRECTORY = ${OUTPUT_DIRECTORY}") endif() - if(PROJ_LANG STREQUAL "CXX") - if(NOT (PROJ_INC_PATH STREQUAL "")) - include_directories(${PROJ_INC_PATH}) - endif() - if(NOT (PROJ_LIB_PATH STREQUAL "")) - link_directories(${PROJ_LIB_PATH}) - endif() + if(NOT (PROJ_INC_PATH STREQUAL "")) + include_directories(${PROJ_INC_PATH}) + endif() + if(NOT (PROJ_LIB_PATH STREQUAL "")) + link_directories(${PROJ_LIB_PATH}) + endif() - if((PROJ_TYPE STREQUAL "STATIC") OR (PROJ_TYPE STREQUAL "OBJECT")) - if(MSVC) - add_definitions(-D_LIB) - endif() - add_library(${PROJ_NAME} ${PROJ_TYPE} ${PROJ_SRC}) - elseif(PROJ_TYPE STREQUAL "SHARED") - add_library(${PROJ_NAME} ${PROJ_TYPE} ${PROJ_SRC}) - elseif(PROJ_TYPE STREQUAL "EXECUTABLE") - if(MSVC) - add_definitions(-D_CONSOLE) - endif() - add_executable(${PROJ_NAME} ${PROJ_SRC}) + if((PROJ_TYPE STREQUAL "STATIC") OR (PROJ_TYPE STREQUAL "OBJECT")) + if(MSVC) + add_definitions(-D_LIB) endif() - - if((PROJ_TYPE STREQUAL "SHARED") OR (PROJ_TYPE STREQUAL "EXECUTABLE")) - if(PROJ_TYPE STREQUAL "SHARED") - set(LINK_MODE PRIVATE) - else() - set(LINK_MODE PUBLIC) - endif() - target_link_libraries(${PROJ_NAME} "${LINK_MODE}" ${PROJ_LIBS}) + add_library(${PROJ_NAME} ${PROJ_TYPE} ${PROJ_SRC}) + elseif(PROJ_TYPE STREQUAL "SHARED") + add_library(${PROJ_NAME} ${PROJ_TYPE} ${PROJ_SRC}) + elseif(PROJ_TYPE STREQUAL "EXECUTABLE") + if(MSVC) + add_definitions(-D_CONSOLE) endif() + add_executable(${PROJ_NAME} ${PROJ_SRC}) + endif() - if(DO_INSTALL) - install(TARGETS ${PROJ_NAME} DESTINATION "${INSTALL_DIR}") - #if (WIN32) - # install(FILES "${PROJ_NAME}.pdb" DESTINATION "${INSTALL_DIR}") - #endif() + if((PROJ_TYPE STREQUAL "SHARED") OR (PROJ_TYPE STREQUAL "EXECUTABLE")) + if(PROJ_TYPE STREQUAL "SHARED") + set(LINK_MODE PRIVATE) + else() + set(LINK_MODE PUBLIC) endif() + target_link_libraries(${PROJ_NAME} "${LINK_MODE}" ${PROJ_LIBS}) + endif() + + if(DO_INSTALL) + install(TARGETS ${PROJ_NAME} DESTINATION "${INSTALL_DIR}") endif() if((PROJ_TYPE STREQUAL "EXECUTABLE") AND (NOT (PROJ_BINPLACES STREQUAL ""))) @@ -198,28 +188,16 @@ function(ms_check_cxx11_support) endif() endfunction(ms_check_cxx11_support) -macro(ms_find_source_files LANG SOURCE_DIR GLOB_OPTION PROJ_SRC) +macro(ms_find_source_files SOURCE_DIR GLOB_OPTION PROJ_SRC) set(TEMP_PROJ_SRC "") - if(${LANG} STREQUAL "CXX") - file(${GLOB_OPTION} - TEMP_PROJ_SRC - "${SOURCE_DIR}/*.cpp" - "${SOURCE_DIR}/*.cc" - "${SOURCE_DIR}/*.c" - "${SOURCE_DIR}/*.h" - "${SOURCE_DIR}/*.hpp" - ) - elseif(${LANG} STREQUAL "CS") - file(${GLOB_OPTION} - TEMP_PROJ_SRC - "${SOURCE_DIR}/*.cs" - ) - elseif(${LANG} STREQUAL "JAVA") - file(${GLOB_OPTION} - TEMP_PROJ_SRC - "${SOURCE_DIR}/*.java" - ) - endif() + file(${GLOB_OPTION} + TEMP_PROJ_SRC + "${SOURCE_DIR}/*.cpp" + "${SOURCE_DIR}/*.cc" + "${SOURCE_DIR}/*.c" + "${SOURCE_DIR}/*.h" + "${SOURCE_DIR}/*.hpp" + ) if(DEFINED DSN_DEBUG_CMAKE) message(STATUS "LANG = ${LANG}") @@ -241,32 +219,18 @@ macro(dsn_setup_serialization) set(USE_PROTOBUF TRUE) endif () endforeach() - if (MY_PROJ_LANG STREQUAL "CXX") - if (USE_THRIFT) - if (WIN32) - list(APPEND MY_PROJ_LIBS thriftmt) - else () - list(APPEND MY_PROJ_LIBS thrift) - endif () - add_definitions(-DDSN_USE_THRIFT_SERIALIZATION) - add_definitions(-DDSN_ENABLE_THRIFT_RPC) - endif () - if (USE_PROTOBUF) - if (WIN32) - list(APPEND MY_PROJ_LIBS libprotobuf) - else () - list(APPEND MY_PROJ_LIBS protobuf.a) - endif () - add_definitions(-DDSN_USE_PROTOBUF_SERIALIZATION) - endif () + if (USE_THRIFT) + list(APPEND MY_PROJ_LIBS thrift) + add_definitions(-DDSN_USE_THRIFT_SERIALIZATION) + add_definitions(-DDSN_ENABLE_THRIFT_RPC) + endif () + if (USE_PROTOBUF) + list(APPEND MY_PROJ_LIBS protobuf.a) + add_definitions(-DDSN_USE_PROTOBUF_SERIALIZATION) endif () - #TODO : CSHARP endmacro(dsn_setup_serialization) function(dsn_add_project) - if((NOT DEFINED MY_PROJ_LANG) OR (MY_PROJ_LANG STREQUAL "")) - message(FATAL_ERROR "MY_PROJ_LANG is empty.") - endif() if((NOT DEFINED MY_PROJ_TYPE) OR (MY_PROJ_TYPE STREQUAL "")) message(FATAL_ERROR "MY_PROJ_TYPE is empty.") endif() @@ -280,7 +244,7 @@ function(dsn_add_project) set(MY_PROJ_SRC "") endif() set(TEMP_SRC "") - ms_find_source_files("${MY_PROJ_LANG}" "${CMAKE_CURRENT_SOURCE_DIR}" ${MY_SRC_SEARCH_MODE} TEMP_SRC) + ms_find_source_files("${CMAKE_CURRENT_SOURCE_DIR}" ${MY_SRC_SEARCH_MODE} TEMP_SRC) set(MY_PROJ_SRC ${TEMP_SRC} ${MY_PROJ_SRC}) if(NOT DEFINED MY_PROJ_INC_PATH) set(MY_PROJ_INC_PATH "") @@ -313,24 +277,22 @@ function(dsn_add_project) set(MY_SERIALIZATION_TYPE "") endif() - if(MY_PROJ_LANG STREQUAL "CXX") - set(MY_BOOST_LIBS "") - if(NOT (MY_BOOST_PACKAGES STREQUAL "")) - ms_setup_boost(TRUE "${MY_BOOST_PACKAGES}" MY_BOOST_LIBS) - endif() + set(MY_BOOST_LIBS "") + if(NOT (MY_BOOST_PACKAGES STREQUAL "")) + ms_setup_boost(TRUE "${MY_BOOST_PACKAGES}" MY_BOOST_LIBS) + endif() - if((MY_PROJ_TYPE STREQUAL "SHARED") OR (MY_PROJ_TYPE STREQUAL "EXECUTABLE")) - if(DSN_BUILD_RUNTIME AND(DEFINED DSN_IN_CORE) AND DSN_IN_CORE) - set(TEMP_LIBS "") - else() - set(TEMP_LIBS dsn_runtime) - endif() - set(MY_PROJ_LIBS ${MY_PROJ_LIBS} ${TEMP_LIBS} ${MY_BOOST_LIBS} -ltcmalloc) - if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - set(MY_PROJ_LIBS ${MY_PROJ_LIBS} ${DSN_SYSTEM_LIBS}) - else() - set(MY_PROJ_LIBS ${DSN_SYSTEM_LIBS} ${MY_PROJ_LIBS}) - endif() + if((MY_PROJ_TYPE STREQUAL "SHARED") OR (MY_PROJ_TYPE STREQUAL "EXECUTABLE")) + if(DSN_BUILD_RUNTIME AND(DEFINED DSN_IN_CORE) AND DSN_IN_CORE) + set(TEMP_LIBS "") + else() + set(TEMP_LIBS dsn_runtime) + endif() + set(MY_PROJ_LIBS ${MY_PROJ_LIBS} ${TEMP_LIBS} ${MY_BOOST_LIBS} -ltcmalloc) + if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(MY_PROJ_LIBS ${MY_PROJ_LIBS} ${DSN_SYSTEM_LIBS}) + else() + set(MY_PROJ_LIBS ${DSN_SYSTEM_LIBS} ${MY_PROJ_LIBS}) endif() endif() @@ -351,29 +313,25 @@ function(dsn_add_project) message(STATUS "MY_BOOST_PACKAGES = ${MY_BOOST_PACKAGES}") message(STATUS "MY_BOOST_LIBS = ${MY_BOOST_LIBS}") endif() - ms_add_project("${MY_PROJ_LANG}" "${MY_PROJ_TYPE}" "${MY_PROJ_NAME}" "${MY_PROJ_SRC}" "${MY_PROJ_INC_PATH}" "${MY_PROJ_LIBS}" "${MY_PROJ_LIB_PATH}" "${MY_BINPLACES}" "${MY_PROJ_BINDIRS}" "${MY_DO_INSTALL}") + ms_add_project("${MY_PROJ_TYPE}" "${MY_PROJ_NAME}" "${MY_PROJ_SRC}" "${MY_PROJ_INC_PATH}" "${MY_PROJ_LIBS}" "${MY_PROJ_LIB_PATH}" "${MY_BINPLACES}" "${MY_PROJ_BINDIRS}" "${MY_DO_INSTALL}") endfunction(dsn_add_project) function(dsn_add_static_library) - set(MY_PROJ_LANG "CXX") set(MY_PROJ_TYPE "STATIC") dsn_add_project() endfunction(dsn_add_static_library) function(dsn_add_shared_library) - set(MY_PROJ_LANG "CXX") set(MY_PROJ_TYPE "SHARED") dsn_add_project() endfunction(dsn_add_shared_library) function(dsn_add_executable) - set(MY_PROJ_LANG "CXX") set(MY_PROJ_TYPE "EXECUTABLE") dsn_add_project() endfunction(dsn_add_executable) function(dsn_add_object) - set(MY_PROJ_LANG "CXX") set(MY_PROJ_TYPE "OBJECT") dsn_add_project() endfunction(dsn_add_object) diff --git a/src/dist/replication/test/meta_test/unit_test/CMakeLists.txt b/src/dist/replication/test/meta_test/unit_test/CMakeLists.txt index 6b353dd8a7..9ab2c6ef1e 100644 --- a/src/dist/replication/test/meta_test/unit_test/CMakeLists.txt +++ b/src/dist/replication/test/meta_test/unit_test/CMakeLists.txt @@ -9,7 +9,7 @@ set(MY_PROJ_SRC ../misc/misc.cpp) # "GLOB" for non-recursive search set(MY_SRC_SEARCH_MODE "GLOB") -ms_find_source_files("CXX" "${CMAKE_CURRENT_SOURCE_DIR}/../../../meta_server" "GLOB" MY_PROJ_SRC) +ms_find_source_files("${CMAKE_CURRENT_SOURCE_DIR}/../../../meta_server" "GLOB" MY_PROJ_SRC) set(MY_PROJ_INC_PATH "") From 0288484a37926421e2e0e2796a9279d6b785bc37 Mon Sep 17 00:00:00 2001 From: neverchanje Date: Mon, 10 Sep 2018 22:43:56 +0800 Subject: [PATCH 3/3] scripts: remove windows specific codes in dsn.cmake --- CMakeLists.txt | 1 - bin/dsn.cg.bat | 4 - bin/dsn.cmake | 321 +++++++++++----------------------------------- compile_thrift.py | 9 +- 4 files changed, 79 insertions(+), 256 deletions(-) delete mode 100644 bin/dsn.cg.bat diff --git a/CMakeLists.txt b/CMakeLists.txt index d887e30cd8..595dc64557 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,5 @@ if(ENABLE_GCOV AND UNIX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov") endif() dsn_common_setup() -dsn_add_pseudo_projects() add_subdirectory(src) diff --git a/bin/dsn.cg.bat b/bin/dsn.cg.bat deleted file mode 100644 index bca8aa4e80..0000000000 --- a/bin/dsn.cg.bat +++ /dev/null @@ -1,4 +0,0 @@ -@ECHO OFF -SET CODEGEN_ROOT=%~dp0 -CALL %CODEGEN_ROOT%\Windows\php.exe -f %CODEGEN_ROOT%\dsn.generate_code.php %1 %2 %3 %4 %5 %6 %7 %8 %9 -:EOF diff --git a/bin/dsn.cmake b/bin/dsn.cmake index 7823fce185..8f9cc0891e 100644 --- a/bin/dsn.cmake +++ b/bin/dsn.cmake @@ -36,19 +36,13 @@ function(ms_add_project PROJ_TYPE PROJ_NAME PROJ_SRC PROJ_INC_PATH PROJ_LIBS PRO set(INSTALL_DIR "bin/${PROJ_NAME}") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJ_NAME}") set(OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") - if(NOT WIN32) - execute_process(COMMAND sh -c "echo ${PROJ_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/${INSTALL_DIR} ' ' >> ${CMAKE_SOURCE_DIR}/.matchfile") - endif() + execute_process(COMMAND sh -c "echo ${PROJ_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/${INSTALL_DIR} ' ' >> ${CMAKE_SOURCE_DIR}/.matchfile") elseif(PROJ_TYPE STREQUAL "STATIC") set(OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}") - if(NOT WIN32) - execute_process(COMMAND sh -c "echo ${PROJ_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ${OUTPUT_DIRECTORY} ' ' >> ${CMAKE_SOURCE_DIR}/.matchfile") - endif() + execute_process(COMMAND sh -c "echo ${PROJ_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ${OUTPUT_DIRECTORY} ' ' >> ${CMAKE_SOURCE_DIR}/.matchfile") elseif(PROJ_TYPE STREQUAL "SHARED") set(OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") - if(NOT WIN32) - execute_process(COMMAND sh -c "echo ${PROJ_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ${OUTPUT_DIRECTORY} ' ' >> ${CMAKE_SOURCE_DIR}/.matchfile") - endif() + execute_process(COMMAND sh -c "echo ${PROJ_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ${OUTPUT_DIRECTORY} ' ' >> ${CMAKE_SOURCE_DIR}/.matchfile") endif() if(DEFINED DSN_DEBUG_CMAKE) @@ -63,16 +57,10 @@ function(ms_add_project PROJ_TYPE PROJ_NAME PROJ_SRC PROJ_INC_PATH PROJ_LIBS PRO endif() if((PROJ_TYPE STREQUAL "STATIC") OR (PROJ_TYPE STREQUAL "OBJECT")) - if(MSVC) - add_definitions(-D_LIB) - endif() add_library(${PROJ_NAME} ${PROJ_TYPE} ${PROJ_SRC}) elseif(PROJ_TYPE STREQUAL "SHARED") add_library(${PROJ_NAME} ${PROJ_TYPE} ${PROJ_SRC}) elseif(PROJ_TYPE STREQUAL "EXECUTABLE") - if(MSVC) - add_definitions(-D_CONSOLE) - endif() add_executable(${PROJ_NAME} ${PROJ_SRC}) endif() @@ -118,76 +106,6 @@ function(ms_add_project PROJ_TYPE PROJ_NAME PROJ_SRC PROJ_INC_PATH PROJ_LIBS PRO endif() endfunction(ms_add_project) -macro(ms_add_compiler_flags LANGUAGES SUFFIXES FLAGS) - foreach(LANG ${LANGUAGES}) - foreach(SUFFIX ${SUFFIXES}) - if(SUFFIX STREQUAL "") - set(SUFFIX "") - else() - string(TOUPPER ${SUFFIX} SUFFIX) - set(SUFFIX "_${SUFFIX}") - endif() - set(FLAG_VAR "CMAKE_${LANG}_FLAGS${SUFFIX}") - set(${FLAG_VAR} "${${FLAG_VAR}} ${FLAGS}" PARENT_SCOPE) - message(STATUS ${FLAG_VAR} ":" ${${FLAG_VAR}}) - endforeach() - endforeach() -endmacro(ms_add_compiler_flags) - -macro(ms_link_static_runtime FLAG_VAR) - if(MSVC) - if(${FLAG_VAR} MATCHES "/MD") - string(REPLACE "/MD" "/MT" "${FLAG_VAR}" "${${FLAG_VAR}}") - #Save persistently - set(${FLAG_VAR} ${${FLAG_VAR}} CACHE STRING "" FORCE) - endif() - endif() -endmacro(ms_link_static_runtime) - -macro(ms_replace_compiler_flags REPLACE_OPTION) - set(SUFFIXES "") - if((NOT DEFINED CMAKE_CONFIGURATION_TYPES) OR (CMAKE_CONFIGURATION_TYPES STREQUAL "")) - #set(SUFFIXES "_DEBUG" "_RELEASE" "_MINSIZEREL" "_RELWITHDEBINFO") - if((DEFINED CMAKE_BUILD_TYPE) AND (NOT (CMAKE_BUILD_TYPE STREQUAL ""))) - string(TOUPPER ${CMAKE_BUILD_TYPE} SUFFIXES) - set(SUFFIXES "_${SUFFIXES}") - endif() - else() - foreach(SUFFIX ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${SUFFIX} SUFFIX) - set(SUFFIXES ${SUFFIXES} "_${SUFFIX}") - endforeach() - endif() - - foreach(SUFFIX "" ${SUFFIXES}) - foreach(LANG C CXX) - set(FLAG_VAR "CMAKE_${LANG}_FLAGS${SUFFIX}") - if(${REPLACE_OPTION} STREQUAL "STATIC_LINK") - ms_link_static_runtime(${FLAG_VAR}) - endif() - endforeach() - #message(STATUS ${FLAG_VAR} ":" ${${FLAG_VAR}}) - endforeach() -endmacro(ms_replace_compiler_flags) - -function(ms_check_cxx11_support) - if(UNIX) - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX11) - else() - if(MSVC_VERSION LESS 1700) - set(COMPILER_SUPPORTS_CXX11 0) - else() - set(COMPILER_SUPPORTS_CXX11 1) - endif() - endif() - - if(COMPILER_SUPPORTS_CXX11) - else() - message(FATAL_ERROR "You need a compiler with C++1y support.") - endif() -endfunction(ms_check_cxx11_support) - macro(ms_find_source_files SOURCE_DIR GLOB_OPTION PROJ_SRC) set(TEMP_PROJ_SRC "") file(${GLOB_OPTION} @@ -200,7 +118,6 @@ macro(ms_find_source_files SOURCE_DIR GLOB_OPTION PROJ_SRC) ) if(DEFINED DSN_DEBUG_CMAKE) - message(STATUS "LANG = ${LANG}") message(STATUS "SOURCE_DIR = ${SOURCE_DIR}") message(STATUS "GLOB_OPTION = ${GLOB_OPTION}") message(STATUS "PROJ_SRC = ${${PROJ_SRC}}") @@ -344,69 +261,49 @@ function(dsn_add_test) endfunction() function(dsn_setup_compiler_flags) - ms_replace_compiler_flags("STATIC_LINK") - - if(UNIX) - if(CMAKE_USE_PTHREADS_INIT) - add_compile_options(-pthread) - endif() - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - add_definitions(-D_DEBUG) - add_definitions(-DDSN_BUILD_TYPE=Debug) - else() - add_definitions(-g) - add_definitions(-O2) - add_definitions(-DDSN_BUILD_TYPE=Release) - endif() - cmake_host_system_information(RESULT BUILD_HOSTNAME QUERY HOSTNAME) - add_definitions(-DDSN_BUILD_HOSTNAME=${BUILD_HOSTNAME}) - add_definitions(-D__STDC_FORMAT_MACROS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y" CACHE STRING "" FORCE) - add_compile_options(-Wall) - add_compile_options(-Werror) - add_compile_options(-Wno-sign-compare) - add_compile_options(-Wno-strict-aliasing) - add_compile_options(-Wuninitialized) - add_compile_options(-Wno-unused-result) - add_compile_options(-Wno-unused-variable) - add_compile_options(-Wno-deprecated-declarations) - add_compile_options(-Wno-inconsistent-missing-override) - - find_program(CCACHE_FOUND ccache) - if(CCACHE_FOUND) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) - if ("${COMPILER_FAMILY}" STREQUAL "clang") - add_compile_options(-Qunused-arguments) - endif() - message("use ccache to speed up compilation") - endif(CCACHE_FOUND) - - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" - CACHE - STRING - "" - FORCE) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" - CACHE - STRING - "" - FORCE) - - elseif(MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-DWIN32_LEAN_AND_MEAN) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS=1) - add_definitions(-D_WIN32_WINNT=0x0600) - add_definitions(-D_UNICODE) - add_definitions(-DUNICODE) - add_compile_options(-MP) - if(DEFINED DSN_PEDANTIC) - add_compile_options(-WX) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-D_DEBUG) + add_definitions(-DDSN_BUILD_TYPE=Debug) + else() + add_definitions(-g) + add_definitions(-O2) + add_definitions(-DDSN_BUILD_TYPE=Release) + endif() + cmake_host_system_information(RESULT BUILD_HOSTNAME QUERY HOSTNAME) + add_definitions(-DDSN_BUILD_HOSTNAME=${BUILD_HOSTNAME}) + add_definitions(-D__STDC_FORMAT_MACROS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y" CACHE STRING "" FORCE) + add_compile_options(-Wall) + add_compile_options(-Werror) + add_compile_options(-Wno-sign-compare) + add_compile_options(-Wno-strict-aliasing) + add_compile_options(-Wuninitialized) + add_compile_options(-Wno-unused-result) + add_compile_options(-Wno-unused-variable) + add_compile_options(-Wno-deprecated-declarations) + add_compile_options(-Wno-inconsistent-missing-override) + + find_program(CCACHE_FOUND ccache) + if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + if ("${COMPILER_FAMILY}" STREQUAL "clang") + add_compile_options(-Qunused-arguments) endif() - endif() + message("use ccache to speed up compilation") + endif(CCACHE_FOUND) + + set(CMAKE_EXE_LINKER_FLAGS + "${CMAKE_EXE_LINKER_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" + CACHE + STRING + "" + FORCE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" + CACHE + STRING + "" + FORCE) endfunction(dsn_setup_compiler_flags) macro(ms_setup_boost STATIC_LINK PACKAGES BOOST_LIBS) @@ -414,14 +311,9 @@ macro(ms_setup_boost STATIC_LINK PACKAGES BOOST_LIBS) message(STATUS "BOOST_PACKAGES = ${PACKAGES}") endif() - set(Boost_USE_MULTITHREADED ON) - if(MSVC)#${STATIC_LINK}) - set(Boost_USE_STATIC_LIBS ON) - set(Boost_USE_STATIC_RUNTIME ON) - else() - set(Boost_USE_STATIC_LIBS OFF) - set(Boost_USE_STATIC_RUNTIME OFF) - endif() + set(Boost_USE_MULTITHREADED ON) + set(Boost_USE_STATIC_LIBS OFF) + set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost COMPONENTS ${PACKAGES} REQUIRED) @@ -437,57 +329,40 @@ macro(ms_setup_boost STATIC_LINK PACKAGES BOOST_LIBS) set(${BOOST_LIBS} ${TEMP_LIBS}) endmacro(ms_setup_boost) +# find necessary system libs function(dsn_setup_packages) - if(UNIX) - set(CMAKE_THREAD_PREFER_PTHREAD TRUE) - endif() find_package(Threads REQUIRED) set(DSN_SYSTEM_LIBS "") - if(UNIX AND (NOT APPLE)) - find_library(DSN_LIB_RT NAMES rt) - if(DSN_LIB_RT STREQUAL "DSN_LIB_RT-NOTFOUND") - message(FATAL_ERROR "Cannot find library rt") - endif() - set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_RT}) - endif() - - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - find_library(DSN_LIB_AIO NAMES aio) - if(DSN_LIB_AIO STREQUAL "DSN_LIB_AIO-NOTFOUND") - message(FATAL_ERROR "Cannot find library aio") - endif() - set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_AIO}) + find_library(DSN_LIB_RT NAMES rt) + if(DSN_LIB_RT STREQUAL "DSN_LIB_RT-NOTFOUND") + message(FATAL_ERROR "Cannot find library rt") endif() + set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_RT}) - if((CMAKE_SYSTEM_NAME STREQUAL "Linux")) - find_library(DSN_LIB_DL NAMES dl) - if(DSN_LIB_DL STREQUAL "DSN_LIB_DL-NOTFOUND") - message(FATAL_ERROR "Cannot find library dl") - endif() - set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_DL}) + find_library(DSN_LIB_AIO NAMES aio) + if(DSN_LIB_AIO STREQUAL "DSN_LIB_AIO-NOTFOUND") + message(FATAL_ERROR "Cannot find library aio") endif() + set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_AIO}) - if((CMAKE_SYSTEM_NAME STREQUAL "Linux")) - find_library(DSN_LIB_CRYPTO NAMES crypto) - if(DSN_LIB_CRYPTO STREQUAL "DSN_LIB_CRYPTO-NOTFOUND") - message(FATAL_ERROR "Cannot find library crypto") - endif() - set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_CRYPTO}) + find_library(DSN_LIB_DL NAMES dl) + if(DSN_LIB_DL STREQUAL "DSN_LIB_DL-NOTFOUND") + message(FATAL_ERROR "Cannot find library dl") endif() + set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_DL}) - if((CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")) - find_library(DSN_LIB_UTIL NAMES util) - if(DSN_LIB_UTIL STREQUAL "DSN_LIB_UTIL-NOTFOUND") - message(FATAL_ERROR "Cannot find library util") - endif() - set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_UTIL}) + # TODO(wutao1): maybe we do not need this? + find_library(DSN_LIB_CRYPTO NAMES crypto) + if(DSN_LIB_CRYPTO STREQUAL "DSN_LIB_CRYPTO-NOTFOUND") + message(FATAL_ERROR "Cannot find library crypto") endif() + set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_CRYPTO}) set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} - ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_THREAD_LIBS_INIT} # the thread library found by FindThreads CACHE STRING "rDSN system libs" FORCE ) endfunction(dsn_setup_packages) @@ -511,7 +386,6 @@ function(dsn_setup_include_path) else() include_directories(${DSN_ROOT}/include) include_directories(${DSN_ROOT}/include/dsn/cpp/serialization_helper) - include_directories(${DSN_ROOT}/include/ext) include_directories(${DSN_THIRDPARTY_ROOT}/include) endif() endfunction(dsn_setup_include_path) @@ -531,62 +405,15 @@ function(dsn_setup_install) install(DIRECTORY include/ DESTINATION include) install(DIRECTORY bin/ DESTINATION bin USE_SOURCE_PERMISSIONS) install(DIRECTORY ${PROJECT_BINARY_DIR}/lib/ DESTINATION lib) - #if(MSVC) - # install(FILES "bin/dsn.cg.bat" DESTINATION bin) - #else() - # install(PROGRAMS "bin/dsn.cg.sh" DESTINATION bin) - # install(PROGRAMS "bin/Linux/thrift" DESTINATION bin/Linux) - # install(PROGRAMS "bin/Linux/protoc" DESTINATION bin/Linux) - # install(PROGRAMS "bin/Darwin/thrift" DESTINATION bin/Darwin) - # install(PROGRAMS "bin/Darwin/protoc" DESTINATION bin/Darwin) - # install(PROGRAMS "bin/FreeBSD/thrift" DESTINATION bin/FreeBSD) - # install(PROGRAMS "bin/FreeBSD/protoc" DESTINATION bin/FreeBSD) - #endif() endif() endfunction(dsn_setup_install) -function(dsn_make_source_group_by_subdir GROUP_PREFIX SOURCE_LIST) - if(GROUP_PREFIX STREQUAL "") - # Assume that the source file path starts with ${CMAKE_CURRENT_SOURCE_DIR} - set(GROUP_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}") - endif() - string(REPLACE "/" "\\" GROUP_PREFIX "${GROUP_PREFIX}/") - string(LENGTH "${GROUP_PREFIX}" GROUP_PREFIX_LENGTH) - foreach(SRC_FILE IN LISTS SOURCE_LIST) - get_filename_component(SRC_PATH "${SRC_FILE}" PATH) - string(REPLACE "/" "\\" SRC_PATH "${SRC_PATH}") - string(FIND "${SRC_PATH}" "${GROUP_PREFIX}" IDX) - # IDX != 0 means that either the source file is not in ${CMAKE_CURRENT_SOURCE_DIR} - # , or it is in the root of ${CMAKE_CURRENT_SOURCE_DIR}. - set(GROUP_NAME "") - if(IDX EQUAL 0) - #math(EXPR IDX "${IDX} + ${prefix_len}") - string(SUBSTRING "${SRC_PATH}" "${GROUP_PREFIX_LENGTH}" -1 GROUP_NAME) - endif() - source_group("${GROUP_NAME}" FILES "${SRC_FILE}") - endforeach() -endfunction(dsn_make_source_group_by_subdir) - -function(dsn_add_pseudo_projects) - if(DSN_BUILD_RUNTIME AND MSVC_IDE) - file(GLOB_RECURSE - PROJ_SRC - "${CMAKE_SOURCE_DIR}/include/dsn/*.h" - "${CMAKE_SOURCE_DIR}/include/dsn/*.hpp" - ) - dsn_make_source_group_by_subdir("${CMAKE_SOURCE_DIR}/include/dsn" "${PROJ_SRC}") - add_custom_target("dsn.include" SOURCES ${PROJ_SRC}) - endif() -endfunction(dsn_add_pseudo_projects) - function(dsn_common_setup) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(notdir $(abspath $<))\"'") - if(NOT WIN32) - execute_process(COMMAND sh -c "rm -rf ${CMAKE_SOURCE_DIR}/.matchfile") - endif() + execute_process(COMMAND sh -c "rm -rf ${CMAKE_SOURCE_DIR}/.matchfile") - if(NOT (UNIX OR WIN32)) - message(FATAL_ERROR "Only Unix and Windows are supported.") + if(NOT (UNIX)) + message(FATAL_ERROR "Only Unix are supported.") endif() if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) @@ -605,7 +432,13 @@ function(dsn_common_setup) endif() set(BUILD_SHARED_LIBS OFF) - ms_check_cxx11_support() + + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y) + if(NOT ${COMPILER_SUPPORTS_CXX11}) + message(FATAL_ERROR "You need a compiler with C++1y support.") + endif() + dsn_setup_packages() dsn_setup_compiler_flags() dsn_setup_include_path() diff --git a/compile_thrift.py b/compile_thrift.py index bee2327031..7a1b09e377 100755 --- a/compile_thrift.py +++ b/compile_thrift.py @@ -134,13 +134,8 @@ def __str__(self): return self.msg def init_env(): - if platform.system() == "Windows": - env_tools["dsn_gentool"] = os.getcwd() + "/bin/dsn.cg.bat" - env_tools["thrift_exe"] = os.getcwd() + "/bin/Windows/thrift.exe" - else: - env_tools["dsn_gentool"] = os.getcwd() + "/bin/dsn.cg.sh" - env_tools["thrift_exe"] = os.getcwd() + "/bin/Linux/thrift" - env_tools["root_dir"] = os.getcwd() + env_tools["dsn_gentool"] = os.getcwd() + "/bin/dsn.cg.sh" + env_tools["thrift_exe"] = os.getcwd() + "/bin/Linux/thrift" def find_struct_define(line, enum_class_list): if len(line)<7 or line[0:7] != "struct ":