From 6a9ece0f1a866994b7d4fc1f28212945bcae5a3c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 4 Jun 2018 13:11:08 -0700 Subject: [PATCH] Makefile: Drop find-godeps.sh for bin/crio target and make it .PHONY The script is from 95846211 (build: find dependencies for Go executables, 2017-03-21, #410), but: * Make expands prerequisites immediately when loading a Makefile [1], and on my wimpy Chromebook SD Card, this is *slow*: $ time hack/find-godeps.sh ~/.local/lib/go/src/github.com/kubernetes-incubator/cri-o cmd/crio github.com/kubernetes-incubator/cri-o ... real 0m19.239s user 0m16.774s sys 0m7.122s * Go is pretty good at this on its own, so having make call 'go build' every time will almost certainly be faster than us trying to mimic this in a shell script. And by punting to Go in the recipe, Make invocations that do not need the podman target (e.g. 'make help') can skip the dependency lookup entirely. The downside to this is that rebuilds mean we'll also force rebuilds in downstream targets, even when none of the dependencies have changed. But the only downstream dependencies are: * crio.conf, which is a fast rebuild (much faster than the find-godeps.sh I'm removing). * binaries, which is in turn a dependency of localintegration and other targets. Rebuild-avoidance might be useful, but bin/conmon (another binaries dependency) is already .PHONY, so binaries dependencies will need to be rebuilt every time regardless of how we handle bin/crio. [1]: https://www.gnu.org/software/make/manual/html_node/Reading-Makefiles.html#Rule-Definition Signed-off-by: W. Trevor King --- Makefile | 3 ++- hack/find-godeps.sh | 41 ----------------------------------------- 2 files changed, 2 insertions(+), 42 deletions(-) delete mode 100755 hack/find-godeps.sh diff --git a/Makefile b/Makefile index 0208f00233c..9929d6f93f9 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ test/copyimg/copyimg: .gopathok $(wildcard test/copyimg/*.go) test/checkseccomp/checkseccomp: .gopathok $(wildcard test/checkseccomp/*.go) $(GO) build -i $(LDFLAGS) -tags "$(BUILDTAGS) containers_image_ostree_stub" -o $@ $(PROJECT)/test/checkseccomp -bin/crio: .gopathok $(shell hack/find-godeps.sh $(GOPKGDIR) cmd/crio $(PROJECT)) +bin/crio: .gopathok $(GO) build -i $(LDFLAGS) -tags "$(BUILDTAGS) containers_image_ostree_stub" -o $@ $(PROJECT)/cmd/crio crio.conf: bin/crio @@ -234,6 +234,7 @@ install.tools: .install.gitvalidation .install.gometalinter .install.md2man .ins .PHONY: \ bin/conmon \ + bin/crio \ bin/pause \ binaries \ clean \ diff --git a/hack/find-godeps.sh b/hack/find-godeps.sh deleted file mode 100755 index 4ce9325421f..00000000000 --- a/hack/find-godeps.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# -# $1 - base path of the source tree -# $2 - subpath under $1 to find *.go dependencies for -# $3 - package name (eg, github.com/organization/project) - -set -o errexit -set -o nounset -set -o pipefail - -# might be called from makefile before basepath is set up; just return -# empty deps. The make target will then ensure that GOPATH is set up -# correctly, and go build will build everything the first time around -# anyway. Next time we get here everything will be fine. -if [ ! -d "$1/$2" ]; then - exit 0 -fi - -function find-deps() { - local basepath=$1 - local srcdir=$2 - local pkgname=$3 - local deps= - - # gather imports from cri-o - pkgs=$(cd ${basepath}/${srcdir} && go list -f "{{.Imports}}" . | tr ' ' '\n' | tr -d '[]' | grep -v "/vendor/" | grep ${pkgname} | sed -e "s|${pkgname}/||g") - - # add each Go import's sources to the deps list, - # and recursively get that imports's imports too - for dep in ${pkgs}; do - deps+="$(ls ${basepath}/${dep}/*.go | sed -e "s|${basepath}/||g") " - # add deps of this package too - deps+="$(find-deps ${basepath} ${dep} ${pkgname}) " - done - - echo "${deps}" | sort | uniq -} - -# add Go sources from the current package at the end -echo "$(find-deps "$1" "$2" "$3" | xargs) $(cd $1 && ls $2/*.go | xargs)" -