Support cross compilation.

Also add more utilities to copy and clean stuff.
This commit is contained in:
Joe Beda
2014-06-17 16:10:57 -07:00
parent 570ebf54a9
commit 4f63a690ee
10 changed files with 160 additions and 40 deletions

View File

@@ -13,15 +13,6 @@
# limitations under the License.
# This file creates a standard build environment for building Kubernetes
#
# Usage:
#
# # Assemble the full dev environment. This is slow the first time.
# docker build -t kube-build .
#
# # Mount your source in an interactive container for quick testing:
# docker run -v `pwd`:/go/src/github.com/GoogleCloudPlatform/kubernetes -i -t docker bash
#
FROM google/debian:wheezy
MAINTAINER Joe Beda <jbeda@google.com>
@@ -50,15 +41,17 @@ RUN cd /usr/local/go/src && \
bash -xc 'for platform in $KUBE_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done'
# Set up Go Environment
ENV PATH /usr/local/go/bin:/go/bin:$PATH
ENV PATH /go/bin:$PATH
ENV GOPATH /go:/go/src/github.com/GoogleCloudPlatform/kubernetes/third_party
# Mark this as a kube-build container
RUN touch /kube-build-image
ENV GOOS linux
ENV GOARCH amd64
# Get the code coverage tool and etcd for integration tests
RUN go get code.google.com/p/go.tools/cmd/cover github.com/coreos/etcd
# Mark this as a kube-build container
RUN touch /kube-build-image
WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
# Upload Kubernetes

View File

@@ -25,3 +25,33 @@ mkdir -p "${KUBE_TARGET}"
if [[ ! -f "/kube-build-image" ]]; then
echo "WARNING: This script should be run in the kube-build conrtainer image!" >&2
fi
function make-binaries() {
readonly BINARIES="
proxy
integration
apiserver
controller-manager
kubelet
cloudcfg
localkube"
ARCH_TARGET="${KUBE_TARGET}/${GOOS}/${GOARCH}"
mkdir -p "${ARCH_TARGET}"
function make-binary() {
echo "+++ Building $1 for ${GOOS}/${GOARCH}"
go build \
-o "${ARCH_TARGET}/$1" \
github.com/GoogleCloudPlatform/kubernetes/cmd/$1
}
if [[ -n $1 ]]; then
make-binary $1
exit 0
fi
for b in ${BINARIES}; do
make-binary $b
done
}

View File

@@ -20,26 +20,4 @@ set -e
source $(dirname $0)/common.sh
readonly BINARIES="
proxy
integration
apiserver
controller-manager
kubelet
cloudcfg
localkube"
if [[ -n $1 ]]; then
echo "+++ Building $1"
go build \
-o "${KUBE_TARGET}/$1" \
github.com/GoogleCloudPlatform/kubernetes/cmd/$1
exit 0
fi
for b in ${BINARIES}; do
echo "+++ Building $b"
go build \
-o "${KUBE_TARGET}/$b" \
github.com/GoogleCloudPlatform/kubernetes/cmd/$b
done
make-binaries

35
build/build-image/make-cross.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This and builds all go components.
set -e
source $(dirname $0)/common.sh
readonly CROSS_BINARIES="
cloudcfg
"
for platform in ${KUBE_CROSSPLATFORMS}; do
(
export GOOS=${platform%/*}
export GOARCH=${platform##*/}
for binary in ${CROSS_BINARIES}; do
make-binaries "${binary}"
done
)
done