| #!/bin/bash -e |
| |
| # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Minimal Go build script for an executable within a Chrome OS chroot. |
| |
| # Personal Go workspace used to cache compiled packages. |
| readonly GOHOME="${HOME}/go" |
| |
| # Directory where compiled packages are cached. |
| readonly PKGDIR="${GOHOME}/pkg" |
| |
| ### |
| ### Customize these parts |
| ### |
| |
| # Go workspaces containing the source. |
| readonly SRCDIRS=( |
| "${HOME}/trunk/infra/tnull" |
| ) |
| # Package to build to produce executable. |
| readonly PKG="tnull" |
| # Output filename for executable. |
| readonly OUT="${GOHOME}/bin/tnull" |
| |
| ### |
| ### End customized parts |
| ### |
| |
| # Readonly Go workspaces containing emerged source to build. |
| export GOPATH="$(IFS=:; echo "${SRCDIRS[*]}"):/usr/lib/gopath" |
| |
| readonly CMD=$(basename "${0}") |
| |
| # Builds an executable package to a destination path. |
| run_build() { |
| local pkg="${1}" |
| local dest="${2}" |
| go build -i -pkgdir "${PKGDIR}" -o "${dest}" "${pkg}" |
| } |
| |
| run_build "${PKG}" "${OUT}" |