From 3c798828a9f043ed824b8cf5983df5dccd250f06 Mon Sep 17 00:00:00 2001 From: xuwei06 Date: Fri, 4 Aug 2017 13:21:33 -0700 Subject: [PATCH] SKip cpplint if source is not changed. --- cmake/cpplint.cmake | 5 ++++- cmake/util.cmake | 1 - paddle/gserver/tests/CMakeLists.txt | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmake/cpplint.cmake b/cmake/cpplint.cmake index 656e1a0803c..e50530411cc 100644 --- a/cmake/cpplint.cmake +++ b/cmake/cpplint.cmake @@ -56,11 +56,14 @@ macro(add_style_check_target TARGET_NAME) # cpplint code style get_filename_component(base_filename ${filename} NAME) set(CUR_GEN ${CMAKE_CURRENT_BINARY_DIR}/${base_filename}.cpplint) - add_custom_command(TARGET ${TARGET_NAME} PRE_BUILD + add_custom_command(OUTPUT ${CUR_GEN} PRE_BUILD COMMAND "${PYTHON_EXECUTABLE}" "${PROJ_ROOT}/paddle/scripts/cpplint.py" "--filter=${STYLE_FILTER}" "--write-success=${CUR_GEN}" ${filename} + DEPENDS ${filename} ${PROJ_ROOT}/paddle/scripts/cpplint.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_custom_target(${base_filename}.cpplint DEPENDS ${CUR_GEN}) + add_dependencies(${TARGET_NAME} ${base_filename}.cpplint) endif() endforeach() endif() diff --git a/cmake/util.cmake b/cmake/util.cmake index 87ad9d91d87..a9b9d4a9fa0 100644 --- a/cmake/util.cmake +++ b/cmake/util.cmake @@ -118,7 +118,6 @@ endfunction() macro(add_unittest_without_exec TARGET_NAME) add_executable(${TARGET_NAME} ${ARGN}) link_paddle_test(${TARGET_NAME}) - add_style_check_target(${TARGET_NAME} ${ARGN}) endmacro() # add_unittest diff --git a/paddle/gserver/tests/CMakeLists.txt b/paddle/gserver/tests/CMakeLists.txt index a43adc7ce7d..4546d12a903 100644 --- a/paddle/gserver/tests/CMakeLists.txt +++ b/paddle/gserver/tests/CMakeLists.txt @@ -1,5 +1,10 @@ # gserver pacakge unittests +file(GLOB_RECURSE GSERVER_HEADER RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.h") +file(GLOB_RECURSE GSERVER_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cpp") +add_style_check_target(paddle_gserver ${GSERVER_SOURCES}) +add_style_check_target(paddle_gserver ${GSERVER_HEADER}) + ################### test_ProtoDataProvider ############ add_unittest_without_exec(test_ProtoDataProvider test_ProtoDataProvider.cpp) @@ -50,7 +55,7 @@ add_unittest_without_exec(test_DetectionOutput test_DetectionOutput.cpp LayerGradUtil.cpp) -add_test(NAME test_DetectionOutput +add_test(NAME test_DetectionOutput COMMAND test_DetectionOutput) ################# test_ConvUnify ####################### add_unittest_without_exec(test_ConvUnify -- GitLab