Tim Peters | 22a51ef | 2001-12-04 01:11:32 +0000 | [diff] [blame] | 1 | #include "Python.h" |
Guido van Rossum | 49bff65 | 1997-05-20 22:40:26 +0000 | [diff] [blame] | 2 | |
Guido van Rossum | ff7e83d | 1999-08-27 20:39:37 +0000 | [diff] [blame] | 3 | #ifndef DONT_HAVE_STDIO_H |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 4 | #include <stdio.h> |
Guido van Rossum | ff7e83d | 1999-08-27 20:39:37 +0000 | [diff] [blame] | 5 | #endif |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 6 | |
| 7 | #ifndef DATE |
| 8 | #ifdef __DATE__ |
| 9 | #define DATE __DATE__ |
| 10 | #else |
| 11 | #define DATE "xx/xx/xx" |
| 12 | #endif |
| 13 | #endif |
| 14 | |
| 15 | #ifndef TIME |
| 16 | #ifdef __TIME__ |
| 17 | #define TIME __TIME__ |
| 18 | #else |
| 19 | #define TIME "xx:xx:xx" |
| 20 | #endif |
| 21 | #endif |
| 22 | |
Kristján Valur Jónsson | b53940f | 2007-06-07 23:53:49 +0000 | [diff] [blame] | 23 | /* on unix, SVNVERSION is passed on the command line. |
| 24 | * on Windows, the string is interpolated using |
| 25 | * subwcrev.exe |
| 26 | */ |
| 27 | #ifndef SVNVERSION |
Martin v. Löwis | d078e40 | 2006-01-18 09:13:51 +0000 | [diff] [blame] | 28 | #define SVNVERSION "$WCRANGE$$WCMODS?M:$" |
Kristján Valur Jónsson | b53940f | 2007-06-07 23:53:49 +0000 | [diff] [blame] | 29 | #endif |
| 30 | |
Georg Brandl | 3a5508e | 2011-03-06 10:42:21 +0100 | [diff] [blame] | 31 | /* XXX Only unix build process has been tested */ |
| 32 | #ifndef HGVERSION |
| 33 | #define HGVERSION "" |
| 34 | #endif |
| 35 | #ifndef HGTAG |
| 36 | #define HGTAG "" |
| 37 | #endif |
| 38 | #ifndef HGBRANCH |
| 39 | #define HGBRANCH "" |
| 40 | #endif |
| 41 | |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 42 | const char * |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 43 | Py_GetBuildInfo(void) |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 44 | { |
Benjamin Peterson | 41a9ec9 | 2011-03-28 17:25:15 -0500 | [diff] [blame] | 45 | static char buildinfo[50 + sizeof(HGVERSION) + |
| 46 | ((sizeof(HGTAG) > sizeof(HGBRANCH)) ? |
| 47 | sizeof(HGTAG) : sizeof(HGBRANCH))]; |
Georg Brandl | 3a5508e | 2011-03-06 10:42:21 +0100 | [diff] [blame] | 48 | const char *revision = _Py_hgversion(); |
Antoine Pitrou | c83ea13 | 2010-05-09 14:46:46 +0000 | [diff] [blame] | 49 | const char *sep = *revision ? ":" : ""; |
Georg Brandl | 3a5508e | 2011-03-06 10:42:21 +0100 | [diff] [blame] | 50 | const char *hgid = _Py_hgidentifier(); |
| 51 | if (!(*hgid)) |
| 52 | hgid = "default"; |
Antoine Pitrou | c83ea13 | 2010-05-09 14:46:46 +0000 | [diff] [blame] | 53 | PyOS_snprintf(buildinfo, sizeof(buildinfo), |
Georg Brandl | 3a5508e | 2011-03-06 10:42:21 +0100 | [diff] [blame] | 54 | "%s%s%s, %.20s, %.9s", hgid, sep, revision, |
Antoine Pitrou | c83ea13 | 2010-05-09 14:46:46 +0000 | [diff] [blame] | 55 | DATE, TIME); |
| 56 | return buildinfo; |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 57 | } |
Barry Warsaw | ce3a913 | 2005-12-19 14:43:44 +0000 | [diff] [blame] | 58 | |
| 59 | const char * |
Martin v. Löwis | 43b5780 | 2006-01-05 23:38:54 +0000 | [diff] [blame] | 60 | _Py_svnversion(void) |
Barry Warsaw | ce3a913 | 2005-12-19 14:43:44 +0000 | [diff] [blame] | 61 | { |
Antoine Pitrou | c83ea13 | 2010-05-09 14:46:46 +0000 | [diff] [blame] | 62 | /* the following string can be modified by subwcrev.exe */ |
| 63 | static const char svnversion[] = SVNVERSION; |
| 64 | if (svnversion[0] != '$') |
| 65 | return svnversion; /* it was interpolated, or passed on command line */ |
| 66 | return "Unversioned directory"; |
Barry Warsaw | ce3a913 | 2005-12-19 14:43:44 +0000 | [diff] [blame] | 67 | } |
Georg Brandl | 3a5508e | 2011-03-06 10:42:21 +0100 | [diff] [blame] | 68 | |
| 69 | const char * |
| 70 | _Py_hgversion(void) |
| 71 | { |
| 72 | return HGVERSION; |
| 73 | } |
| 74 | |
| 75 | const char * |
| 76 | _Py_hgidentifier(void) |
| 77 | { |
| 78 | const char *hgtag, *hgid; |
| 79 | hgtag = HGTAG; |
| 80 | if ((*hgtag) && strcmp(hgtag, "tip") != 0) |
| 81 | hgid = hgtag; |
| 82 | else |
| 83 | hgid = HGBRANCH; |
| 84 | return hgid; |
| 85 | } |