Skip to content

Commit

Permalink
[travis] Check code style -- currently checking 0 files
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Nov 4, 2016
2 parents 3219455 + 6c42f64 commit e5e61bd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
36 changes: 23 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,19 +425,29 @@ if (CLANG_FORMAT_EXECUTABLE)
message(STATUS "Looking for clang-format - found")
endif()

add_custom_target(format
COMMAND ${CMAKE_COMMAND} -E echo "Formatting code... "
COMMAND ${CLANG_FORMAT_EXECUTABLE} -style=file -i ${formatting_files}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
DEPENDS ${CLANG_FORMAT_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/dart)

add_custom_target(check-format
COMMAND ${CMAKE_COMMAND} -E echo "Checking code format... "
COMMAND ${CMAKE_SOURCE_DIR}/tools/check_format.sh ${CLANG_FORMAT_EXECUTABLE} ${formatting_files}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
DEPENDS ${CLANG_FORMAT_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/dart)
if ("${formatting_files}")
add_custom_target(format
COMMAND ${CMAKE_COMMAND} -E echo "Formatting ${formatting_files_length} files... "
COMMAND ${CLANG_FORMAT_EXECUTABLE} -style=file -i ${formatting_files}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
DEPENDS ${CLANG_FORMAT_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/dart)

add_custom_target(check-format
COMMAND ${CMAKE_COMMAND} -E echo "Checking ${formatting_files_length} files... "
COMMAND ${CMAKE_SOURCE_DIR}/tools/check_format.sh ${CLANG_FORMAT_EXECUTABLE} ${formatting_files}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
DEPENDS ${CLANG_FORMAT_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/dart)
else()
add_custom_target(format
COMMAND ${CMAKE_COMMAND} -E echo "Formatting ${formatting_files_length} files... "
COMMAND ${CMAKE_COMMAND} -E echo "Done.")

add_custom_target(check-format
COMMAND ${CMAKE_COMMAND} -E echo "Checking ${formatting_files_length} files... "
COMMAND ${CMAKE_COMMAND} -E echo "Done.")
endif()

else()

Expand Down
1 change: 1 addition & 0 deletions ci/install_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ libtinyxml2-dev
liburdfdom-dev
liburdfdom-headers-dev
libopenscenegraph-dev
clang-format-3.8
'

sudo apt-get -qq --yes --force-yes install $APT
1 change: 1 addition & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$COMPILER" = "CLANG" ]; then exit;
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DDART_VERBOSE=ON -DDART_TREAT_WARNINGS_AS_ERRORS=ON -DDART_COVERALLS=$COVERALLS ..
make -j4 tutorials examples tests
if [ "$TRAVIS_OS_NAME" = "linux" ]; then make check-format; fi
if [ $COVERALLS = ON ]; then make -j4 coveralls; else make -j4 test; fi

5 changes: 5 additions & 0 deletions tools/check_format.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "Usage: ./check_format.sh [<file> ...]" >&2
exit 0
fi

num_changes=`$1 -style=file -output-replacements-xml "${@:2}" | grep -c "<replacement "`

if [ "$num_changes" = "0" ]; then
Expand Down

0 comments on commit e5e61bd

Please sign in to comment.