bindata.bzl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright 2018 The Kubernetes Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Genrule wrapper around the go-bindata utility.
  15. # IMPORTANT: Any changes to this rule may also require changes to hack/generate-bindata.sh.
  16. def go_bindata(
  17. name, srcs, outs,
  18. compress=True,
  19. include_metadata=True,
  20. pkg="generated",
  21. ignores=["\.jpg", "\.png", "\.md", "BUILD(\.bazel)?"],
  22. **kw):
  23. args = []
  24. for ignore in ignores:
  25. args.extend(["-ignore", "'%s'" % ignore])
  26. if not include_metadata:
  27. args.append("-nometadata")
  28. if not compress:
  29. args.append("-nocompress")
  30. native.genrule(
  31. name = name,
  32. srcs = srcs,
  33. outs = outs,
  34. cmd = """
  35. $(location //vendor/github.com/jteeuwen/go-bindata/go-bindata:go-bindata) \
  36. -o "$@" -pkg %s -prefix $$(pwd) %s $(SRCS)
  37. """ % (pkg, " ".join(args)),
  38. tools = [
  39. "//vendor/github.com/jteeuwen/go-bindata/go-bindata",
  40. ],
  41. **kw
  42. )