buildinfo.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. ReleaseVersion string
  23. User string
  24. Host string
  25. Date string
  26. // VCS is one of "svn", "arc", "hg", "git" or ""
  27. VCS string
  28. SVNRevision string
  29. ArcadiaSourceRevision string
  30. ArcadiaSourceLastChanged string
  31. ArcadiaPatchNumber string
  32. ArcadiaSourcePath string
  33. BuildTimestamp string
  34. Hash string
  35. Tag string
  36. Dirty string
  37. Branch string
  38. }
  39. // Info holds information about current build.
  40. //
  41. // Info might not available in distributed build and when building from
  42. // IDE. Users of api must gracefully handle such cases.
  43. var Info BuildInfo
  44. // InitBuildInfo is internal, but exported API.
  45. //
  46. // This function is called from the main package by the code generated in build/scripts/vcs_info.py
  47. func InitBuildInfo(buildinfo map[string]string) {
  48. Info.ProgramVersion = strings.TrimRight(buildinfo["PROGRAM_VERSION"], " ")
  49. Info.CustomVersion = strings.TrimRight(buildinfo["CUSTOM_VERSION"], " ")
  50. Info.ReleaseVersion = strings.TrimRight(buildinfo["RELEASE_VERSION"], " ")
  51. Info.User = buildinfo["BUILD_USER"]
  52. Info.Host = buildinfo["BUILD_HOST"]
  53. Info.Date = buildinfo["BUILD_DATE"]
  54. Info.VCS = buildinfo["VCS"]
  55. Info.SVNRevision = buildinfo["ARCADIA_SOURCE_REVISION"]
  56. Info.ArcadiaSourceRevision = buildinfo["ARCADIA_SOURCE_REVISION"]
  57. Info.ArcadiaSourceLastChanged = buildinfo["ARCADIA_SOURCE_LAST_CHANGE"]
  58. Info.ArcadiaPatchNumber = buildinfo["ARCADIA_PATCH_NUMBER"]
  59. Info.ArcadiaSourcePath = buildinfo["ARCADIA_SOURCE_PATH"]
  60. Info.BuildTimestamp = buildinfo["BUILD_TIMESTAMP"]
  61. Info.Hash = buildinfo["ARCADIA_SOURCE_HG_HASH"]
  62. Info.Tag = buildinfo["ARCADIA_TAG"]
  63. Info.Dirty = buildinfo["DIRTY"]
  64. Info.Branch = buildinfo["BRANCH"]
  65. }