github.com/sams1990/dockerrepo@v17.12.1-ce-rc2+incompatible/hack/make/.go-autogen (about)

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