github.com/ali-iotechsys/cli@v20.10.0+incompatible/scripts/build/cross (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Build a binary for all supported platforms
     4  #
     5  
     6  set -eu -o pipefail
     7  
     8  BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
     9  export SHELL=bash
    10  
    11  jobs=(
    12      "$BUILDDIR/windows" \
    13      "$BUILDDIR/osx" \
    14      "GOOS=linux GOARCH=amd64   $BUILDDIR/binary" \
    15      "GOOS=linux GOARCH=arm     $BUILDDIR/binary" \
    16      "GOOS=linux GOARCH=ppc64le $BUILDDIR/binary" \
    17      "GOOS=linux GOARCH=s390x   $BUILDDIR/binary" \
    18  )
    19  
    20  # Outside of circleCI run all at once. On circleCI run two at a time because
    21  # each container has access to two cores.
    22  group=${CROSS_GROUP-"all"}
    23  
    24  if [ "$group" = "all" ]; then
    25  
    26      echo "Building binaries for all platforms"
    27      parallel ::: "${jobs[@]}"
    28      exit 0
    29  
    30  fi
    31  
    32  declare -i start="$group*2"
    33  parallel ::: "${jobs[@]:$start:2}"