diff options
author | Tom Rini <trini@konsulko.com> | 2021-07-14 20:10:34 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-07-14 20:10:34 -0400 |
commit | c11f5abce84f630c92304683d5bde3204c5612c4 (patch) | |
tree | 29f4a7db27669fac1ea7b7eb8821b5440b09af0d /scripts/clang-version.sh | |
parent | eae8c7c33829c3bd25a792600c1fe6ed842a1ddc (diff) | |
parent | 963fde31559f50ceb4f5965f00d79f8747a9d217 (diff) |
Merge branch '2021-07-14-build-and-host-updates'
- Resync Kbuild with the v4.20 Linux Kernel release
- Update checkpatch.pl
- Assorted other tooling updates
Diffstat (limited to 'scripts/clang-version.sh')
-rwxr-xr-x | scripts/clang-version.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh new file mode 100755 index 00000000000..e65fbc3079d --- /dev/null +++ b/scripts/clang-version.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# clang-version [-p] clang-command +# +# Prints the compiler version of `clang-command' in a canonical 4-digit form +# such as `0500' for clang-5.0 etc. +# +# With the -p option, prints the patchlevel as well, for example `050001' for +# clang-5.0.1 etc. +# + +compiler="$*" + +if ! ( $compiler --version | grep -q clang) ; then + echo 0 + exit 1 +fi + +MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) +MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) +PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL |