buildinfo.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. Note that any passed value must contain no whitespace.
  28. */
  29. // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate=`date --iso-8601=seconds`
  30. var buildDate string
  31. // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo=`git config --get remote.origin.url`
  32. var buildRepo string
  33. // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev=`git rev-parse --short HEAD`
  34. var buildRev string
  35. // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.goVersion=`go version | perl -ne '/go version (.*?) / && print $1'`
  36. var goVersion string
  37. // -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.gomobileVersion=`gomobile version | perl -ne '/gomobile version (.*?) / && print $1'`
  38. var gomobileVersion string
  39. func EmitNoticeBuildInfo() {
  40. NoticeBuildInfo(
  41. strings.TrimSpace(buildDate),
  42. strings.TrimSpace(buildRepo),
  43. strings.TrimSpace(buildRev),
  44. strings.TrimSpace(goVersion),
  45. strings.TrimSpace(gomobileVersion))
  46. }