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
16 echo "usage: `basename $0`"
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."
28 while [ $# -gt 0 ]; do
35 if [ -n "$print" ]; then
36 echo "Only one of --major, --minor, --patch is allowed"
42 if [ -n "$print" ]; then
43 echo "Only one of --major, --minor, --patch is allowed"
49 if [ -n "$print" ]; then
50 echo "Only one of --major, --minor, --patch is allowed"
60 echo "unknown option: $1"
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]\+'`
83 echo "$major.$minor.$patch"