fake_fuchsia_sdk.bzl 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. """Provides a fake @fuchsia_sdk implementation that's used when the real one isn't available.
  2. This is needed since bazel queries on targets that depend on //:gtest (eg:
  3. `bazel query "deps(set(//googletest/test:gtest_all_test))"`) will fail if @fuchsia_sdk is not
  4. defined when bazel is evaluating the transitive closure of the query target.
  5. See https://github.com/google/googletest/issues/4472.
  6. """
  7. def _fake_fuchsia_sdk_impl(repo_ctx):
  8. for stub_target in repo_ctx.attr._stub_build_targets:
  9. stub_package = stub_target
  10. stub_target_name = stub_target.split("/")[-1]
  11. repo_ctx.file("%s/BUILD.bazel" % stub_package, """
  12. filegroup(
  13. name = "%s",
  14. )
  15. """ % stub_target_name)
  16. fake_fuchsia_sdk = repository_rule(
  17. doc = "Used to create a fake @fuchsia_sdk repository with stub build targets.",
  18. implementation = _fake_fuchsia_sdk_impl,
  19. attrs = {
  20. "_stub_build_targets": attr.string_list(
  21. doc = "The stub build targets to initialize.",
  22. default = [
  23. "pkg/fdio",
  24. "pkg/syslog",
  25. "pkg/zx",
  26. ],
  27. ),
  28. },
  29. )