buildinfo.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package buildinfo
  2. import "strings"
  3. type BuildInfo struct {
  4. // ProgramVersion is multiline string completely describing
  5. // version of current binary.
  6. //
  7. // Svn info:
  8. // URL: svn+ssh://arcadia.yandex.ru/arc/trunk/arcadia
  9. // Last Changed Rev: 4479764
  10. // Last Changed Author: robot-yappy
  11. // Last Changed Date: 2019-02-19 16:33:55 +0300 (Tue, 19 Feb 2019)
  12. //
  13. // Other info:
  14. // Build by: prime
  15. // Top src dir: /home/prime/Code/go/src/a.yandex-team.ru
  16. // Top build dir: /home/prime/.ya/build/build_root/qbh0/000002
  17. // Hostname: 77.88.18.146-red.dhcp.yndx.net
  18. // Host information:
  19. // Linux 77.88.18.146-red.dhcp.yndx.net 4.19.10-300.fc29.x86_64 #1 SMP Mon Dec 17 15:34:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  20. ProgramVersion string
  21. CustomVersion string
  22. User string
  23. Host string
  24. Date string
  25. // VCS is one of "svn", "arc", "hg", "git" or ""
  26. VCS string
  27. SVNRevision string
  28. ArcadiaSourceRevision string
  29. ArcadiaSourceLastChanged string
  30. ArcadiaPatchNumber string
  31. ArcadiaSourcePath string
  32. BuildTimestamp string
  33. Hash string
  34. Tag string
  35. Dirty string
  36. Branch string
  37. }
  38. // Info holds information about current build.
  39. //
  40. // Info might not available in distributed build and when building from
  41. // IDE. Users of api must gracefully handle such cases.
  42. var Info BuildInfo
  43. // InitBuildInfo is internal, but exported API.
  44. //
  45. // This function is called from the main package by the code generated in build/scripts/vcs_info.py
  46. func InitBuildInfo(buildinfo map[string]string) {
  47. Info.ProgramVersion = strings.TrimRight(buildinfo["PROGRAM_VERSION"], " ")
  48. Info.CustomVersion = strings.TrimRight(buildinfo["CUSTOM_VERSION"], " ")
  49. Info.User = buildinfo["BUILD_USER"]
  50. Info.Host = buildinfo["BUILD_HOST"]
  51. Info.Date = buildinfo["BUILD_DATE"]
  52. Info.VCS = buildinfo["VCS"]
  53. Info.SVNRevision = buildinfo["ARCADIA_SOURCE_REVISION"]
  54. Info.ArcadiaSourceRevision = buildinfo["ARCADIA_SOURCE_REVISION"]
  55. Info.ArcadiaSourceLastChanged = buildinfo["ARCADIA_SOURCE_LAST_CHANGE"]
  56. Info.ArcadiaPatchNumber = buildinfo["ARCADIA_PATCH_NUMBER"]
  57. Info.ArcadiaSourcePath = buildinfo["ARCADIA_SOURCE_PATH"]
  58. Info.BuildTimestamp = buildinfo["BUILD_TIMESTAMP"]
  59. Info.Hash = buildinfo["ARCADIA_SOURCE_HG_HASH"]
  60. Info.Tag = buildinfo["ARCADIA_TAG"]
  61. Info.Dirty = buildinfo["DIRTY"]
  62. Info.Branch = buildinfo["BRANCH"]
  63. }