122a51efc1cb9b3d5c945bf90fd8906306c367604Tim Peters#include "Python.h" 249bff65deba89d13b11db725e70bfe7ae2b82f82Guido van Rossum 3ff7e83d6067814a329790cc983f1efa67371ccf8Guido van Rossum#ifndef DONT_HAVE_STDIO_H 42fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#include <stdio.h> 5ff7e83d6067814a329790cc983f1efa67371ccf8Guido van Rossum#endif 62fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum 72fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#ifndef DATE 82fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#ifdef __DATE__ 92fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#define DATE __DATE__ 102fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#else 112fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#define DATE "xx/xx/xx" 122fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#endif 132fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#endif 142fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum 152fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#ifndef TIME 162fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#ifdef __TIME__ 172fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#define TIME __TIME__ 182fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#else 192fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#define TIME "xx:xx:xx" 202fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#endif 212fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum#endif 222fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossum 23b53940f238c55c8b715301e6b5902ef2d15cfefaKristján Valur Jónsson/* on unix, SVNVERSION is passed on the command line. 24b53940f238c55c8b715301e6b5902ef2d15cfefaKristján Valur Jónsson * on Windows, the string is interpolated using 25b53940f238c55c8b715301e6b5902ef2d15cfefaKristján Valur Jónsson * subwcrev.exe 26b53940f238c55c8b715301e6b5902ef2d15cfefaKristján Valur Jónsson */ 27b53940f238c55c8b715301e6b5902ef2d15cfefaKristján Valur Jónsson#ifndef SVNVERSION 28d078e40d416566d3a88bc47c2df180c85d5e339fMartin v. Löwis#define SVNVERSION "$WCRANGE$$WCMODS?M:$" 29b53940f238c55c8b715301e6b5902ef2d15cfefaKristján Valur Jónsson#endif 30b53940f238c55c8b715301e6b5902ef2d15cfefaKristján Valur Jónsson 313a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl/* XXX Only unix build process has been tested */ 323a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#ifndef HGVERSION 333a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#define HGVERSION "" 343a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#endif 353a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#ifndef HGTAG 363a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#define HGTAG "" 373a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#endif 383a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#ifndef HGBRANCH 393a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#define HGBRANCH "" 403a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl#endif 413a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl 422fff2e6b05b8eb11898186f218d1656ec64a6091Guido van Rossumconst char * 43a3bdc2c2a5dbb6fd7f7f655f6970f7559dca0497Barry WarsawPy_GetBuildInfo(void) 442a38a86c1c48adbf9cf76d485c515002f042fd56Barry Warsaw{ 4541a9ec90030ad29fadba44eb44cc002d1c2cb153Benjamin Peterson static char buildinfo[50 + sizeof(HGVERSION) + 4641a9ec90030ad29fadba44eb44cc002d1c2cb153Benjamin Peterson ((sizeof(HGTAG) > sizeof(HGBRANCH)) ? 4741a9ec90030ad29fadba44eb44cc002d1c2cb153Benjamin Peterson sizeof(HGTAG) : sizeof(HGBRANCH))]; 483a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl const char *revision = _Py_hgversion(); 49c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou const char *sep = *revision ? ":" : ""; 503a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl const char *hgid = _Py_hgidentifier(); 513a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl if (!(*hgid)) 523a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl hgid = "default"; 53c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou PyOS_snprintf(buildinfo, sizeof(buildinfo), 543a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl "%s%s%s, %.20s, %.9s", hgid, sep, revision, 55c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou DATE, TIME); 56c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou return buildinfo; 572a38a86c1c48adbf9cf76d485c515002f042fd56Barry Warsaw} 58ce3a9131c37dc8e968156864e73e1ff544cf7eceBarry Warsaw 59ce3a9131c37dc8e968156864e73e1ff544cf7eceBarry Warsawconst char * 6043b57805fbc9b500f0b4239fd925868b26475f35Martin v. Löwis_Py_svnversion(void) 61ce3a9131c37dc8e968156864e73e1ff544cf7eceBarry Warsaw{ 62c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou /* the following string can be modified by subwcrev.exe */ 63c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou static const char svnversion[] = SVNVERSION; 64c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou if (svnversion[0] != '$') 65c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou return svnversion; /* it was interpolated, or passed on command line */ 66c83ea137d7e717f764e2f31fc2544f522de7d857Antoine Pitrou return "Unversioned directory"; 67ce3a9131c37dc8e968156864e73e1ff544cf7eceBarry Warsaw} 683a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl 693a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandlconst char * 703a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl_Py_hgversion(void) 713a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl{ 723a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl return HGVERSION; 733a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl} 743a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl 753a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandlconst char * 763a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl_Py_hgidentifier(void) 773a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl{ 783a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl const char *hgtag, *hgid; 793a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl hgtag = HGTAG; 803a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl if ((*hgtag) && strcmp(hgtag, "tip") != 0) 813a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl hgid = hgtag; 823a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl else 833a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl hgid = HGBRANCH; 843a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl return hgid; 853a5508e2c075405f35b5c32f413445b9e875c92cGeorg Brandl} 86