go.ketch.com/lib/goja@v0.0.1/scripts/buildgo.sh (about)

     1  #!/usr/bin/env sh
     2  
     3  # Code generated by shipbuilder init 1.21.2. DO NOT EDIT.
     4  
     5  system_goos=$(go env GOOS)
     6  system_goarch=$(go env GOARCH)
     7  
     8  if [ ! -f "./scripts/check.sh" ]; then
     9    cd $(command dirname -- "$(command readlink -f "$(command -v -- "$0")")")/..
    10  fi
    11  
    12  if [ -f "./features/shipbuilder/.env" ]; then
    13    . ./features/shipbuilder/.env
    14  fi
    15  
    16  . ./scripts/check.sh
    17  
    18  export CGO_ENABLED="${shipbuilder_go_cgo_enabled:-0}"
    19  export GOPRIVATE="go.ketch.com"
    20  
    21  if [ -d "./cmd" ]; then
    22    check go
    23  
    24    set -e
    25  
    26    if [ -z "$*" ]; then
    27      oses="${shipbuilder_go_os:-darwin}"
    28    else
    29      oses=$*
    30    fi
    31  
    32    cmds=$(find cmd -type d -maxdepth 1 -mindepth 1 | cut -f2- -d/)
    33  
    34    for os in $oses; do
    35      export GOOS="$os"
    36  
    37      case "$GOOS" in
    38      "linux")
    39        arches="${shipbuilder_go_linux_arch:-amd64}"
    40        ;;
    41  
    42      "windows")
    43        arches="${shipbuilder_go_windows_arch:-amd64}"
    44        ;;
    45  
    46      "darwin")
    47        arches="${shipbuilder_go_darwin_arch:-amd64}"
    48        ;;
    49  
    50      *)
    51        echo "$GOOS is not supported"
    52        ;;
    53      esac
    54  
    55      for arch in $arches; do
    56        export GOARCH="$arch"
    57  
    58        echo "Building for $GOOS $GOARCH..."
    59        for i in $cmds; do
    60          echo "|- $i"
    61          $go build -o "./.build/$GOOS-$GOARCH/$i" "./cmd/$i/main.go"
    62  
    63          if [ "$GOOS" = "darwin" -a "$GOARCH" = "$system_goarch" ]; then
    64            echo "|--> copied to ~/go/bin"
    65            mkdir -p $HOME/go/bin
    66            cp "./.build/$GOOS-$GOARCH/$i" "$HOME/go/bin/$i" || true
    67          fi
    68        done
    69  
    70        if [ -d "./test/smoketest" ]; then
    71          # Build the smoketest
    72          echo "\- smoketest"
    73          $go test -c -o "./.build/$GOOS-$GOARCH/smoke.test" -json -failfast --tags smoke ./test/smoketest/...
    74        fi
    75      done
    76    done
    77  else
    78    go build ./...
    79  fi