Branch data Line data Source code
1 : : #include "Python.h" 2 : : 3 : : #ifndef DONT_HAVE_STDIO_H 4 : : #include <stdio.h> 5 : : #endif 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 : : 23 : : /* XXX Only unix build process has been tested */ 24 : : #ifndef GITVERSION 25 : : #define GITVERSION "" 26 : : #endif 27 : : #ifndef GITTAG 28 : : #define GITTAG "" 29 : : #endif 30 : : #ifndef GITBRANCH 31 : : #define GITBRANCH "" 32 : : #endif 33 : : 34 : : static int initialized = 0; 35 : : static char buildinfo[50 + sizeof(GITVERSION) + 36 : : ((sizeof(GITTAG) > sizeof(GITBRANCH)) ? 37 : : sizeof(GITTAG) : sizeof(GITBRANCH))]; 38 : : 39 : : const char * 40 : 29 : Py_GetBuildInfo(void) 41 : : { 42 [ - + ]: 29 : if (initialized) { 43 : 0 : return buildinfo; 44 : : } 45 : 29 : initialized = 1; 46 : 29 : const char *revision = _Py_gitversion(); 47 [ + - ]: 29 : const char *sep = *revision ? ":" : ""; 48 : 29 : const char *gitid = _Py_gitidentifier(); 49 [ - + ]: 29 : if (!(*gitid)) { 50 : 0 : gitid = "main"; 51 : : } 52 : 29 : PyOS_snprintf(buildinfo, sizeof(buildinfo), 53 : : "%s%s%s, %.20s, %.9s", gitid, sep, revision, 54 : : DATE, TIME); 55 : 29 : return buildinfo; 56 : : } 57 : : 58 : : const char * 59 : 58 : _Py_gitversion(void) 60 : : { 61 : 58 : return GITVERSION; 62 : : } 63 : : 64 : : const char * 65 : 58 : _Py_gitidentifier(void) 66 : : { 67 : : const char *gittag, *gitid; 68 : 58 : gittag = GITTAG; 69 [ + - + - ]: 58 : if ((*gittag) && strcmp(gittag, "undefined") != 0) 70 : 58 : gitid = gittag; 71 : : else 72 : 0 : gitid = GITBRANCH; 73 : 58 : return gitid; 74 : : }