/Modules/getbuildinfo.c

http://unladen-swallow.googlecode.com/ · C · 52 lines · 41 code · 6 blank · 5 comment · 2 complexity · 6f595eb7a6060f1a57b8a49193fa0529 MD5 · raw file

  1. #include "Python.h"
  2. #ifndef DONT_HAVE_STDIO_H
  3. #include <stdio.h>
  4. #endif
  5. #ifndef DATE
  6. #ifdef __DATE__
  7. #define DATE __DATE__
  8. #else
  9. #define DATE "xx/xx/xx"
  10. #endif
  11. #endif
  12. #ifndef TIME
  13. #ifdef __TIME__
  14. #define TIME __TIME__
  15. #else
  16. #define TIME "xx:xx:xx"
  17. #endif
  18. #endif
  19. /* on unix, SVNVERSION is passed on the command line.
  20. * on Windows, the string is interpolated using
  21. * subwcrev.exe
  22. */
  23. #ifndef SVNVERSION
  24. #define SVNVERSION "$WCRANGE$$WCMODS?M:$"
  25. #endif
  26. const char *
  27. Py_GetBuildInfo(void)
  28. {
  29. static char buildinfo[50];
  30. const char *revision = Py_SubversionRevision();
  31. const char *sep = *revision ? ":" : "";
  32. const char *branch = Py_SubversionShortBranch();
  33. PyOS_snprintf(buildinfo, sizeof(buildinfo),
  34. "%s%s%s, %.20s, %.9s", branch, sep, revision,
  35. DATE, TIME);
  36. return buildinfo;
  37. }
  38. const char *
  39. _Py_svnversion(void)
  40. {
  41. /* the following string can be modified by subwcrev.exe */
  42. static const char svnversion[] = SVNVERSION;
  43. if (svnversion[0] != '$')
  44. return svnversion; /* it was interpolated, or passed on command line */
  45. return "Unversioned directory";
  46. }