Skip to content

Latest commit

 

History

History
executable file
·
75 lines (52 loc) · 8.78 KB

repository_rules_overview.md

File metadata and controls

executable file
·
75 lines (52 loc) · 8.78 KB

Repository Rules

The rules described below are used to build Swift packages and make their products and targets available as Bazel targets.

On this page:

local_swift_package

local_swift_package(name, bazel_package_name, dependencies_index, env, path, repo_mapping)

Used to build a local Swift package.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this repository. Name required
bazel_package_name The short name for the Swift package's Bazel repository. String optional ""
dependencies_index A JSON file that contains a mapping of Swift products and Swift modules. Label optional None
env Environment variables that will be passed to the execution environments for this repository rule. (e.g. SPM version check, SPM dependency resolution, SPM package description generation) Dictionary: String -> String optional {}
path The path to the local Swift package directory. This can be an absolute path or a relative path to the workspace root. String required
repo_mapping In WORKSPACE context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.

For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target).

This attribute is not supported in MODULE.bazel context (when invoking a repository rule inside a module extension's implementation function).
Dictionary: String -> String optional

swift_package

swift_package(name, bazel_package_name, branch, commit, dependencies_index, env, init_submodules,
              patch_args, patch_cmds, patch_cmds_win, patch_tool, patches, recursive_init_submodules,
              remote, repo_mapping, shallow_since, tag, verbose, version)

Used to download and build an external Swift package.

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this repository. Name required
bazel_package_name The short name for the Swift package's Bazel repository. String optional ""
branch branch in the remote repository to checked out. Precisely one of branch, tag, or commit must be specified. String optional ""
commit The commit or revision to download from version control. String required
dependencies_index A JSON file that contains a mapping of Swift products and Swift modules. Label optional None
env Environment variables that will be passed to the execution environments for this repository rule. (e.g. SPM version check, SPM dependency resolution, SPM package description generation) Dictionary: String -> String optional {}
init_submodules Whether to clone submodules in the repository. Boolean optional False
patch_args The arguments given to the patch tool. Defaults to -p0, however -p1 will usually be needed for patches generated by git. If multiple -p arguments are specified, the last one will take effect.If arguments other than -p are specified, Bazel will fall back to use patch command line tool instead of the Bazel-native patch implementation. When falling back to patch command line tool and patch_tool attribute is not specified, patch will be used. List of strings optional ["-p0"]
patch_cmds Sequence of Bash commands to be applied on Linux/Macos after patches are applied. List of strings optional []
patch_cmds_win Sequence of Powershell commands to be applied on Windows after patches are applied. If this attribute is not set, patch_cmds will be executed on Windows, which requires Bash binary to exist. List of strings optional []
patch_tool The patch(1) utility to use. If this is specified, Bazel will use the specified patch tool instead of the Bazel-native patch implementation. String optional ""
patches A list of files that are to be applied as patches after extracting the archive. By default, it uses the Bazel-native patch implementation which doesn't support fuzz match and binary patch, but Bazel will fall back to use patch command line tool if patch_tool attribute is specified or there are arguments other than -p in patch_args attribute. List of labels optional []
recursive_init_submodules Whether to clone submodules recursively in the repository. Boolean optional True
remote The version control location from where the repository should be downloaded. String required
repo_mapping In WORKSPACE context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.

For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target).

This attribute is not supported in MODULE.bazel context (when invoking a repository rule inside a module extension's implementation function).
Dictionary: String -> String optional
shallow_since an optional date, not after the specified commit; the argument is not allowed if a tag is specified (which allows cloning with depth 1). Setting such a date close to the specified commit allows for a more shallow clone of the repository, saving bandwidth and wall-clock time. String optional ""
tag tag in the remote repository to checked out. Precisely one of branch, tag, or commit must be specified. String optional ""
verbose - Boolean optional False
version The resolved version of the package. String optional ""