Text file src/crypto/internal/boring/build.sh

     1  #!/bin/bash
     2  # Copyright 2022 The Go Authors. All rights reserved.
     3  # Use of this source code is governed by a BSD-style
     4  # license that can be found in the LICENSE file.
     5  
     6  # This shell script uses Docker to run build-boring.sh and build-goboring.sh,
     7  # which build goboringcrypto_linux_$GOARCH.syso according to the Security Policy.
     8  # Currently, amd64 and arm64 are permitted.
     9  
    10  set -e
    11  set -o pipefail
    12  
    13  GOARCH=${GOARCH:-$(go env GOARCH)}
    14  echo "# Building goboringcrypto_linux_$GOARCH.syso. Set GOARCH to override." >&2
    15  
    16  if ! which docker >/dev/null; then
    17  	echo "# Docker not found. Inside Google, see go/installdocker." >&2
    18  	exit 1
    19  fi
    20  
    21  platform=""
    22  buildargs=""
    23  case "$GOARCH" in
    24  amd64)
    25  	if ! docker run --rm -t amd64/ubuntu:focal uname -m >/dev/null 2>&1; then
    26  		echo "# Docker cannot run amd64 binaries."
    27  		exit 1
    28  	fi
    29  	platform="--platform linux/amd64"
    30  	buildargs="--build-arg ubuntu=amd64/ubuntu"
    31  	;;
    32  arm64)
    33  	if ! docker run --rm -t arm64v8/ubuntu:focal uname -m >/dev/null 2>&1; then
    34  		echo "# Docker cannot run arm64 binaries. Try:"
    35  		echo "	sudo apt-get install qemu binfmt-support qemu-user-static"
    36  		echo "	docker run --rm --privileged multiarch/qemu-user-static --reset -p yes"
    37  		echo "	docker run --rm -t arm64v8/ubuntu:focal uname -m"
    38  		exit 1
    39  	fi
    40  	platform="--platform linux/arm64/v8"
    41  	buildargs="--build-arg ubuntu=arm64v8/ubuntu"
    42  	;;
    43  *)
    44  	echo unknown GOARCH $GOARCH >&2
    45  	exit 2
    46  esac
    47  
    48  docker build $platform $buildargs --build-arg GOARCH=$GOARCH -t goboring:$GOARCH .
    49  id=$(docker create $platform goboring:$GOARCH)
    50  docker cp $id:/boring/godriver/goboringcrypto_linux_$GOARCH.syso ./syso
    51  docker rm $id
    52  ls -l ./syso/goboringcrypto_linux_$GOARCH.syso
    53  

View as plain text