update-bazel.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. # Copyright 2016 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -o errexit
  16. set -o pipefail
  17. export KRATOS_ROOT=$(dirname "${BASH_SOURCE}")/..
  18. source "${KRATOS_ROOT}/build/lib/init.sh"
  19. #kratos::util::ensure-gnu-sed
  20. # Remove generated files prior to running kazel.
  21. # TODO(spxtr): Remove this line once Bazel is the only way to build.
  22. # rm -f "${KRATOS_ROOT}/pkg/generated/openapi/zz_generated.openapi.go"
  23. # Ensure that we find the binaries we build before anything else.
  24. export GOBIN="${KRATOS_OUTPUT_BINPATH}"
  25. PATH="${GOBIN}:${PATH}"
  26. # Install tools we need, but only from vendor/...
  27. go install ./vendor/github.com/hawkingrei/kazel
  28. # gazelle gets confused by our staging/ directory, prepending an extra
  29. # "k8s.io/kratosrnetes/staging/src" to the import path.
  30. # gazelle won't follow the symlinks in vendor/, so we can't just exclude
  31. # staging/. Instead we just fix the bad paths with sed.
  32. if ! kazel; then
  33. kratos::log::info "Please remember to run the 'make update' in the root directory of go-common, or run 'kratos update' in any position of go-common.
  34. For more information.Please read this document http://info.bilibili.co/pages/viewpage.action?pageId=8466415" >&2
  35. exit 1
  36. fi