| # Copyright 2023 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| """Defines a WORKSPACE rule, which is a prerequisite for using @fuchsia_infra rules.""" |
| |
| load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") |
| load("//cipd:defs.bzl", "cipd_repository", "cipd_tool_repository") |
| |
| def _fuchsia_infra_workspace_impl(ctx): |
| ctx.file("BUILD.bazel", "") |
| |
| # See https://bazel.build/docs/output_directories. |
| ctx.file( |
| "workspace_info.bzl", |
| """WORKSPACE_OUTPUT_BASE = "{output_base}" |
| """.format( |
| output_base = ctx.path("../.."), |
| ), |
| ) |
| |
| _fuchsia_infra_workspace = repository_rule( |
| doc = """ |
| Adds @fuchsia_infra_workspace//:workspace_info.bzl. |
| |
| This is required to use the build rules in @fuchsia_infra. |
| """, |
| implementation = _fuchsia_infra_workspace_impl, |
| ) |
| |
| def fuchsia_infra_workspace(**kwargs): |
| _fuchsia_infra_workspace( |
| name = "fuchsia_infra_workspace", |
| **kwargs |
| ) |
| |
| maybe( |
| repo_rule = cipd_tool_repository, |
| name = "cipd_tool", |
| ) |
| |
| maybe( |
| repo_rule = cipd_repository, |
| name = "luci_auth", |
| cipd_bin = "@cipd_tool//:cipd", |
| ensure_file = "@fuchsia_infra//manifests:luci-auth.ensure", |
| build_file_content = """\ |
| exports_files( |
| glob(["**"]), |
| ) |
| """, |
| ) |
| |
| maybe( |
| repo_rule = cipd_repository, |
| name = "orchestrate", |
| cipd_bin = "@cipd_tool//:cipd", |
| ensure_file = "@fuchsia_infra//manifests:orchestrate.ensure", |
| build_file_content = """\ |
| exports_files( |
| glob(["**"]), |
| ) |
| """, |
| ) |