.go-autogen 2.6 KB

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