diff --git a/.travis.yml b/.travis.yml index 9f6fc47e26cd1c98f3617849e0028df9f109d50c..f4f1a4cd533e2fdd635e93cdfffe1489683f7857 100644 --- a/.travis.yml +++ b/.travis.yml @@ -90,6 +90,8 @@ install: - if test "$CPPCHECK" == yes ; then ./.travis/install.cppcheck $CPPCHECK_VERSION ; fi # for plumedcheck I need latest gawk - if test "$CPPCHECK" == yes ; then ./.travis/install.gawk 4.1.4 ; fi +# for plumedcheck I need astyle + - if test "$CPPCHECK" == yes ; then make -j 4 -C astyle ; fi # installation of these packages takes a lot of time # we do it only when needed - if test "$PLUMED_CXX" == "mpic++" -a "$TRAVIS_OS_NAME" == "linux" ; then sudo apt-get install -y libopenmpi-dev openmpi-bin ; fi diff --git a/src/maketools/codecheck b/src/maketools/codecheck index 15b6bd2f21a623123de2bc858ab6849052005f39..7f6a67e8a7a647c0d4e06557c41685964a83b832 100755 --- a/src/maketools/codecheck +++ b/src/maketools/codecheck @@ -22,9 +22,9 @@ done if [ $do_plumedcheck == true ] ; then if [ $do_local == true ] ; then - ../maketools/plumedcheck *.{h,cpp} ../../configure.ac + ../maketools/plumedcheck *.{h,cpp} ../../configure.ac --astyle=../../astyle/astyle --astyle-options=../../.astyle.options else - maketools/plumedcheck --global-check */*.{h,cpp} ../configure.ac + maketools/plumedcheck --global-check */*.{h,cpp} ../configure.ac --astyle=../astyle/astyle --astyle-options=../.astyle.options fi fi diff --git a/src/maketools/plumedcheck b/src/maketools/plumedcheck index 751a07db36b0d7db9b18261ad9fd3b9d9e5859e0..120808decbabe905049f6c393a0cfbf14e68cfa3 100755 --- a/src/maketools/plumedcheck +++ b/src/maketools/plumedcheck @@ -66,6 +66,7 @@ BEGIN{ newargv[0]=ARGV[0] pre="" opt_global_check=0 + astyle="astyle" for(i=1;i<ARGC;i++){ opt=pre ARGV[i] pre="" @@ -75,6 +76,14 @@ BEGIN{ usage(); break; case "--global-check": opt_global_check=1; break; + case /--astyle=.*/: + sub("^--astyle=","",opt); + astyle=opt; + case /--astyle-options=.*/: + sub("^--astyle-options=","",opt); + astyle_options=opt; + break; + break; case /-.*/: print "Unknown option " opt; exit(1) default: @@ -129,6 +138,9 @@ BEGIN{ core_modules["core"]=1 core_modules["tools"]=1 core_modules["reference"]=1 + +# create tmp dir for future usage + "mktemp -d" | getline tmpdir } # for each input file @@ -182,6 +194,14 @@ BEGINFILE{ # checks that are done only on some modules will be skipped if the module name is not known if((filetype=="source" || filetype=="header") && !module) information("missing_module_name","module name is not know, some check will be skipped"); + if(filetype=="source" || filetype=="header"){ + tempfile = tmpdir "/astyle" + system(astyle " --options=" astyle_options " < " FILENAME " > " tempfile) + s=system("diff -q " FILENAME " " tempfile ">/dev/null 2>/dev/null") + if(s!=0) error("astyle","astyle not satisfied") + system("rm " tempfile) + } + } # line by line analysis @@ -526,6 +546,9 @@ END{ error("unused_has","has " has " at " plumed_definehas[has] " is not used") } } + +# remove temporary directory + system("rmdir " tmpdir); } EOF