diff --git a/bin/dsn.cmake b/bin/dsn.cmake index 562b91caab..a25f8b435d 100644 --- a/bin/dsn.cmake +++ b/bin/dsn.cmake @@ -1,12 +1,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/compiler_info.cmake) - # Always generate the compilation database file (compile_commands.json) for use # with various development tools, such as IWYU and Vim's YouCompleteMe plugin. # See http://clang.llvm.org/docs/JSONCompilationDatabase.html set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - # Set DSN_PROJECT_DIR to rdsn/ set(DSN_PROJECT_DIR ${CMAKE_CURRENT_LIST_DIR}) get_filename_component(DSN_PROJECT_DIR ${DSN_PROJECT_DIR} DIRECTORY) @@ -19,6 +17,18 @@ message(STATUS "DSN_THIRDPARTY_ROOT = ${DSN_THIRDPARTY_ROOT}") set(DSN_ROOT ${DSN_PROJECT_DIR}/DSN_ROOT) message(STATUS "DSN_ROOT = ${DSN_ROOT}") +option(BUILD_TEST "build unit test" ON) +message(STATUS "BUILD_TEST = ${BUILD_TEST}") + +option(ENABLE_GCOV "Enable gcov (for code coverage analysis)" OFF) +message(STATUS "ENABLE_GCOV = ${ENABLE_GCOV}") + +# Disable this option before running valgrind. +option(ENABLE_GPERF "Enable gperftools (for tcmalloc)" ON) +message(STATUS "ENABLE_GPERF = ${ENABLE_GPERF}") + +# ================================================================== # + # Install this target into ${CMAKE_INSTALL_PREFIX}/lib function(dsn_install_library) @@ -139,11 +149,9 @@ function(dsn_add_project) else() set(TEMP_LIBS dsn_runtime) endif() - set(MY_PROJ_LIBS ${MY_PROJ_LIBS} ${TEMP_LIBS} ${MY_BOOST_LIBS} -ltcmalloc ${DSN_SYSTEM_LIBS}) + set(MY_PROJ_LIBS ${MY_PROJ_LIBS} ${TEMP_LIBS} ${MY_BOOST_LIBS} ${DSN_SYSTEM_LIBS}) endif() - list(APPEND MY_PROJ_LIBS thrift) - 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}") endfunction(dsn_add_project) @@ -169,8 +177,6 @@ function(dsn_add_object) dsn_add_project() endfunction(dsn_add_object) -option(BUILD_TEST "build unit test" ON) -option(ENABLE_GCOV "Enable gcov (for code coverage analysis)" OFF) function(dsn_add_test) if(${BUILD_TEST}) set(MY_EXECUTABLE_IS_TEST TRUE) @@ -290,8 +296,13 @@ function(dsn_setup_system_libs) endif() set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} ${DSN_LIB_CRYPTO}) + if(ENABLE_GPERF) + set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} tcmalloc) + endif() + set(DSN_SYSTEM_LIBS ${DSN_SYSTEM_LIBS} + thrift ${CMAKE_THREAD_LIBS_INIT} # the thread library found by FindThreads CACHE STRING "rDSN system libs" FORCE ) diff --git a/run.sh b/run.sh index 8909c0222c..13f86f9f44 100755 --- a/run.sh +++ b/run.sh @@ -21,20 +21,10 @@ function usage() echo " start_zk start the local single zookeeper server" echo " stop_zk stop the local single zookeeper server" echo " clear_zk stop the local single zookeeper server and clear the data" - echo " format check the code format" - echo " publish publish the program" - echo " publish_docker" - echo " publish the program docker image" - echo " republish republish the program without changes to machinelist and config.ini files" - echo " republish_docker" - echo " republish the program docker image without changes to machinelist and config.ini files" echo " deploy deploy the program to remote machine" echo " start start program at remote machine" echo " stop stop program at remote machine" echo " clean clean deployed program at remote machine" - echo " k8s_deploy deploy onto kubernetes cluster" - echo " k8s_undeploy" - echo " undeploy from kubernetes cluster" echo echo "Command 'run.sh -h' will print help for subcommands." } @@ -61,6 +51,8 @@ function usage_build() echo " --enable_gcov generate gcov code coverage report, default no" echo " -v|--verbose build in verbose mode, default no" echo " --notest build without building unit tests, default no" + echo " --disable_gperf build without gperftools, this flag is mainly used" + echo " to enable valgrind memcheck, default no" if [ "$ONLY_BUILD" == "NO" ]; then echo " -m|--test_module specify modules to test, split by ','," echo " e.g., \"dsn.core.tests,dsn.tests\"," @@ -119,12 +111,19 @@ function run_build() --enable_gcov) ENABLE_GCOV=YES BUILD_TYPE="debug" + shift ;; -v|--verbose) RUN_VERBOSE=YES + shift ;; --notest) NO_TEST=YES + shift + ;; + --disable_gperf) + DISABLE_GPERF=YES + shift ;; -m|--test_module) if [ "$ONLY_BUILD" == "YES" ]; then @@ -176,7 +175,8 @@ function run_build() C_COMPILER="$C_COMPILER" CXX_COMPILER="$CXX_COMPILER" BUILD_TYPE="$BUILD_TYPE" \ ONLY_BUILD="$ONLY_BUILD" CLEAR="$CLEAR" JOB_NUM="$JOB_NUM" \ BOOST_DIR="$BOOST_DIR" ENABLE_GCOV="$ENABLE_GCOV" \ - RUN_VERBOSE="$RUN_VERBOSE" TEST_MODULE="$TEST_MODULE" NO_TEST="$NO_TEST" $scripts_dir/build.sh + RUN_VERBOSE="$RUN_VERBOSE" TEST_MODULE="$TEST_MODULE" NO_TEST="$NO_TEST" \ + DISABLE_GPERF="$DISABLE_GPERF" $scripts_dir/build.sh } ##################### @@ -321,35 +321,6 @@ function run_clear_zk() DOWNLOADED_DIR="$DOWNLOADED_DIR" $scripts_dir/clear_zk.sh } -##################### -## format -##################### -function usage_format() -{ - echo "Options for subcommand 'format':" - echo " -h|--help print the help info" -} -function run_format() -{ - while [[ $# > 0 ]]; do - key="$1" - case $key in - -h|--help) - usage_format - exit 0 - ;; - *) - echo "ERROR: unknown option \"$key\"" - echo - usage_format - exit 1 - ;; - esac - shift - done - $scripts_dir/format.sh -} - #################################################################### if [ $# -eq 0 ]; then @@ -380,15 +351,8 @@ case $cmd in clear_zk) shift run_clear_zk $* ;; - format) - shift - run_format $* ;; - publish|publish_docker|republish|republish_docker) - $scripts_dir/publish.sh $* ;; deploy|start|stop|clean) $scripts_dir/deploy.sh $* ;; - k8s_deploy|k8s_undeploy) - $scripts_dir/k8s_deploy.sh $* ;; *) echo "ERROR: unknown command $cmd" echo diff --git a/scripts/linux/build.sh b/scripts/linux/build.sh index b4e194048a..0e4f0c846d 100755 --- a/scripts/linux/build.sh +++ b/scripts/linux/build.sh @@ -79,6 +79,15 @@ else echo "NO_TEST=NO" fi +# valgrind can not work together with gpertools +# you may want to use this option when you want to run valgrind +if [ "$DISABLE_GPERF" == "YES" ] + echo "DISABLE_GPERF=YES" + CMAKE_OPTIONS="$CMAKE_OPTIONS -DENABLE_GPERF=Off" +then + echo "DISABLE_GPERF=NO" +fi + # You can specify customized boost by defining BOOST_DIR. # Install boost like this: # wget http://downloads.sourceforge.net/project/boost/boost/1.54.0/boost_1_54_0.zip?r=&ts=1442891144&use_mirror=jaist diff --git a/scripts/linux/format.sh b/scripts/linux/format.sh deleted file mode 100755 index b2f7598dae..0000000000 --- a/scripts/linux/format.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# This script is to check format of the project, including: -# - not use 'TAB' in codes, instead using spaces. - -find . -name '*.h' \ - -o -name '*.cpp' \ - -o -name '*.proto' \ - -o -name '*.thrift' \ - -o -name '*.annotations' \ - -o -name '*.ini' \ - -o -name '*.sh' \ - -o -name '*.php' \ - -o -name '*.act' \ - | grep -v '^\./\.' \ - | grep -v '^\./builder' \ - | grep -v '^\./scripts/.*/format.sh' \ - | xargs grep -n ' \|<::' - -if [ $? -eq 0 ]; then - echo "ERROR: check format failed: should not contain tab character or '<::'" - exit 1 -else - echo "Check format succeed" - exit 0 -fi -