Browse Source

Working on formatting.

master
jgoppert 9 years ago
parent
commit
a703c8169e
  1. 1
      .travis.yml
  2. 18
      CMakeLists.txt
  3. 7
      scripts/format.sh

1
.travis.yml

@ -25,4 +25,3 @@ addons: @@ -25,4 +25,3 @@ addons:
apt:
packages:
- cmake
- astyle

18
CMakeLists.txt

@ -63,16 +63,26 @@ endif() @@ -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})

7
scripts/format.sh

@ -1,6 +1,7 @@ @@ -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=""" @@ -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

Loading…
Cancel
Save