github.com/dolfly/pty@v1.2.1/test_crosscompile.sh (about)

     1  #!/usr/bin/env sh
     2  
     3  # Test script checking that all expected os/arch compile properly.
     4  # Does not actually test the logic, just the compilation so we make sure we don't break code depending on the lib.
     5  
     6  echo2() {
     7      echo $@ >&2
     8  }
     9  
    10  trap end 0
    11  end() {
    12      [ "$?" = 0 ] && echo2 "Pass." || (echo2 "Fail."; exit 1)
    13  }
    14  
    15  cross() {
    16      os=$1
    17      shift
    18      echo2 "Build for $os."
    19      for arch in $@; do
    20        echo2 "  - $os/$arch"
    21        GOOS=$os GOARCH=$arch go build
    22      done
    23      echo2
    24  }
    25  
    26  set -e
    27  
    28  cross linux     amd64 386 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le
    29  cross darwin    amd64 arm64
    30  cross freebsd   amd64 386 arm arm64
    31  cross netbsd    amd64 386 arm arm64
    32  cross openbsd   amd64 386 arm arm64
    33  cross dragonfly amd64
    34  cross solaris   amd64
    35  cross windows   amd64 386 arm
    36  
    37  # TODO: Fix compilation error on openbsd/arm.
    38  # TODO: Merge the solaris PR.
    39  
    40  # Some os/arch require a different compiler. Run in docker.
    41  if ! hash docker; then
    42      # If docker is not present, stop here.
    43      return
    44  fi
    45  
    46  echo2 "Build for linux."
    47  echo2 "  - linux/riscv"
    48  docker build -t creack-pty-test -f Dockerfile.riscv .
    49  
    50  # Golang dropped support for darwin 32bits since go1.15. Make sure the lib still compile with go1.14 on those archs.
    51  echo2 "Build for darwin (32bits)."
    52  echo2 "  - darwin/386"
    53  docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.14 --build-arg=GOOS=darwin --build-arg=GOARCH=386 .
    54  echo2 "  - darwin/arm"
    55  docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.14 --build-arg=GOOS=darwin --build-arg=GOARCH=arm .
    56  
    57  # Run a single test for an old go version. Would be best with go1.0, but not available on Dockerhub.
    58  # Using 1.6 as it is the base version for the RISCV compiler.
    59  # Would also be better to run all the tests, not just one, need to refactor this file to allow for specifc archs per version.
    60  echo2 "Build for linux - go1.6."
    61  echo2 "  - linux/amd64"
    62  docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.6 --build-arg=GOOS=linux --build-arg=GOARCH=amd64 .