1"""This module defines the cipd_install repository rule. 2 3The cipd_install rule is a wrapper around http_archive to download the CIPD 4package at the specified version over HTTPS. This does not require depot_tools nor a cipd binary 5on the host machine. 6""" 7 8load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 9 10def cipd_install(name, build_file_content, cipd_package, sha256, tag): 11 """Download and extract the zipped archive from CIPD, making it available for Bazel rules. 12 13 Args: 14 name: The name of the Bazel "repository" created. For example, if name is "alpha_beta", 15 the full Bazel label will start with @alpha_beta// 16 build_file_content: CIPD packages do not come with BUILD.bazel files, so we must supply 17 one. This should generally contain exports_files or filegroup. 18 cipd_package: The full name of the CIPD package. This is a "path" from the root of CIPD. 19 This should be a publicly accessible package, as authentication is not 20 supported. 21 sha256: The sha256 hash of the zip archive downloaded from CIPD. This should match the 22 official CIPD website. 23 tag: Represents the version of the CIPD package to download. 24 For example, git_package:abc123... 25 """ 26 cipd_url = "https://chrome-infra-packages.appspot.com/dl/" 27 cipd_url += cipd_package 28 cipd_url += "/+/" 29 cipd_url += tag 30 31 mirror_url = "https://storage.googleapis.com/skia-world-readable/bazel/" 32 mirror_url += sha256 33 mirror_url += ".zip" 34 http_archive( 35 name = name, 36 build_file_content = build_file_content, 37 sha256 = sha256, 38 urls = [ 39 cipd_url, 40 mirror_url, 41 ], 42 type = "zip", 43 ) 44