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 | |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 23 | /* XXX Only unix build process has been tested */ |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 24 | #ifndef GITVERSION |
| 25 | #define GITVERSION "" |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 26 | #endif |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 27 | #ifndef GITTAG |
| 28 | #define GITTAG "" |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 29 | #endif |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 30 | #ifndef GITBRANCH |
| 31 | #define GITBRANCH "" |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 32 | #endif |
| 33 | |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 34 | const char * |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 35 | Py_GetBuildInfo(void) |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 36 | { |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 37 | static char buildinfo[50 + sizeof(GITVERSION) + |
| 38 | ((sizeof(GITTAG) > sizeof(GITBRANCH)) ? |
| 39 | sizeof(GITTAG) : sizeof(GITBRANCH))]; |
| 40 | const char *revision = _Py_gitversion(); |
Antoine Pitrou | 7f14f0d | 2010-05-09 16:14:21 +0000 | [diff] [blame] | 41 | const char *sep = *revision ? ":" : ""; |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 42 | const char *gitid = _Py_gitidentifier(); |
| 43 | if (!(*gitid)) |
| 44 | gitid = "default"; |
Antoine Pitrou | 7f14f0d | 2010-05-09 16:14:21 +0000 | [diff] [blame] | 45 | PyOS_snprintf(buildinfo, sizeof(buildinfo), |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 46 | "%s%s%s, %.20s, %.9s", gitid, sep, revision, |
Antoine Pitrou | 7f14f0d | 2010-05-09 16:14:21 +0000 | [diff] [blame] | 47 | DATE, TIME); |
| 48 | return buildinfo; |
Guido van Rossum | 2fff2e6 | 1997-01-20 18:34:26 +0000 | [diff] [blame] | 49 | } |
Barry Warsaw | ce3a913 | 2005-12-19 14:43:44 +0000 | [diff] [blame] | 50 | |
| 51 | const char * |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 52 | _Py_gitversion(void) |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 53 | { |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 54 | return GITVERSION; |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | const char * |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 58 | _Py_gitidentifier(void) |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 59 | { |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 60 | const char *gittag, *gitid; |
| 61 | gittag = GITTAG; |
| 62 | if ((*gittag) && strcmp(gittag, "undefined") != 0) |
| 63 | gitid = gittag; |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 64 | else |
Ned Deily | 5c4b0d0 | 2017-03-04 00:19:55 -0500 | [diff] [blame] | 65 | gitid = GITBRANCH; |
| 66 | return gitid; |
Georg Brandl | 1ca2e79 | 2011-03-05 20:51:24 +0100 | [diff] [blame] | 67 | } |