|
| 1 | +#/ |
| 2 | +# @license Apache-2.0 |
| 3 | +# |
| 4 | +# Copyright (c) 2021 The Stdlib Authors. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +#/ |
| 18 | + |
| 19 | +# DEPENDENCIES # |
| 20 | + |
| 21 | +# Note: keep in alphabetical order... |
| 22 | +include $(TOOLS_MAKE_LIB_DIR)/lint/c/cppcheck.mk |
| 23 | + |
| 24 | + |
| 25 | +# RULES # |
| 26 | + |
| 27 | +#/ |
| 28 | +# Checks whether C linters are installed. |
| 29 | +# |
| 30 | +# @private |
| 31 | +# |
| 32 | +# @example |
| 33 | +# make check-c-linters |
| 34 | +#/ |
| 35 | +check-c-linters: check-cppcheck |
| 36 | + |
| 37 | +.PHONY: check-c-linters |
| 38 | + |
| 39 | +#/ |
| 40 | +# Lints C files. |
| 41 | +# |
| 42 | +# ## Notes |
| 43 | +# |
| 44 | +# - This rule is useful when wanting to glob for files, irrespective of context, for a particular directory in order to lint all contained C files. |
| 45 | +# |
| 46 | +# @param {string} [C_SOURCES_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`) |
| 47 | +# @param {string} [C_TESTS_FIXTURES_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`) |
| 48 | +# @param {string} [C_EXAMPLES_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`) |
| 49 | +# @param {string} [C_BENCHMARKS_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`) |
| 50 | +# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error |
| 51 | +# |
| 52 | +# @example |
| 53 | +# make lint-c |
| 54 | +# |
| 55 | +# @example |
| 56 | +# make lint-c C_SOURCES_FILTER=".*/blas/base/dasum/.*" C_TESTS_FIXTURES_FILTER=".*/blas/base/dasum/.*" C_EXAMPLES_FILTER=".*/blas/base/dasum/.*" C_BENCHMARKS_FILTER=".*/blas/base/dasum/.*" |
| 57 | +#/ |
| 58 | +lint-c: lint-c-src lint-c-examples lint-c-benchmarks lint-c-tests-fixtures |
| 59 | + |
| 60 | +.PHONY: lint-c |
| 61 | + |
| 62 | +#/ |
| 63 | +# Lints C source files. |
| 64 | +# |
| 65 | +# ## Notes |
| 66 | +# |
| 67 | +# - This rule is useful when wanting to glob for C source files (e.g., lint all C source files for a particular package). |
| 68 | +# |
| 69 | +# @param {string} [C_SOURCES_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`) |
| 70 | +# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error |
| 71 | +# |
| 72 | +# @example |
| 73 | +# make lint-c-src |
| 74 | +# |
| 75 | +# @example |
| 76 | +# make lint-c-src C_SOURCES_FILTER=".*/math/base/special/abs/.*" |
| 77 | +#/ |
| 78 | +lint-c-src: |
| 79 | +ifeq ($(C_LINTER), cppcheck) |
| 80 | + $(QUIET) $(MAKE) -f $(this_file) cppcheck-src |
| 81 | +endif |
| 82 | + |
| 83 | +.PHONY: lint-c-src |
| 84 | + |
| 85 | +#/ |
| 86 | +# Lints C examples files. |
| 87 | +# |
| 88 | +# ## Notes |
| 89 | +# |
| 90 | +# - This rule is useful when wanting to glob for C examples files (e.g., lint all C examples files for a particular package). |
| 91 | +# |
| 92 | +# @param {string} [C_EXAMPLES_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`) |
| 93 | +# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error |
| 94 | +# |
| 95 | +# @example |
| 96 | +# make lint-c-examples |
| 97 | +# |
| 98 | +# @example |
| 99 | +# make lint-c-examples C_EXAMPLES_FILTER=".*/math/base/special/abs/.*" |
| 100 | +#/ |
| 101 | +lint-c-examples: |
| 102 | +ifeq ($(C_LINTER), cppcheck) |
| 103 | + $(QUIET) $(MAKE) -f $(this_file) cppcheck-examples |
| 104 | +endif |
| 105 | + |
| 106 | +.PHONY: lint-c-examples |
| 107 | + |
| 108 | +#/ |
| 109 | +# Lints C benchmark files. |
| 110 | +# |
| 111 | +# ## Notes |
| 112 | +# |
| 113 | +# - This rule is useful when wanting to glob for C benchmark files (e.g., lint all C benchmark files for a particular package). |
| 114 | +# |
| 115 | +# @param {string} [C_BENCHMARKS_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`) |
| 116 | +# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error |
| 117 | +# |
| 118 | +# @example |
| 119 | +# make lint-c-benchmarks |
| 120 | +# |
| 121 | +# @example |
| 122 | +# make lint-c-benchmarks C_BENCHMARKS_FILTER=".*/math/base/special/abs/.*" |
| 123 | +#/ |
| 124 | +lint-c-benchmarks: |
| 125 | +ifeq ($(C_LINTER), cppcheck) |
| 126 | + $(QUIET) $(MAKE) -f $(this_file) cppcheck-benchmarks |
| 127 | +endif |
| 128 | + |
| 129 | +.PHONY: lint-c-benchmarks |
| 130 | + |
| 131 | +#/ |
| 132 | +# Lints C test fixture files. |
| 133 | +# |
| 134 | +# ## Notes |
| 135 | +# |
| 136 | +# - This rule is useful when wanting to glob for C test fixture files (e.g., lint all C test fixture files for a particular package). |
| 137 | +# |
| 138 | +# @param {string} [C_TESTS_FIXTURES_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`) |
| 139 | +# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error |
| 140 | +# |
| 141 | +# @example |
| 142 | +# make lint-c-tests-fixtures |
| 143 | +# |
| 144 | +# @example |
| 145 | +# make lint-c-tests-fixtures C_TESTS_FIXTURES_FILTER=".*/math/base/special/abs/.*" |
| 146 | +#/ |
| 147 | +lint-c-tests-fixtures: |
| 148 | +ifeq ($(C_LINTER), cppcheck) |
| 149 | + $(QUIET) $(MAKE) -f $(this_file) cppcheck-tests-fixtures |
| 150 | +endif |
| 151 | + |
| 152 | +.PHONY: lint-c-tests-fixtures |
| 153 | + |
| 154 | +#/ |
| 155 | +# Lints a specified list of C files. |
| 156 | +# |
| 157 | +# ## Notes |
| 158 | +# |
| 159 | +# - This rule is useful when wanting to lint a list of C files generated by some other command (e.g., a list of changed C files obtained via `git diff`). |
| 160 | +# |
| 161 | +# @param {string} FILES - list of C file paths |
| 162 | +# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error |
| 163 | +# |
| 164 | +# @example |
| 165 | +# make lint-c-files FILES='/foo/file.c /bar/file.c' |
| 166 | +#/ |
| 167 | +lint-c-files: |
| 168 | +ifeq ($(C_LINTER), cppcheck) |
| 169 | + $(QUIET) FILES="$(FILES)" $(MAKE) -f $(this_file) cppcheck-files |
| 170 | +endif |
| 171 | + |
| 172 | +.PHONY: lint-c-files |
0 commit comments