[AArch64] Fix SDNode type mismatches between *.td files and ISel (#116523)
[llvm-project.git] / llvm / utils / release / get-llvm-version.sh
blob2183e2e0edacd0d8f0c4f9ad538e931097d8ed33
1 #!/usr/bin/env bash
2 #===-- get-llvm-version.sh - Get LLVM Version from sources -----------------===#
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===------------------------------------------------------------------------===#
10 # Extract the current LLVM version from the CMake files.
12 #===------------------------------------------------------------------------===#
14 cmake_file=$(dirname $0)/../../../cmake/Modules/LLVMVersion.cmake
15 function usage() {
16 echo "usage: `basename $0`"
17 echo ""
18 echo "Calling this script with now options will output the full version: e.g. 19.1.0"
19 echo " --cmake-file Path to cmake file with the version (default: $cmake_file)
20 echo " You can use at most one of the following options:
21 echo " --major Print the major version."
22 echo " --minor Print the minor version."
23 echo " --patch Print the patch version."
26 print=""
28 while [ $# -gt 0 ]; do
29 case $1 in
30 --cmake-file )
31 shift
32 cmake_file="$1"
34 --major)
35 if [ -n "$print" ]; then
36 echo "Only one of --major, --minor, --patch is allowed"
37 exit 1
39 print="major"
41 --minor)
42 if [ -n "$print" ]; then
43 echo "Only one of --major, --minor, --patch is allowed"
44 exit 1
46 print="minor"
48 --patch)
49 if [ -n "$print" ]; then
50 echo "Only one of --major, --minor, --patch is allowed"
51 exit 1
53 print="patch"
55 --help | -h | -\? )
56 usage
57 exit 0
59 * )
60 echo "unknown option: $1"
61 usage
62 exit 1
64 esac
65 shift
66 done
68 major=`grep -o 'LLVM_VERSION_MAJOR[[:space:]]\+\([0-9]\+\)' $cmake_file | grep -o '[0-9]\+'`
69 minor=`grep -o 'LLVM_VERSION_MINOR[[:space:]]\+\([0-9]\+\)' $cmake_file | grep -o '[0-9]\+'`
70 patch=`grep -o 'LLVM_VERSION_PATCH[[:space:]]\+\([0-9]\+\)' $cmake_file | grep -o '[0-9]\+'`
72 case $print in
73 major)
74 echo "$major"
76 minor)
77 echo "$minor"
79 patch)
80 echo "$patch"
83 echo "$major.$minor.$patch"
85 esac