github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/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=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,) 26 27 # Pass version and commit information into the resource compiler 28 defs= 29 [ -n "$VERSION" ] && defs+=( "-D DOCKER_VERSION=\"$VERSION\"") 30 [ -n "$VERSION_QUAD" ] && defs+=( "-D DOCKER_VERSION_QUAD=$VERSION_QUAD") 31 [ -n "$GITCOMMIT" ] && defs+=( "-D DOCKER_COMMIT=\"$GITCOMMIT\"") 32 33 makeres() { 34 # shellcheck disable=SC2086 35 "$WINDRES" \ 36 -i "$RESOURCES/$1" \ 37 -o "$3" \ 38 -F "$2" \ 39 --use-temp-file \ 40 -I "$TEMPDIR" \ 41 ${defs[*]} 42 } 43 44 makeres docker.rc pe-x86-64 rsrc_amd64.syso 45 makeres docker.rc pe-i386 rsrc_386.syso