From a703c8169e0eec00225feefce645b90e651854f7 Mon Sep 17 00:00:00 2001 From: jgoppert Date: Wed, 4 Nov 2015 23:19:20 -0500 Subject: [PATCH] Working on formatting. --- .travis.yml | 1 - CMakeLists.txt | 18 ++++++++++++++---- scripts/format.sh | 7 ++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0b19fadce9..55d027c767 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,3 @@ addons: apt: packages: - cmake - - astyle diff --git a/CMakeLists.txt b/CMakeLists.txt index 80e163f20d..f7fe1540a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,16 +63,26 @@ endif() add_subdirectory(test) -add_custom_target(format - COMMAND scripts/format.sh 1 +set(astyle_exe ${CMAKE_BINARY_DIR}/astyle/src/bin/astyle) +add_custom_command(OUTPUT ${astyle_exe} + COMMAND wget http://sourceforge.net/projects/astyle/files/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz -O /tmp/astyle.tar.gz + COMMAND tar -xvf /tmp/astyle.tar.gz + COMMAND cd astyle/src && make -f ../build/gcc/Makefile + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + +add_custom_target(check_format + COMMAND scripts/format.sh ${astyle_exe} 0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + DEPENDS ${astyle_exe} VERBATIM ) -add_custom_target(check_format - COMMAND scripts/format.sh +add_custom_target(format + COMMAND scripts/format.sh ${astyle_exe} 1 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} VERBATIM + DEPENDS ${astyle_exe} ) set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) diff --git a/scripts/format.sh b/scripts/format.sh index f5faa735ec..37f746ac1f 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,6 +1,7 @@ #!/bin/bash echo pwd:$PWD -format=$1 +astyle=$1 +format=$2 format_wildcards=""" ./matrix/*.*pp ./test/*.*pp @@ -9,10 +10,10 @@ format_wildcards=""" if [[ $format ]] then echo formatting - astyle ${format_wildcards} + $astyle ${format_wildcards} else echo checking format - astyle --dry-run ${format_wildcards} | grep Formatted + $astyle --dry-run ${format_wildcards} | grep Formatted if [[ $? -eq 0 ]] then echo need to format