Merge pull request #39512 from ixdy/bazel-srcs-infinite-loop

Automatic merge from submit-queue

Generate a dummy BUILD file in _output/local/go to keep Bazel out of trouble

**What this PR does / why we need it**: the Kubernetes build system creates a symlink from `_output/local/go/src/k8s.io/kubernetes` back to `$KUBE_ROOT`, likely to deal with folks that don't have their `GOPATH `set up correctly.

Bazel's `glob()` is not very smart, and runs into issues with this; the `package-srcs` glob in `//BUILD.bazel` first evaluates the `**` before matching any excludes, and thus explodes on the infinite loop.

By generating a `BUILD` file along the path to the symlink, Bazel treats this as a separate package and descends no further.

(Oddly, generating a `BUILD.bazel` file doesn't seem to solve the glob explosion, but a directory with a `BUILD.bazel` file is still treated as a separate package. There's probably a subtle bug in Bazel somewhere.)

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-01-06 14:57:35 -08:00 committed by GitHub
commit d478eafa0c
2 changed files with 9 additions and 0 deletions

View File

@ -9,5 +9,8 @@
"./federation",
"./examples"
],
"SkippedPaths": [
"^_.*"
],
"AddSourcesRules": true
}

View File

@ -307,6 +307,12 @@ kube::golang::create_gopath_tree() {
if [[ ! -e "${go_pkg_dir}" || "$(readlink ${go_pkg_dir})" != "${KUBE_ROOT}" ]]; then
ln -snf "${KUBE_ROOT}" "${go_pkg_dir}"
fi
cat >"${KUBE_GOPATH}/BUILD" <<EOF
# This dummy BUILD file prevents Bazel from trying to descend through the
# infinite loop created by the symlink at
# ${go_pkg_dir}
EOF
}
# Ensure the godep tool exists and is a viable version.