From fc80b58435a8a077b56b6a17ca2c3a492c5d577c Mon Sep 17 00:00:00 2001 From: Bowei Du Date: Fri, 8 Jun 2018 15:42:44 -0700 Subject: [PATCH] Fix build to only build the executable target The build was building everything in the repo recursively, causing an unstable built for the e2e-test. --- build/build.sh | 13 +++++-------- build/rules.mk | 3 ++- cmd/e2e-test/placeholder.go | 20 -------------------- 3 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 cmd/e2e-test/placeholder.go diff --git a/build/build.sh b/build/build.sh index 490932437f..f9afc1de85 100755 --- a/build/build.sh +++ b/build/build.sh @@ -42,14 +42,11 @@ if [ $GOARCH == "amd64" ]; then export GOBIN="$GOPATH/bin/linux_amd64" fi +BIN_PKG="$PKG/cmd/$(basename ${TARGET})" +LD_FLAGS="-X ${PKG}/pkg/version.Version=${VERSION} -X ${PKG}/pkg/version.GitCommit=${GIT_COMMIT}" + if echo "${TARGET}" | grep '.*-test$'; then - go test -c \ - -ldflags "-X ${PKG}/pkg/version.Version=${VERSION} -X ${PKG}/pkg/version.GitCommit=${GIT_COMMIT}" \ - -o "${TARGET}" \ - "$PKG/cmd/$(basename ${TARGET})" + go test -c -ldflags "${LD_FLAGS}" -o "${TARGET}" "${BIN_PKG}" else - go install \ - -installsuffix "static" \ - -ldflags "-X ${PKG}/pkg/version.Version=${VERSION} -X ${PKG}/pkg/version.GitCommit=${GIT_COMMIT}" \ - ./... + go install -i -installsuffix "static" -ldflags "${LD_FLAGS}" "${BIN_PKG}" fi diff --git a/build/rules.mk b/build/rules.mk index 4a65916d18..d7daa2455d 100644 --- a/build/rules.mk +++ b/build/rules.mk @@ -125,7 +125,8 @@ $(GO_BINARIES): build-dirs TARGET=$@ \ GIT_COMMIT=$(GIT_COMMIT) \ ./build/build.sh \ - " + " \ + $(VERBOSE_OUTPUT) # Rules for dockerfiles. define DOCKERFILE_RULE diff --git a/cmd/e2e-test/placeholder.go b/cmd/e2e-test/placeholder.go deleted file mode 100644 index 66d1132331..0000000000 --- a/cmd/e2e-test/placeholder.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -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. -*/ - -package main - -// This is a placeholder file to keep the Golang build happy. -func main() {}