Skip to content

Commit

Permalink
Pass kwargs to _buidl_script_run
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinh Tran authored Aug 25, 2023
1 parent aab2ea4 commit 3385c97
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions cargo/private/cargo_build_script_wrapper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ load("//rust:defs.bzl", "rust_binary")

def cargo_build_script(
name,
edition = None,
srcs = [],
crate_features = [],
version = None,
deps = [],
Expand Down Expand Up @@ -84,6 +86,8 @@ def cargo_build_script(
Args:
name (str): The name for the underlying rule. This should be the name of the package
being compiled, optionally with a suffix of `_build_script`.
edition (str): The rust edition to use for the internal binary crate.
srcs (list of label): Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made.
crate_features (list, optional): A list of features to enable for the build script.
version (str, optional): The semantic version (semver) of the crate.
deps (list, optional): The build-dependencies of the crate.
Expand Down Expand Up @@ -116,31 +120,17 @@ def cargo_build_script(
binary_tags = [tag for tag in tags or []]
if "manual" not in binary_tags:
binary_tags.append("manual")
build_script_kwargs = {}
binary_kwargs = kwargs
if "compatible_with" in kwargs:
build_script_kwargs["compatible_with"] = kwargs["compatible_with"]
binary_kwargs.pop("compatible_with")

if "target_compatible_with" in kwargs:
build_script_kwargs["target_compatible_with"] = kwargs["target_compatible_with"]

if "toolchains" in kwargs:
build_script_kwargs["toolchains"] = kwargs["toolchains"]

if "features" in kwargs:
build_script_kwargs["features"] = kwargs["features"]

rust_binary(
name = name + "_",
crate_features = crate_features,
version = version,
deps = deps,
data = data,
rustc_env = rustc_env,
rustc_flags = rustc_flags,
srcs = srcs,
edition = edition,
tags = binary_tags,
**binary_kwargs
)
_build_script_run(
name = name,
Expand All @@ -156,5 +146,5 @@ def cargo_build_script(
rustc_flags = rustc_flags,
visibility = visibility,
tags = tags,
**build_script_kwargs
**kwargs
)

0 comments on commit 3385c97

Please sign in to comment.