Skip to content

Commit

Permalink
Refactored binary build shell invocation
Browse files Browse the repository at this point in the history
By changing the amount of code that is literally contained
in the sub-shell `()` braces, we allow the stacktrace that
is generated to contain much less text on any one line, so
that it is read-able and useful. Furthermore, by naming the
positional variables we pass around we allow the new stack
trace code to correctly evaluate them and show us what went
wrong, exactly.

Signed-off-by: Steve Kuznetsov <[email protected]>
  • Loading branch information
stevekuznetsov committed Jun 15, 2016
1 parent 39326a0 commit 62e2e0a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,27 @@ function os::build::build_static_binaries() {
}
readonly -f os::build::build_static_binaries

# Build binaries targets specified
# Build binary targets specified
#
# Input:
# $@ - targets and go flags. If no targets are set then all binaries targets
# are built.
# OS_BUILD_PLATFORMS - Incoming variable of targets to build for. If unset
# then just the host architecture is built.
function os::build::build_binaries() {
local -a binaries=( "$@" )
# Create a sub-shell so that we don't pollute the outer environment
(
( os::build::internal::build_binaries "${binaries[@]+"${binaries[@]}"}" )
}

# Build binary targets specified. Should always be run in a sub-shell so we don't leak GOBIN
#
# Input:
# $@ - targets and go flags. If no targets are set then all binaries targets
# are built.
# OS_BUILD_PLATFORMS - Incoming variable of targets to build for. If unset
# then just the host architecture is built.
os::build::internal::build_binaries() {
# Check for `go` binary and set ${GOPATH}.
os::build::setup_env

Expand Down Expand Up @@ -325,7 +336,6 @@ function os::build::build_binaries() {
"$(dirname ${test})"
done
done
)
}
readonly -f os::build::build_binaries

Expand Down

0 comments on commit 62e2e0a

Please sign in to comment.