Skip to content

Commit

Permalink
Reorganize implementation of cquery_deps
Browse files Browse the repository at this point in the history
Summary: Minor rearrangement to make the handling of the 3 cases of Thrift/Protobuf/other make more sense to me and prepare for changes I need to make here for D58537292.

Reviewed By: davidbarsky

Differential Revision: D58632004

fbshipit-source-id: e9c9c58348f6e9b2041380e77a8ade163a6e0913
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Jun 15, 2024
1 parent e82579a commit 4f48b5a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions rust/rust-analyzer/resolve_deps.bxl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def materialize(
def _process_target_config(
ctx: BxlContext,
target: bxl.ConfiguredTargetNode,
in_workspace: bool,
out_dir: bxl.EnsuredArtifact | None = None) -> TargetInfo:
in_workspace: bool) -> TargetInfo:
# convert all source paths to absolute paths
resolved_attrs = target.resolved_attrs_eager(ctx)

Expand Down Expand Up @@ -105,8 +104,6 @@ def _process_target_config(
copy["project_relative_buildfile"] = ctx.fs.project_rel_path(target.buildfile_path)
copy["kind"] = target.rule_type
copy["in_workspace"] = in_workspace
if out_dir:
copy["out_dir"] = out_dir

return copy

Expand All @@ -133,6 +130,12 @@ def cquery_deps(
if candidate_workspace.raw_target() in workspaces:
in_workspace = True

target_info = _process_target_config(
ctx = ctx,
target = target,
in_workspace = in_workspace,
)

labels = attrs.get("labels")
if "thrift_library-rust" in labels.value():
for src, dest in attrs.get("mapped_srcs").value().items():
Expand All @@ -141,12 +144,11 @@ def cquery_deps(
src = src,
dest = dest,
))
out[target.label.raw_target()] = _process_target_config(ctx, target, in_workspace)
elif "generated_protobuf_library_rust" in labels.value():
protobuf_out_dir = materialize_generated_protobufs(ctx, target, actions, seen)
out[target.label.raw_target()] = _process_target_config(ctx, target, in_workspace, protobuf_out_dir)
else:
out[target.label.raw_target()] = _process_target_config(ctx, target, in_workspace)
target_info["out_dir"] = protobuf_out_dir

out[target.label.raw_target()] = target_info

materialize_generated_thrift(ctx, actions, mapped_srcs, out)

Expand Down

0 comments on commit 4f48b5a

Please sign in to comment.