Skip to content

Commit 4ef7502

Browse files
committed
build: add script to check for clang-format
1 parent 92b2038 commit 4ef7502

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tools/scripts/check_clang_format

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
#
3+
# @license Apache-2.0
4+
#
5+
# Copyright (c) 2014 The Stdlib Authors.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
# Check whether clang-format is installed.
20+
#
21+
# Usage: check_clang_format
22+
#
23+
24+
# VARIABLES #
25+
26+
# Find clang-format:
27+
CLANG_FORMAT=$(command -v clang-format 2>/dev/null)
28+
29+
30+
# FUNCTIONS #
31+
32+
# Prints usage information.
33+
usage() {
34+
echo '' >&2
35+
echo 'Usage: check_clang_format' >&2
36+
echo '' >&2
37+
}
38+
39+
# MAIN #
40+
41+
if [[ -x "${CLANG_FORMAT}" ]] && "${CLANG_FORMAT}" --version >/dev/null; then
42+
echo 'clang-format is installed.' >&2
43+
exit 0
44+
else
45+
echo 'ERROR: missing dependency. Please download clang-format version >= 19 (https://clang.llvm.org/; the latest version is recommended). Once installed, run the command again.' >&2
46+
exit 1
47+
fi
48+
49+
# TODO: check for minimum version

0 commit comments

Comments
 (0)