Rework hack/ and build/ directories.

* Rewrite a bunch of the hack/ directory with modular reusable bash libraries.
* Have 'build/*' build on 'hack/*'.  The stuff in build now just runs hack/* in a docker container.
* Use a docker data container to enable faster incremental builds.
* Standardize output to _output/{local,dockerized}/bin/OS/ARCH/*.  This regularized placement makes cross compilation work.
* Move travis specific scripts under hack/travis

With new dockerized incremental builds, I can do a no-op `make quick-release` in ~30s.  This is a significant improvement.
This commit is contained in:
Joe Beda
2014-10-22 16:26:59 -07:00
parent 203a3d0cec
commit 5d33ce46cc
51 changed files with 1005 additions and 789 deletions

View File

@@ -21,42 +21,7 @@ set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
# Set the environment variables required by the build.
source "${KUBE_ROOT}/hack/config-go.sh"
# Go to the top of the tree.
cd "${KUBE_ROOT}"
# Check for `go` binary and set ${GOPATH}.
kube::setup_go_environment
# Fetch the version.
version_ldflags=$(kube::version_ldflags)
# Use eval to preserve embedded quoted strings.
eval "goflags=(${GOFLAGS:-})"
targets=()
for arg; do
if [[ "${arg}" == -* ]]; then
# Assume arguments starting with a dash are flags to pass to go.
goflags+=("${arg}")
else
targets+=("${arg}")
fi
done
if [[ ${#targets[@]} -eq 0 ]]; then
targets=($(kube::default_build_targets))
fi
binaries=($(kube::binaries_from_targets "${targets[@]}"))
echo "Building local go components"
# Note that the flags to 'go build' are duplicated in the dockerized build setup
# (build/build-image/common.sh). If we add more command line options to our
# standard build we'll want to duplicate them there. This needs to be fixed
go install "${goflags[@]:+${goflags[@]}}" \
-ldflags "${version_ldflags}" \
"${binaries[@]}"
kube::golang::build_binaries "$@"
kube::golang::place_bins