Merge pull request #29320 from thockin/makefile-fixes-and-speed

Automatic merge from submit-queue

Makefile fixes and speed

A few fixes that, together, make the 'make' experience smoother and more seamless.
    * `make clean all` works (@soltysh)
    * `make clean` does no spend 5 seconds loading deps just to remove them
    * deps building is faster

Fixes #28890
Ref #8830
This commit is contained in:
k8s-merge-robot
2016-07-22 06:40:35 -07:00
committed by GitHub
3 changed files with 125 additions and 62 deletions

View File

@@ -0,0 +1,65 @@
#!/bin/bash
# Copyright 2014 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.
# This script finds, caches, and prints a list of all directories that hold
# *.go files. If any directory is newer than the cache, re-find everything and
# update the cache. Otherwise use the cached file.
set -o errexit
set -o nounset
set -o pipefail
if [[ -z "${1:-}" ]]; then
echo "usage: $0 <cache-file>"
exit 1
fi
CACHE="$1"; shift
# This is a partial 'find' command. The caller is expected to pass the
# remaining arguments.
#
# Example:
# kfind -type f -name foobar.go
function kfind() {
find . \
-not \( \
\( \
-path ./vendor -o \
-path ./_\* -o \
-path ./.\* -o \
-path ./docs -o \
-path ./examples \
\) -prune \
\) \
"$@"
}
NEED_FIND=true
# It's *significantly* faster to check whether any directories are newer than
# the cache than to blindly rebuild it.
if [[ -f "${CACHE}" ]]; then
N=$(kfind -type d -newer "${CACHE}" -print -quit | wc -l)
[[ "${N}" == 0 ]] && NEED_FIND=false
fi
mkdir -p $(dirname "${CACHE}")
if $("${NEED_FIND}"); then
kfind -type f -name \*.go \
| xargs -n1 dirname \
| sort -u \
| sed 's|^./||' \
> "${CACHE}"
fi
cat "${CACHE}"