buildinfo.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2015, Psiphon Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. package psiphon
  20. import "strings"
  21. /*
  22. These values should be filled in at build time using the `-X` option[1] to the
  23. Go linker (probably via `-ldflags` option to `go build` -- like `-ldflags "-X var1 abc -X var2 xyz"`).
  24. [1]: http://golang.org/cmd/ld/
  25. Without those build flags, the build info in the notice will simply be empty strings.
  26. Suggestions for how to fill in the values will be given for each variable.
  27. */
  28. // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate `date --iso-8601=seconds`
  29. var buildDate string
  30. // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo `git config --get remote.origin.url`
  31. var buildRepo string
  32. // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev `git rev-parse HEAD`
  33. var buildRev string
  34. func NoticeBuildInfo() {
  35. NoticeInfo(
  36. "Built: %#v from %#v at rev %#v",
  37. strings.TrimSpace(buildDate),
  38. strings.TrimSpace(buildRepo),
  39. strings.TrimSpace(buildRev))
  40. }