blob: a1a7b7ac33447d8d35bf864db27452a1bdeb1aca [file] [log] [blame]
Jacob Kopczynski933a6f12020-05-20 13:43:08 -07001#!/bin/bash -e
Jacob Kopczynski933a6f12020-05-20 13:43:08 -07002# 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.
9readonly GOHOME="${HOME}/go"
10
11# Directory where compiled packages are cached.
12readonly PKGDIR="${GOHOME}/pkg"
13
14###
15### Customize these parts
16###
17
18# Go workspaces containing the source.
19readonly SRCDIRS=(
20 "${HOME}/trunk/infra/tnull"
21)
22# Package to build to produce executable.
23readonly PKG="tnull"
24# Output filename for executable.
25readonly OUT="${GOHOME}/bin/tnull"
26
27###
28### End customized parts
29###
30
31# Readonly Go workspaces containing emerged source to build.
32export GOPATH="$(IFS=:; echo "${SRCDIRS[*]}"):/usr/lib/gopath"
33
34readonly CMD=$(basename "${0}")
35
36# Builds an executable package to a destination path.
37run_build() {
38 local pkg="${1}"
39 local dest="${2}"
40 go build -i -pkgdir "${PKGDIR}" -o "${dest}" "${pkg}"
41}
42
43run_build "${PKG}" "${OUT}"