You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.2 KiB

  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. /* XXX Only unix build process has been tested */
  20. #ifndef HGVERSION
  21. #define HGVERSION ""
  22. #endif
  23. #ifndef HGTAG
  24. #define HGTAG ""
  25. #endif
  26. #ifndef HGBRANCH
  27. #define HGBRANCH ""
  28. #endif
  29. const char *
  30. Py_GetBuildInfo(void)
  31. {
  32. static char buildinfo[50 + sizeof(HGVERSION) +
  33. ((sizeof(HGTAG) > sizeof(HGBRANCH)) ?
  34. sizeof(HGTAG) : sizeof(HGBRANCH))];
  35. const char *revision = _Py_hgversion();
  36. const char *sep = *revision ? ":" : "";
  37. const char *hgid = _Py_hgidentifier();
  38. if (!(*hgid))
  39. hgid = "default";
  40. PyOS_snprintf(buildinfo, sizeof(buildinfo),
  41. "%s%s%s, %.20s, %.9s", hgid, sep, revision,
  42. DATE, TIME);
  43. return buildinfo;
  44. }
  45. const char *
  46. _Py_hgversion(void)
  47. {
  48. return HGVERSION;
  49. }
  50. const char *
  51. _Py_hgidentifier(void)
  52. {
  53. const char *hgtag, *hgid;
  54. hgtag = HGTAG;
  55. if ((*hgtag) && strcmp(hgtag, "tip") != 0)
  56. hgid = hgtag;
  57. else
  58. hgid = HGBRANCH;
  59. return hgid;
  60. }