1 //===- Version.cpp - Flang Version Number -------------------*- Fortran -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines several version-related utility functions for Flang.
11 //===----------------------------------------------------------------------===//
13 #include "flang/Common/Version.h"
14 #include "llvm/Support/raw_ostream.h"
18 #include "VCSVersion.inc"
20 namespace Fortran::common
{
22 std::string
getFlangRepositoryPath() {
23 #if defined(FLANG_REPOSITORY_STRING)
24 return FLANG_REPOSITORY_STRING
;
26 #ifdef FLANG_REPOSITORY
27 return FLANG_REPOSITORY
;
34 std::string
getLLVMRepositoryPath() {
35 #ifdef LLVM_REPOSITORY
36 return LLVM_REPOSITORY
;
42 std::string
getFlangRevision() {
44 return FLANG_REVISION
;
50 std::string
getLLVMRevision() {
58 std::string
getFlangFullRepositoryVersion() {
60 llvm::raw_string_ostream
OS(buf
);
61 std::string Path
= getFlangRepositoryPath();
62 std::string Revision
= getFlangRevision();
63 if (!Path
.empty() || !Revision
.empty()) {
67 if (!Revision
.empty()) {
74 // Support LLVM in a separate repository.
75 std::string LLVMRev
= getLLVMRevision();
76 if (!LLVMRev
.empty() && LLVMRev
!= Revision
) {
78 std::string LLVMRepo
= getLLVMRepositoryPath();
79 if (!LLVMRepo
.empty())
80 OS
<< LLVMRepo
<< ' ';
86 std::string
getFlangFullVersion() { return getFlangToolFullVersion("flang"); }
88 std::string
getFlangToolFullVersion(llvm::StringRef ToolName
) {
90 llvm::raw_string_ostream
OS(buf
);
94 OS
<< ToolName
<< " version " FLANG_VERSION_STRING
;
96 std::string repo
= getFlangFullRepositoryVersion();
104 } // end namespace Fortran::common