-
Notifications
You must be signed in to change notification settings - Fork 198
/
astyle-apply.sh
executable file
·79 lines (63 loc) · 1.8 KB
/
astyle-apply.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Copyright (c) 1998 Lawrence Livermore National Security, LLC and other
# HYPRE Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
scriptname=`basename $0 .sh`
# Check number of arguments
if [ $# -lt 1 ]; then
echo "Need at least one argument"
exit
fi
# Echo usage information
case $1 in
-h|-help)
cat <<EOF
$0 [-h|-help] {src_dir}
where: {src_dir} is the hypre source directory
-h|-help prints this usage information and exits
This script applies indentation style to hypre source files.
It also generates the internal '_hypre*.h' header files.
Example usage: $0 ../src
EOF
exit
;;
esac
# Setup
src_dir=`cd $1; pwd`
shift
cd $src_dir
# Check for correct version of astyle
astyle_version="Artistic Style Version 3.1"
if [ ! -x "$(command -v astyle)" ]; then
echo "$astyle_version not found"
exit
elif [ "$(astyle --version)" != "$astyle_version" ]; then
echo "Please use $astyle_version"
fi
# Generate list of source files to indent
find . -type f -print | egrep '[.]*[.](c|cc|cpp|cxx|C|h|hpp|hxx|H)$' |
egrep -v '/docs' |
egrep -v '/FEI_mv' |
egrep -v '/blas' |
egrep -v '/lapack' |
egrep -v '/distributed' |
egrep -v '/hypre/include' |
egrep -v '/HYPREf[.]h' |
egrep -v '/utilities/HYPRE_error_f[.]h' |
egrep -v '/utilities/cub_allocator[.]h' |
egrep -v '/_hypre_.*[.]h' > $scriptname.files
# Apply indentation style to source files
astyle_result=$(astyle --options=config/astylerc $(cat $scriptname.files))
if [ -n "$astyle_result" ]; then
echo "Please make sure changes are committed"
else
echo "No source files were changed"
fi
# Run headers scripts
for i in $(find . -name 'headers')
do
dir=$(dirname $i)
(cd $dir; ./headers)
done
rm -f $scriptname.files