Skip to main content
Version: 2.7.x

repo_utils

Public API

Macros and Functions

patch

Implementation of patching an already extracted repository.

This rule is intended to be used in the implementation function of a repository rule. If the parameters patches, patch_tool, patch_args, patch_cmds and patch_cmds_win are not specified then they are taken from ctx.attr.

Example usage (generated):

load("@aspect_bazel_lib//lib:repo_utils.bzl", "patch")

patch(
# The repository context of the repository rule calling this utility
ctx = None,
)

ctx

Required.

The repository context of the repository rule calling this utility function.

patches

Optional. Default: None

The patch files to apply. List of strings, Labels, or paths.

patch_cmds

Optional. Default: None

Bash commands to run for patching, passed one at a time to bash -c. List of strings

patch_cmds_win

Optional. Default: None

Powershell commands to run for patching, passed one at a time to powershell /c. List of strings. If the boolean value of this parameter is false, patch_cmds will be used and this parameter will be ignored.

patch_tool

Optional. Default: None

Path of the patch tool to execute for applying patches. String.

patch_args

Optional. Default: None

Arguments to pass to the patch tool. List of strings.

auth

Optional. Default: None

An optional dict specifying authentication information for some of the URLs.

patch_directory

Optional. Default: None

Directory to apply the patches in

repo_utils.is_darwin

Returns true if the host operating system is Darwin

Example usage (generated):

load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")

repo_utils.is_darwin(
rctx = None,
)

rctx

Required.

repo_utils.is_linux

Returns true if the host operating system is Linux

Example usage (generated):

load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")

repo_utils.is_linux(
rctx = None,
)

rctx

Required.

repo_utils.is_windows

Returns true if the host operating system is Windows

Example usage (generated):

load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")

repo_utils.is_windows(
rctx = None,
)

rctx

Required.

repo_utils.get_env_var

Find an environment variable in system. Doesn't %-escape the value!

Example usage (generated):

load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")

repo_utils.get_env_var(
# rctx
rctx = None,
# environment variable name
name = "",
# default value to return if env var is not set in system
default = None,
)

rctx

Required.

rctx

name

Required.

environment variable name

default

Required.

default value to return if env var is not set in system

repo_utils.get_home_directory

Example usage (generated):

load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")

repo_utils.get_home_directory(
rctx = None,
)

rctx

Required.

repo_utils.os

Returns the name of the host operating system

Example usage (generated):

load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")

repo_utils.os(
# rctx
rctx = None,
)

rctx

Required.

rctx

repo_utils.platform

Returns a normalized name of the host os and CPU architecture.

Alias archictures names are normalized:

x86_64 => amd64 aarch64 => arm64

The result can be used to generate repository names for host toolchain repositories for toolchains that use these normalized names.

Common os & architecture pairs that are returned are,

  • darwin_amd64
  • darwin_arm64
  • linux_amd64
  • linux_arm64
  • linux_s390x
  • linux_ppc64le
  • windows_amd64

Example usage (generated):

load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")

repo_utils.platform(
# rctx
rctx = None,
)

rctx

Required.

rctx