Skip to content

Commit

Permalink
pw_env_setup: Add ability to override bazel BUILD file for CIPD repos
Browse files Browse the repository at this point in the history
Change-Id: I65279e62bb53a4975c4a8acbb65825f4aa6e25ee
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/165530
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Erik Gilling <konkers@google.com>
  • Loading branch information
konkers authored and CQ Bot Account committed Aug 14, 2023
1 parent 0000497 commit aa9cec4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 14 additions & 3 deletions pw_env_setup/bazel/cipd_setup/cipd_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,20 @@ def cipd_client_repository():
cipd_repository = repository_rule(
_cipd_repository_impl,
attrs = {
"_cipd_client": attr.label(default = "@cipd_client//:cipd"),
"path": attr.string(),
"tag": attr.string(),
"_cipd_client": attr.label(
default = "@cipd_client//:cipd",
doc = "Location of the CIPD client binary (internal).",
),
"build_file": attr.label(
allow_single_file = True,
doc = "A BUILD file to use instead of generating one internally.",
),
"path": attr.string(
doc = "Path within CIPD where this repository lives.",
),
"tag": attr.string(
doc = "Tag specifying which version of the repository to fetch.",
),
},
doc = """
Downloads a singular CIPD dependency to the root of a remote repository.
Expand Down
7 changes: 5 additions & 2 deletions pw_env_setup/bazel/cipd_setup/internal/cipd_internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,18 @@ def cipd_repository_impl(rctx):
rctx: Repository context.
"""
cipd_repository_base(rctx)
rctx.file("BUILD", """
if rctx.attr.build_file:
rctx.file("BUILD", rctx.read(rctx.attr.build_file))
else:
rctx.file("BUILD", """
exports_files(glob(["**"]))
filegroup(
name = "all",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
""")
""")

def _cipd_path_to_repository_name(path, platform):
""" Converts a cipd path to a repository name
Expand Down

0 comments on commit aa9cec4

Please sign in to comment.