Remove unsupported configs from the gpuupdate matrix
[gromacs.git] / admin / iwyu.sh
blob3d2fce665388388f69e722afb1ff22e2358e2931
1 #!/bin/bash
3 # This file is part of the GROMACS molecular simulation package.
5 # Copyright (c) 2014, by the GROMACS development team, led by
6 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7 # and including many others, as listed in the AUTHORS file in the
8 # top-level source directory and at http://www.gromacs.org.
10 # GROMACS is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public License
12 # as published by the Free Software Foundation; either version 2.1
13 # of the License, or (at your option) any later version.
15 # GROMACS is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with GROMACS; if not, see
22 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 # If you want to redistribute modifications to GROMACS, please
26 # consider that scientific software is very special. Version
27 # control is crucial - bugs must be traceable. We will be happy to
28 # consider code for inclusion in the official distribution, but
29 # derived work must not be called official GROMACS. Details are found
30 # in the README & COPYING files - if they are missing, get the
31 # official version at http://www.gromacs.org.
33 # To help us fund GROMACS development, we humbly ask that you cite
34 # the research papers on the package. Check out http://www.gromacs.org.
36 # The build and source folder can be specified with -B and -S respectively.
37 # By default it assume "-B. -S..".
38 # include-what-you-use needs to be in the path. Add --apply if you want
39 # changes to be applied. Any extra arguments are added as is to the
40 # command (can be used for extra defines or include paths).
42 filename=
43 build_path=.
44 src_path=..
45 cmd="include-what-you-use -DHAVE_CONFIG_H -mavx"
47 # Read all special arguments and add others to the command
48 apply=0
49 for arg in "$@"; do
50 if [ $arg == "--apply" ]; then
51 apply=1
52 elif [[ $arg == -[SB] ]]; then
53 echo -S and -B require an argument
54 exit 1
55 elif [[ $arg == -B* ]]; then
56 build_path=${arg:2}
57 elif [[ $arg == -S* ]]; then
58 src_path=${arg:2}
59 elif [[ $arg != -* ]]; then
60 if [ "$filename" == "" ]; then
61 filename=$arg
62 else
63 echo "This script can only be run on one file at a time"
64 exit 1
66 else
67 cmd="$cmd $arg"
69 done
71 if [ "$filename" == "" ]; then
72 echo "No file specified"
73 exit 1
76 # We cannot detect wether it is a C++ or C header. Should be fine to always use C++
77 if [ "${filename##*.}" == "h" ]; then
78 cmd="$cmd -x c++"
81 cmd="$cmd $filename"
83 # Always use C++11.
84 if [ "${filename##*.}" == "cpp" -o "${filename##*.}" == "h" ]; then
85 cmd="$cmd -std=c++11"
88 # keep gmxpre.h for source files
89 if [ "${filename##*.}" == "cpp" -o "${filename##*.}" == "c" ]; then
90 cmd="$cmd -Xiwyu --pch_in_code -Xiwyu --prefix_header_includes=keep"
93 if [ $src_path == "." ]; then
94 src_folder="src" # ./src confuses IWYU
95 else
96 src_folder="$src_path/src"
99 cmd="$cmd -I${src_folder} -I${src_folder}/external/thread_mpi/include
100 -I$build_path/src -I${src_folder}/external/boost
101 -Xiwyu --mapping_file=${src_path}/admin/iwyu.imp"
103 if [ $apply -eq 1 ] ; then
104 cmd="$cmd 2>&1 | fix_includes.py --nosafe_headers ||
105 ${src_path}/docs/doxygen/includesorter.py $filename -B$build_path -S$src_path"
108 eval $cmd