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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
#!/bin/sh -e
# Copyright 2017, 2018 Kai Pastor
#
# This file is part of OpenOrienteering.
#
# OpenOrienteering is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenOrienteering is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenOrienteering. If not, see <http://www.gnu.org/licenses/>.
# This is a wrapper for code quality tools supported by CMake.
#
# It adds these benefits over direct use of the tools:
#
# - It provides a pattern for filenames on which the tools are to be
# applied. This limits the noise in relevant diagnostic output and
# cuts build times by skipping files which are not of interest.
# - It allows changing pattern and arguments without forcing a complete
# rebuild of all sources handled by this compiler (which is always
# triggered by changes to the CMake variables).
#
# To use this wrapper, set its full path as the program for each check,
# with the actual tool as the first argument, e.g.
#
# CMAKE_CXX_CLANG_TIDY="/path/to/code-check-wrapper.sh;clang-tidy"
# CMAKE_CXX_INCLUDE_WHAT_YOU_USE="/path/to/code-check-wrapper.sh;iwyu"
#
# Any other parameter is ignored. So modifying extra parameters can still
# be used to force a full re-run.
PROGRAM=$1
shift
ENABLE_CLANG_TIDY=true
ENABLE_IWYU=true
PATTERN=
for I in \
action_grid_bar.cpp \
boolean_tool.cpp \
color_wheel_widget.cpp \
combined_symbol.cpp \
configure_grid_dialog.cpp \
course_file_format.cpp \
crs_param_widgets.cpp \
crs_template.cpp \
crs_template_implementation.cpp \
duplicate_equals_t.cpp \
file_dialog.cpp \
/file_format.cpp \
file_format_t.cpp \
file_import_export.cpp \
georeferencing.cpp \
georeferencing_dialog.cpp \
georeferencing_t.cpp \
icon_engine \
iof_course_export \
key_button_bar.cpp \
key_value_container \
kml_course_export \
line_symbol.cpp \
main.cpp \
/map.cpp \
map_coord.cpp \
map_editor.cpp \
map_find_feature.cpp \
map_printer \
map_widget.cpp \
mapper_proxystyle.cpp \
/object.cpp \
object_mover.cpp \
object_query.cpp \
ocd_file_format.cpp \
ocd_t.cpp \
overriding_shortcut.cpp \
paint_on_template \
point_symbol.cpp \
print_widget.cpp \
renderable.cpp \
renderable_implementation.cpp \
rotate_map_dialog.cpp \
settings_dialog.cpp \
simple_course_dialog.cpp \
simple_course_export.cpp \
stretch_map_dialog.cpp \
style_t.cpp \
/symbol.cpp \
symbol_replacement.cpp \
symbol_replacement_dialog.cpp \
symbol_rule_set.cpp \
symbol_t.cpp \
symbol_tooltip.cpp \
tag_select_widget.cpp \
/template.cpp \
template_image.cpp \
template_image_open_dialog.cpp \
template_list_widget.cpp \
template_map.cpp \
template_placeholder.cpp \
template_table_model.cpp \
template_t.cpp \
template_tool \
template_track.cpp \
text_object_editor_helper.cpp \
text_brwoser_dialog \
toast.cpp \
track_t.cpp \
/track.cpp \
undo_manager.cpp \
/util.cpp \
/util_gui.cpp \
world_file.cpp \
xml_file_format.cpp \
xml_stream_util.cpp \
\
"3rd-party/cove/[^ ]*.cpp" \
gdal/ \
ocd \
src/sensors/ \
src/tools/ \
settings \
# end of patterns
do
PATTERN="${PATTERN:+$PATTERN\|}$I"
done
if echo "$@" | grep -q "${PATTERN}"; then
case "${PROGRAM}" in
*clang-tidy*)
if ${ENABLE_CLANG_TIDY}; then
"${PROGRAM}" \
"$@" \
|| exit 1
fi
;;
*iwyu*|*include-what-you-use*)
if ${ENABLE_IWYU}; then
"${PROGRAM}" \
-Xiwyu --mapping_file=${0%/*}/iwyu-mapper.imp \
-Xiwyu --check_also=*_p.h \
-Xiwyu --max_line_length=160 \
"-DqPrintable(...)=(void(__VA_ARGS__), \"\")" \
"-DqUtf8Printable(...)=(void(__VA_ARGS__), \"\")" \
"$@" \
|| exit 1
fi
;;
*)
"${PROGRAM}" "$@" || exit 1
esac
else
true;
fi
|