Jacob Kopczynski | 933a6f1 | 2020-05-20 13:43:08 -0700 | [diff] [blame] | 1 | #!/bin/bash -e |
Jacob Kopczynski | 933a6f1 | 2020-05-20 13:43:08 -0700 | [diff] [blame] | 2 | # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | # Minimal Go build script for an executable within a Chrome OS chroot. |
| 7 | |
| 8 | # Personal Go workspace used to cache compiled packages. |
| 9 | readonly GOHOME="${HOME}/go" |
| 10 | |
| 11 | # Directory where compiled packages are cached. |
| 12 | readonly PKGDIR="${GOHOME}/pkg" |
| 13 | |
| 14 | ### |
| 15 | ### Customize these parts |
| 16 | ### |
| 17 | |
| 18 | # Go workspaces containing the source. |
| 19 | readonly SRCDIRS=( |
| 20 | "${HOME}/trunk/infra/tnull" |
| 21 | ) |
| 22 | # Package to build to produce executable. |
| 23 | readonly PKG="tnull" |
| 24 | # Output filename for executable. |
| 25 | readonly OUT="${GOHOME}/bin/tnull" |
| 26 | |
| 27 | ### |
| 28 | ### End customized parts |
| 29 | ### |
| 30 | |
| 31 | # Readonly Go workspaces containing emerged source to build. |
| 32 | export GOPATH="$(IFS=:; echo "${SRCDIRS[*]}"):/usr/lib/gopath" |
| 33 | |
| 34 | readonly CMD=$(basename "${0}") |
| 35 | |
| 36 | # Builds an executable package to a destination path. |
| 37 | run_build() { |
| 38 | local pkg="${1}" |
| 39 | local dest="${2}" |
| 40 | go build -i -pkgdir "${PKGDIR}" -o "${dest}" "${pkg}" |
| 41 | } |
| 42 | |
| 43 | run_build "${PKG}" "${OUT}" |