.go-autogen 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env bash
  2. rm -rf autogen
  3. source hack/dockerfile/binaries-commits
  4. cat > dockerversion/version_autogen.go <<DVEOF
  5. // +build autogen
  6. // Package dockerversion is auto-generated at build-time
  7. package dockerversion
  8. // Default build-time variable for library-import.
  9. // This file is overridden on build with build-time informations.
  10. const (
  11. GitCommit string = "$GITCOMMIT"
  12. Version string = "$VERSION"
  13. BuildTime string = "$BUILDTIME"
  14. IAmStatic string = "${IAMSTATIC:-true}"
  15. ContainerdCommitID string = "${CONTAINERD_COMMIT}"
  16. PlatformName string = "${PLATFORM}"
  17. )
  18. // AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
  19. DVEOF
  20. cat > dockerversion/version_autogen_unix.go <<DVEOF
  21. // +build autogen,!windows
  22. // Package dockerversion is auto-generated at build-time
  23. package dockerversion
  24. // Default build-time variable for library-import.
  25. // This file is overridden on build with build-time informations.
  26. const (
  27. RuncCommitID string = "${RUNC_COMMIT}"
  28. InitCommitID string = "${TINI_COMMIT}"
  29. )
  30. // AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
  31. DVEOF
  32. # Compile the Windows resources into the sources
  33. if [ "$(go env GOOS)" = "windows" ]; then
  34. mkdir -p autogen/winresources/tmp autogen/winresources/docker autogen/winresources/dockerd
  35. cp hack/make/.resources-windows/resources.go autogen/winresources/docker/
  36. cp hack/make/.resources-windows/resources.go autogen/winresources/dockerd/
  37. if [ "$(go env GOHOSTOS)" == "windows" ]; then
  38. WINDRES=windres
  39. WINDMC=windmc
  40. else
  41. # Cross compiling
  42. WINDRES=x86_64-w64-mingw32-windres
  43. WINDMC=x86_64-w64-mingw32-windmc
  44. fi
  45. # Generate a Windows file version of the form major,minor,patch,build (with any part optional)
  46. VERSION_QUAD=$(echo -n $VERSION | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,)
  47. # Pass version and commit information into the resource compiler
  48. defs=
  49. [ ! -z $VERSION ] && defs="$defs -D DOCKER_VERSION=\"$VERSION\""
  50. [ ! -z $VERSION_QUAD ] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD"
  51. [ ! -z $GITCOMMIT ] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\""
  52. function makeres {
  53. $WINDRES \
  54. -i hack/make/.resources-windows/$1 \
  55. -o $3 \
  56. -F $2 \
  57. --use-temp-file \
  58. -I autogen/winresources/tmp \
  59. $defs
  60. }
  61. $WINDMC \
  62. hack/make/.resources-windows/event_messages.mc \
  63. -h autogen/winresources/tmp \
  64. -r autogen/winresources/tmp
  65. makeres docker.rc pe-x86-64 autogen/winresources/docker/rsrc_amd64.syso
  66. makeres docker.rc pe-i386 autogen/winresources/docker/rsrc_386.syso
  67. makeres dockerd.rc pe-x86-64 autogen/winresources/dockerd/rsrc_amd64.syso
  68. rm -r autogen/winresources/tmp
  69. fi