Skip to content

Commit

Permalink
Move output_hash creation upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinh Tran committed Oct 9, 2023
1 parent a7eba05 commit 2950a8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 8 additions & 3 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1118,10 +1118,15 @@ def rustc_compile_action(
# removing CrateInfo construction before `rust_compile_action

crate_info_dict = None
if create_crate_info_callback != None:
if ctx == None or toolchain == None or crate_type == None or crate_info != None:
if create_crate_info_callback:
if ctx == None or toolchain == None or crate_type == None or output_hash == None or crate_info != None:
fail("FAIL", ctx, toolchain, crate_type)
crate_info_dict = create_crate_info_callback(ctx, toolchain, crate_type)
crate_info_dict = create_crate_info_callback(
ctx = ctx,
toolchain = toolchain,
crate_type = crate_type,
output_hash = output_hash,
)

if crate_info_dict != None:
crate_info = rust_common.create_crate_info(**crate_info_dict)
Expand Down
7 changes: 1 addition & 6 deletions 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):
def create_crate_info_dict(ctx, toolchain, crate_type, output_hash):
"""Creates a mutable dict() representing CrateInfo provider
create_crate_info_dict is a *temporary* solution until create_crate_info is completely moved into
Expand All @@ -873,11 +873,6 @@ def create_crate_info_dict(ctx, toolchain, crate_type):
crate_root = crate_root_src(ctx.attr.name, ctx.files.srcs, crate_type)
srcs, crate_root = transform_sources(ctx, ctx.files.srcs, crate_root)

if crate_type in ["cdylib", "staticlib"]:
output_hash = None
else:
output_hash = determine_output_hash(crate_root, ctx.label)

deps = transform_deps(ctx.attr.deps)
proc_macro_deps = transform_deps(ctx.attr.proc_macro_deps + get_import_macro_deps(ctx))
rust_lib_name = _determine_lib_name(
Expand Down

0 comments on commit 2950a8f

Please sign in to comment.