2009-10-05 18:52:24 +00:00
|
|
|
//===- Version.cpp - Clang Version Number -----------------------*- C++ -*-===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
//
|
|
|
|
|
// This file defines several version-related utility functions for Clang.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2010-01-22 20:55:35 +00:00
|
|
|
|
2010-01-22 22:29:50 +00:00
|
|
|
#include "clang/Basic/Version.h"
|
2010-01-22 22:12:47 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2009-10-05 18:52:24 +00:00
|
|
|
#include <cstring>
|
|
|
|
|
#include <cstdlib>
|
2010-01-22 20:55:35 +00:00
|
|
|
|
2009-10-05 18:52:24 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
|
|
2010-09-29 19:15:29 +00:00
|
|
|
std::string getClangRepositoryPath() {
|
2010-09-29 17:57:10 +00:00
|
|
|
#ifdef SVN_REPOSITORY
|
2010-09-29 19:15:29 +00:00
|
|
|
llvm::StringRef URL(SVN_REPOSITORY);
|
|
|
|
|
#else
|
|
|
|
|
llvm::StringRef URL("");
|
|
|
|
|
#endif
|
2010-01-30 14:01:39 +00:00
|
|
|
|
2010-09-29 19:15:29 +00:00
|
|
|
// Strip off version from a build from an integration branch.
|
|
|
|
|
URL = URL.slice(0, URL.find("/src/tools/clang"));
|
2010-01-30 14:01:39 +00:00
|
|
|
|
2010-09-29 19:15:29 +00:00
|
|
|
// Trim path prefix off, assuming path came from standard cfe path.
|
|
|
|
|
size_t Start = URL.find("cfe/");
|
|
|
|
|
if (Start != llvm::StringRef::npos)
|
|
|
|
|
URL = URL.substr(Start + 4);
|
2010-01-30 14:01:39 +00:00
|
|
|
|
2010-09-29 19:15:29 +00:00
|
|
|
return URL;
|
2009-10-05 18:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-29 19:15:29 +00:00
|
|
|
std::string getClangRevision() {
|
2010-03-03 01:02:48 +00:00
|
|
|
#ifdef SVN_REVISION
|
2010-09-29 19:15:29 +00:00
|
|
|
return SVN_REVISION;
|
|
|
|
|
#else
|
2010-03-03 01:02:48 +00:00
|
|
|
return "";
|
2010-09-29 19:15:29 +00:00
|
|
|
#endif
|
2009-10-05 18:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-12 22:54:40 +00:00
|
|
|
std::string getClangFullRepositoryVersion() {
|
|
|
|
|
std::string buf;
|
|
|
|
|
llvm::raw_string_ostream OS(buf);
|
2010-09-29 19:15:29 +00:00
|
|
|
std::string Path = getClangRepositoryPath();
|
|
|
|
|
std::string Revision = getClangRevision();
|
2010-09-29 17:57:10 +00:00
|
|
|
if (!Path.empty())
|
|
|
|
|
OS << Path;
|
|
|
|
|
if (!Revision.empty()) {
|
|
|
|
|
if (!Path.empty())
|
|
|
|
|
OS << ' ';
|
|
|
|
|
OS << Revision;
|
|
|
|
|
}
|
2010-03-05 15:39:20 +00:00
|
|
|
return OS.str();
|
2010-01-22 22:29:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-12 22:54:40 +00:00
|
|
|
std::string getClangFullVersion() {
|
|
|
|
|
std::string buf;
|
|
|
|
|
llvm::raw_string_ostream OS(buf);
|
2010-01-22 22:29:50 +00:00
|
|
|
#ifdef CLANG_VENDOR
|
2010-02-12 22:54:40 +00:00
|
|
|
OS << CLANG_VENDOR;
|
2010-01-22 22:29:50 +00:00
|
|
|
#endif
|
2010-02-12 22:54:40 +00:00
|
|
|
OS << "clang version " CLANG_VERSION_STRING " ("
|
|
|
|
|
<< getClangFullRepositoryVersion() << ')';
|
2010-03-05 15:39:20 +00:00
|
|
|
return OS.str();
|
2010-01-22 22:12:47 +00:00
|
|
|
}
|
2010-02-12 22:54:40 +00:00
|
|
|
|
2009-10-05 18:52:24 +00:00
|
|
|
} // end namespace clang
|