• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2set -e -o pipefail
3
4# This script builds the go cross compilers for ChromeOS targets.
5#
6# Usage: build_go
7#
8# It assumes that the "x86_64-cros-linux-gnu" toolchain is already installed.
9# It assumes that the "armv7a-cros-linux-gnueabi" toolchain is already installed.
10# It assumes that the "aarch64-cros-linux-gnu" toolchain is already installed.
11
12if [[ ! -e "make.bash" && -e "src/make.bash" ]]
13then
14	cd src
15fi
16
17# Build the Go toolchain for amd64 targets.
18GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" \
19	CC_FOR_TARGET="x86_64-cros-linux-gnu-clang" \
20	CXX_FOR_TARGET="x86_64-cros-linux-gnu-clang++" \
21	./make.bash --no-clean
22GOOS="linux" GOARCH="amd64" CGO_ENABLED="1" \
23	CC="x86_64-cros-linux-gnu-clang" \
24	CXX="x86_64-cros-linux-gnu-clang++" \
25	../bin/go install -v -buildmode=pie std
26
27# Build the Go toolchain for arm targets.
28GOOS="linux" GOARCH="arm" CGO_ENABLED="1" \
29	CC_FOR_TARGET="armv7a-cros-linux-gnueabi-clang" \
30	CXX_FOR_TARGET="armv7a-cros-linux-gnueabi-clang++" \
31	./make.bash --no-clean
32GOOS="linux" GOARCH="arm" CGO_ENABLED="1" \
33	CC="armv7a-cros-linux-gnueabi-clang" \
34	CXX="armv7a-cros-linux-gnueabi-clang++" \
35	../bin/go install -v -buildmode=pie std
36
37# Build the Go toolchain for arm64 targets.
38GOOS="linux" GOARCH="arm64" CGO_ENABLED="1" \
39	CC_FOR_TARGET="aarch64-cros-linux-gnu-clang" \
40	CXX_FOR_TARGET="aarch64-cros-linux-gnu-clang++" \
41	./make.bash --no-clean
42GOOS="linux" GOARCH="arm64" CGO_ENABLED="1" \
43	CC="aarch64-cros-linux-gnu-clang" \
44	CXX="aarch64-cros-linux-gnu-clang++" \
45	../bin/go install -v -buildmode=pie std
46