github.com/xdlianrong208/docker-ce-comments@v17.12.1-ce-rc2+incompatible/components/cli/scripts/gen/windows-resources (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Compile the Windows resources into the sources
     4  #
     5  
     6  set -eu -o pipefail
     7  
     8  SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
     9  # shellcheck source=/go/src/github.com/docker/cli/scripts/build/.variables
    10  source $SCRIPTDIR/../build/.variables
    11  
    12  RESOURCES=$SCRIPTDIR/../winresources
    13  
    14  TEMPDIR=$(mktemp -d)
    15  trap 'rm -rf $TEMPDIR' EXIT
    16  
    17  if [ "$(go env GOHOSTOS)" == "windows" ]; then
    18  	WINDRES=windres
    19  else
    20  	# Cross compiling
    21  	WINDRES=x86_64-w64-mingw32-windres
    22  fi
    23  
    24  # Generate a Windows file version of the form major,minor,patch,build (with any part optional)
    25  VERSION_QUAD=$(echo -n "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,)
    26  
    27  # Pass version and commit information into the resource compiler
    28  defs=
    29  [ ! -z "$VERSION" ]      && defs+=( "-D DOCKER_VERSION=\"$VERSION\"")
    30  [ ! -z "$VERSION_QUAD" ] && defs+=( "-D DOCKER_VERSION_QUAD=$VERSION_QUAD")
    31  [ ! -z "$GITCOMMIT" ]    && defs+=( "-D DOCKER_COMMIT=\"$GITCOMMIT\"")
    32  
    33  function makeres {
    34  	"$WINDRES" \
    35  		-i "$RESOURCES/$1" \
    36  		-o "$3" \
    37  		-F "$2" \
    38  		--use-temp-file \
    39  		-I "$TEMPDIR" \
    40  		${defs[*]}
    41  }
    42  
    43  makeres docker.rc pe-x86-64 rsrc_amd64.syso
    44  makeres docker.rc pe-i386   rsrc_386.syso