From 0bbf4e99f621b614b0f64cee540f09b2d70f6b8f Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Wed, 1 Apr 2015 17:31:15 -0700 Subject: [PATCH] Re tab-ify golang.sh --- hack/lib/golang.sh | 80 +++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index 54ad20a8dc0..111a6a0a595 100644 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -316,61 +316,61 @@ kube::golang::build_binaries() { kube::log::status "Building go targets for ${platforms[@]} in parallel (output will appear in a burst when complete):" "${targets[@]}" local platform for platform in "${platforms[@]}"; do ( - kube::golang::set_platform_envs "${platform}" - kube::log::status "${platform}: Parallel go build started" - - local -a statics=() - local -a nonstatics=() - for binary in "${binaries[@]}"; do - if kube::golang::is_statically_linked_library "${binary}"; then - kube::golang::exit_if_stdlib_not_installed; - statics+=($binary) - else - nonstatics+=($binary) - fi - done - - if [[ -n ${use_go_build:-} ]]; then - # Try and replicate the native binary placement of go install without - # calling go install. This means we have to iterate each binary. - local output_path="${KUBE_GOPATH}/bin" - if [[ $platform != $host_platform ]]; then - output_path="${output_path}/${platform//\//_}" - fi + kube::golang::set_platform_envs "${platform}" + kube::log::status "${platform}: Parallel go build started" + local -a statics=() + local -a nonstatics=() for binary in "${binaries[@]}"; do - local bin=$(basename "${binary}") - if [[ ${GOOS} == "windows" ]]; then - bin="${bin}.exe" - fi - if kube::golang::is_statically_linked_library "${binary}"; then kube::golang::exit_if_stdlib_not_installed; - CGO_ENABLED=0 go build -installsuffix cgo -o "${output_path}/${bin}" \ - "${goflags[@]:+${goflags[@]}}" \ - -ldflags "${version_ldflags}" \ - "${binary}" + statics+=($binary) else - go build -o "${output_path}/${bin}" \ - "${goflags[@]:+${goflags[@]}}" \ - -ldflags "${version_ldflags}" \ - "${binary}" + nonstatics+=($binary) fi done - else + + if [[ -n ${use_go_build:-} ]]; then + # Try and replicate the native binary placement of go install without + # calling go install. This means we have to iterate each binary. + local output_path="${KUBE_GOPATH}/bin" + if [[ $platform != $host_platform ]]; then + output_path="${output_path}/${platform//\//_}" + fi + + for binary in "${binaries[@]}"; do + local bin=$(basename "${binary}") + if [[ ${GOOS} == "windows" ]]; then + bin="${bin}.exe" + fi + + if kube::golang::is_statically_linked_library "${binary}"; then + kube::golang::exit_if_stdlib_not_installed; + CGO_ENABLED=0 go build -installsuffix cgo -o "${output_path}/${bin}" \ + "${goflags[@]:+${goflags[@]}}" \ + -ldflags "${version_ldflags}" \ + "${binary}" + else + go build -o "${output_path}/${bin}" \ + "${goflags[@]:+${goflags[@]}}" \ + -ldflags "${version_ldflags}" \ + "${binary}" + fi + done + else # Use go install. if [[ "${#nonstatics[@]}" != 0 ]]; then go install "${goflags[@]:+${goflags[@]}}" \ - -ldflags "${version_ldflags}" \ - "${nonstatics[@]:+${nonstatics[@]}}" + -ldflags "${version_ldflags}" \ + "${nonstatics[@]:+${nonstatics[@]}}" fi if [[ "${#statics[@]}" != 0 ]]; then CGO_ENABLED=0 go install -installsuffix cgo "${goflags[@]:+${goflags[@]}}" \ -ldflags "${version_ldflags}" \ - "${statics[@]:+${statics[@]}}" + "${statics[@]:+${statics[@]}}" fi - fi - kube::log::status "${platform}: Parallel go build finished" + fi + kube::log::status "${platform}: Parallel go build finished" ) &> "/tmp//${platform//\//_}.build" & done