Skip to content

Commit

Permalink
Remove crate_info attr
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinh Tran committed Oct 9, 2023
1 parent e43d2f2 commit d66fa70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
6 changes: 3 additions & 3 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def _rust_test_impl(ctx):
))

# Build the test binary using the dependency's srcs.
crate_info = rust_common.create_crate_info(
crate_info_dict = dict(
name = crate.name,
type = crate_type,
root = crate.root,
Expand Down Expand Up @@ -307,7 +307,7 @@ def _rust_test_impl(ctx):
)

# Target is a standalone crate. Build the test binary as its own crate.
crate_info = rust_common.create_crate_info(
crate_info_dict = dict(
name = compute_crate_name(ctx.workspace_name, ctx.label, toolchain, ctx.attr.crate_name),
type = crate_type,
root = crate_root,
Expand All @@ -330,7 +330,7 @@ def _rust_test_impl(ctx):
ctx = ctx,
attr = ctx.attr,
toolchain = toolchain,
crate_info = crate_info,
crate_info_dict = crate_info_dict,
rust_flags = ["--test"] if ctx.attr.use_libtest_harness else ["--cfg", "test"],
skip_expanding_rustc_env = True,
)
Expand Down
27 changes: 11 additions & 16 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,6 @@ def rustc_compile_action(
toolchain,
rust_flags = [],
crate_type = None,
crate_info = None,
output_hash = None,
force_all_deps_direct = False,
rust_metadata = None,
Expand Down Expand Up @@ -1118,21 +1117,17 @@ def rustc_compile_action(
# TODO: Remove create_crate_info_callback after all rustc_compile_action callers migrate to
# removing CrateInfo construction before `rust_compile_action

# if crate_info == None:
# print(crate_info_dict)

if crate_info == None:
if crate_info_dict:
crate_info = rust_common.create_crate_info(**crate_info_dict)
else:
crate_info_dict = create_crate_info_dict(
ctx = ctx,
toolchain = toolchain,
crate_type = crate_type,
rust_metadata = rust_metadata,
output_file = output_file,
)
crate_info = rust_common.create_crate_info(**crate_info_dict)
if crate_info_dict:
crate_info = rust_common.create_crate_info(**crate_info_dict)
else:
crate_info_dict = create_crate_info_dict(
ctx = ctx,
toolchain = toolchain,
crate_type = crate_type,
rust_metadata = rust_metadata,
output_file = output_file,
)
crate_info = rust_common.create_crate_info(**crate_info_dict)

build_metadata = getattr(crate_info, "metadata", None)

Expand Down
2 changes: 1 addition & 1 deletion rust/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ def _symlink_for_non_generated_source(ctx, src_file, package_root):
else:
return src_file

def create_crate_info_dict(ctx, toolchain, crate_type, rust_metadata, output_file, crate_info_dict = None):
def create_crate_info_dict(ctx, toolchain, crate_type, rust_metadata, output_file):
"""Creates a mutable dict() representing CrateInfo provider
create_crate_info_dict is a *temporary* solution until create_crate_info is completely moved into
Expand Down

0 comments on commit d66fa70

Please sign in to comment.