Douglas Gregor | 60b5d8e | 2009-10-05 18:52:24 +0000 | [diff] [blame] | 1 | //===- Version.cpp - Clang Version Number -----------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines several version-related utility functions for Clang. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | #include <cstring> |
| 14 | #include <cstdlib> |
| 15 | using namespace std; |
| 16 | |
| 17 | namespace clang { |
| 18 | |
| 19 | const char *getClangSubversionPath() { |
| 20 | static const char *Path = 0; |
| 21 | if (Path) |
| 22 | return Path; |
| 23 | |
| 24 | static char URL[] = "$URL$"; |
| 25 | char *End = strstr(URL, "/lib/Basic"); |
| 26 | if (End) |
| 27 | *End = 0; |
| 28 | |
Douglas Gregor | 1fbf1f0 | 2009-11-05 23:46:05 +0000 | [diff] [blame] | 29 | End = strstr(URL, "/clang/tools/clang"); |
| 30 | if (End) |
| 31 | *End = 0; |
| 32 | |
Douglas Gregor | 60b5d8e | 2009-10-05 18:52:24 +0000 | [diff] [blame] | 33 | char *Begin = strstr(URL, "cfe/"); |
| 34 | if (Begin) { |
| 35 | Path = Begin + 4; |
| 36 | return Path; |
| 37 | } |
| 38 | |
| 39 | Path = URL; |
| 40 | return Path; |
| 41 | } |
| 42 | |
| 43 | |
| 44 | unsigned getClangSubversionRevision() { |
| 45 | #ifndef SVN_REVISION |
Douglas Gregor | b8d1191 | 2009-10-05 20:33:49 +0000 | [diff] [blame] | 46 | // Subversion was not available at build time? |
Douglas Gregor | 60b5d8e | 2009-10-05 18:52:24 +0000 | [diff] [blame] | 47 | return 0; |
| 48 | #else |
Douglas Gregor | b8d1191 | 2009-10-05 20:33:49 +0000 | [diff] [blame] | 49 | return strtol(SVN_REVISION, 0, 10); |
Douglas Gregor | 60b5d8e | 2009-10-05 18:52:24 +0000 | [diff] [blame] | 50 | #endif |
| 51 | } |
| 52 | |
| 53 | } // end namespace clang |