Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cargo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files([
"defs.bzl",
"Cargo.toml",
])
exports_files(
glob(["*.bzl"]) + ["Cargo.toml"],
)

bzl_library(
name = "bzl_lib",
Expand Down
8 changes: 8 additions & 0 deletions cargo/cargo_bootstrap_repository.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""# cargo_bootstrap_repository.bzl"""

load(
"//cargo/private:cargo_bootstrap.bzl",
_cargo_bootstrap_repository = "cargo_bootstrap_repository",
)

cargo_bootstrap_repository = _cargo_bootstrap_repository
8 changes: 8 additions & 0 deletions cargo/cargo_build_script.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""# cargo_build_script.bzl"""

load(
"//cargo/private:cargo_build_script_wrapper.bzl",
_cargo_build_script = "cargo_build_script",
)

cargo_build_script = _cargo_build_script
8 changes: 8 additions & 0 deletions cargo/cargo_dep_env.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""# cargo_dep_env.bzl"""

load(
"//cargo/private:cargo_dep_env.bzl",
_cargo_dep_env = "cargo_dep_env",
)

cargo_dep_env = _cargo_dep_env
8 changes: 8 additions & 0 deletions cargo/cargo_env.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""# cargo_env.bzl"""

load(
"//cargo/private:cargo_bootstrap.bzl",
_cargo_env = "cargo_env",
)

cargo_env = _cargo_env
13 changes: 8 additions & 5 deletions cargo/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ Common definitions for the `@rules_rust//cargo` package
"""

load(
"//cargo/private:cargo_bootstrap.bzl",
"//cargo:cargo_bootstrap_repository.bzl",
_cargo_bootstrap_repository = "cargo_bootstrap_repository",
_cargo_env = "cargo_env",
)
load(
"//cargo/private:cargo_build_script_wrapper.bzl",
"//cargo:cargo_build_script.bzl",
_cargo_build_script = "cargo_build_script",
)
load(
"//cargo/private:cargo_dep_env.bzl",
"//cargo:cargo_dep_env.bzl",
_cargo_dep_env = "cargo_dep_env",
)
load(
"//cargo/private:cargo_lints.bzl",
"//cargo:cargo_env.bzl",
_cargo_env = "cargo_env",
)
load(
"//cargo:extract_cargo_lints.bzl",
_extract_cargo_lints = "extract_cargo_lints",
)
load("//cargo/private:cargo_toml_env_vars.bzl", _cargo_toml_env_vars = "cargo_toml_env_vars")
Expand Down
8 changes: 8 additions & 0 deletions cargo/extract_cargo_lints.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""# extract_cargo_lints.bzl"""

load(
"//cargo/private:cargo_lints.bzl",
_extract_cargo_lints = "extract_cargo_lints",
)

extract_cargo_lints = _extract_cargo_lints
2 changes: 1 addition & 1 deletion crate_universe/private/crates_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_i
),
"splicing_config": attr.string(
doc = (
"The configuration flags to use for splicing Cargo manifests. Use `//crate_universe:defs.bzl\\%rsplicing_config` to " +
"The configuration flags to use for splicing Cargo manifests. Use `//crate_universe:defs.bzl\\%splicing_config` to " +
"generate the value for this field. If unset, the defaults defined there will be used."
),
),
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/private/crates_vendor.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def generate_config_file(
mode (str): The vendoring mode.
annotations: Any annotations provided.
generate_binaries (bool): Whether to generate binaries for the crates.
generate_build_scripts (bool): Whether to generate BUILD.bazel files.
generate_build_scripts (bool): Whether to generate `cargo_build_script` targets for crates that have build scripts.
generate_target_compatible_with (bool): DEPRECATED: Moved to `render_config`.
supported_platform_triples (str): The platform triples to support in
the generated BUILD.bazel files.
Expand Down Expand Up @@ -572,7 +572,7 @@ CRATES_VENDOR_ATTRS = {
),
"splicing_config": attr.string(
doc = (
"The configuration flags to use for splicing Cargo manifests. Use `//crate_universe:defs.bzl\\%rsplicing_config` to " +
"The configuration flags to use for splicing Cargo manifests. Use `//crate_universe:defs.bzl\\%splicing_config` to " +
"generate the value for this field. If unset, the defaults defined there will be used."
),
),
Expand Down
8 changes: 5 additions & 3 deletions crate_universe/private/generate_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def render_config(
crate_repository_template (str, optional): The base template to use for Crate label repository names. The
available format keys are [`{repository}`, `{name}`, `{version}`].
crate_alias_template (str, optional): The template to use when referring to generated aliases within the external
repository. The available format keys are [`{repository}`, `{name}`, `{version}`].
repository. The available format keys are [`{repository}`, `{name}`, `{version}`, `{target}`].
crates_module_template (str, optional): The pattern to use for the `defs.bzl` and `BUILD.bazel`
file names used for the crates module. The available format keys are [`{file}`].
default_alias_rule (str, option): Alias rule to use when generating aliases for all crates. Acceptable values
Expand Down Expand Up @@ -347,13 +347,15 @@ def generate_config(repository_ctx):
return config_path

def get_lockfiles(repository_ctx):
"""_summary_
"""Resolve the Cargo and Bazel lockfile paths from the repository rule's attributes.

Args:
repository_ctx (repository_ctx): The rule's context object.

Returns:
struct: _description_
struct: A struct with the following fields:
- `cargo` (path): The path to the Cargo lockfile.
- `bazel` (path | None): The path to the Bazel lockfile, or `None` if none was configured.
"""
return struct(
cargo = repository_ctx.path(repository_ctx.attr.cargo_lockfile),
Expand Down
2 changes: 1 addition & 1 deletion crate_universe/private/local_crate_mirror.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This is effectively a `local_repository` rule implementation, but where the `BUI
),
"path": attr.string(
# TODO: Verify what happens if this is not an absolute path.
doc = "Absolute path to the BUILD.bazel file to generate.",
doc = "Absolute path to the crate source directory whose contents will be copied into the mirror repository.",
),
"quiet": attr.bool(
doc = "If stdout and stderr should not be printed to the terminal.",
Expand Down
5 changes: 4 additions & 1 deletion crate_universe/private/splicing_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ def splice_workspace_manifest(
debug_workspace_dir (path): The location in which to save splicing outputs for future review.

Returns:
path: The path to a Cargo metadata json file found in the spliced workspace root.
struct: A struct describing the spliced workspace outputs with the following fields:
- `metadata` (path): The path to the Cargo `metadata.json` in the spliced workspace root.
- `cargo_lock` (path): The path to the spliced `Cargo.lock` file.
- `extra_paths_to_track` (list of str): Additional paths (one per line) reported by the splicer that should be tracked for repin invalidation.
"""

# Generate a workspace root which contains all workspace members
Expand Down
Loading
Loading