svn_interface.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // Used indirectly. See build/scripts/vcs_info.py
  2. // ya-bin dump vcs-info > vcs.json
  3. // python build/scripts/vcs_info.py vcs.json out.c build/scripts/c_templates/svn_interface.c <any_prefix>library/cpp/svnversion<any_suffix>
  4. #include "build/scripts/c_templates/svnversion.h"
  5. #define STR1(x) #x
  6. #define STR2(x) STR1(x)
  7. const char* GetProgramSvnVersion() {
  8. #if defined(REVISION)
  9. // for package systems generating from svn export but providing REVISION macro
  10. #define STRREVISION STR2(REVISION)
  11. #define REVISIONINFO "r" STRREVISION
  12. #if defined(PROGRAM_VERSION)
  13. return PROGRAM_VERSION "\n\n" REVISIONINFO;
  14. #else
  15. return REVISIONINFO " "__DATE__
  16. " "__TIME__;
  17. #endif
  18. #elif defined(PROGRAM_VERSION)
  19. return PROGRAM_VERSION;
  20. #else
  21. return "No program version found";
  22. #endif
  23. }
  24. const char* GetArcadiaSourcePath() {
  25. #if defined(ARCADIA_SOURCE_PATH)
  26. return ARCADIA_SOURCE_PATH;
  27. #else
  28. return "";
  29. #endif
  30. }
  31. const char* GetArcadiaSourceUrl() {
  32. #if defined(ARCADIA_SOURCE_URL)
  33. return ARCADIA_SOURCE_URL;
  34. #else
  35. return "";
  36. #endif
  37. }
  38. int GetArcadiaLastChangeNum() {
  39. #if defined(ARCADIA_SOURCE_LAST_CHANGE)
  40. return ARCADIA_SOURCE_LAST_CHANGE;
  41. #else
  42. return 0;
  43. #endif
  44. }
  45. const char* GetArcadiaLastChange() {
  46. #if defined(ARCADIA_SOURCE_LAST_CHANGE)
  47. return STR2(ARCADIA_SOURCE_LAST_CHANGE);
  48. #else
  49. return "";
  50. #endif
  51. }
  52. const char* GetArcadiaLastAuthor() {
  53. #if defined(ARCADIA_SOURCE_LAST_AUTHOR)
  54. return ARCADIA_SOURCE_LAST_AUTHOR;
  55. #else
  56. return "";
  57. #endif
  58. }
  59. int GetProgramSvnRevision() {
  60. #if defined(ARCADIA_SOURCE_REVISION)
  61. return ARCADIA_SOURCE_REVISION;
  62. #else
  63. return 0;
  64. #endif
  65. }
  66. const char* GetVCSDirty()
  67. {
  68. #if defined(DIRTY)
  69. return DIRTY;
  70. #else
  71. return 0;
  72. #endif
  73. }
  74. const char* GetProgramHash() {
  75. #if defined(ARCADIA_SOURCE_HG_HASH)
  76. return ARCADIA_SOURCE_HG_HASH;
  77. #else
  78. return "";
  79. #endif
  80. }
  81. const char* GetProgramCommitId() {
  82. #if defined(ARCADIA_SOURCE_REVISION)
  83. if (ARCADIA_SOURCE_REVISION <= 0) {
  84. return GetProgramHash();
  85. }
  86. return STR2(ARCADIA_SOURCE_REVISION);
  87. #else
  88. return GetProgramHash();
  89. #endif
  90. }
  91. const char* GetProgramScmData() {
  92. #if defined(SCM_DATA)
  93. return SCM_DATA;
  94. #else
  95. return "";
  96. #endif
  97. }
  98. const char* GetProgramShortVersionData() {
  99. #if defined(SVN_REVISION) && defined(SVN_TIME)
  100. return STR2(SVN_REVISION) " (" SVN_TIME ")";
  101. #else
  102. return GetProgramHash();
  103. #endif
  104. }
  105. const char* GetProgramBuildUser() {
  106. #if defined(BUILD_USER)
  107. return BUILD_USER;
  108. #else
  109. return "";
  110. #endif
  111. }
  112. const char* GetProgramBuildHost() {
  113. #if defined(BUILD_HOST)
  114. return BUILD_HOST;
  115. #else
  116. return "";
  117. #endif
  118. }
  119. const char* GetProgramBuildDate() {
  120. #if defined(BUILD_DATE)
  121. return BUILD_DATE;
  122. #else
  123. return "";
  124. #endif
  125. }
  126. const char* GetCustomVersion() {
  127. #if defined(CUSTOM_VERSION)
  128. return CUSTOM_VERSION;
  129. #else
  130. return "";
  131. #endif
  132. }
  133. int GetProgramBuildTimestamp() {
  134. #if defined(BUILD_TIMESTAMP)
  135. return BUILD_TIMESTAMP;
  136. #else
  137. return 0;
  138. #endif
  139. }
  140. const char* GetVCS() {
  141. #if defined(VCS)
  142. return VCS;
  143. #else
  144. return "";
  145. #endif
  146. }
  147. const char* GetBranch() {
  148. #if defined(BRANCH)
  149. return BRANCH;
  150. #else
  151. return "";
  152. #endif
  153. }
  154. int GetArcadiaPatchNumber() {
  155. #if defined(ARCADIA_PATCH_NUMBER)
  156. return ARCADIA_PATCH_NUMBER;
  157. #else
  158. return 42;
  159. #endif
  160. }
  161. const char* GetTag() {
  162. #if defined(ARCADIA_TAG)
  163. return ARCADIA_TAG;
  164. #else
  165. return "";
  166. #endif
  167. }