Skip to content

Commit

Permalink
check: Add and use structured output option
Browse files Browse the repository at this point in the history
Summary: So that a future diff can output additional things

Reviewed By: dtolnay

Differential Revision: D64365598

fbshipit-source-id: 0c095c473f2c808dd184b0596fe751b5c223ae39
  • Loading branch information
JakobDegen authored and facebook-github-bot committed Oct 20, 2024
1 parent f6c58c7 commit 8542040
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions rust/rust-analyzer/check.bxl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

load("@prelude//rust:outputs.bzl", "RustcExtraOutputsInfo")

def check_targets_impl(ctx: bxl.Context) -> None:
def _check_targets_impl(ctx: bxl.Context) -> list[bxl.EnsuredArtifact]:
uquery_owners = ctx.uquery().owner(ctx.cli_args.file)
target_universe = ctx.target_universe(uquery_owners)
owners = ctx.cquery().owner(ctx.cli_args.file, target_universe.target_set())
nodes = ctx.cquery().kind("^(rust_binary|rust_library|rust_test)$", owners)

if len(nodes) == 0:
return
return []

analysis = ctx.analysis(nodes).values()

Expand All @@ -28,17 +28,27 @@ def check_targets_impl(ctx: bxl.Context) -> None:

art_output = ctx.output.ensure_multiple(artifacts)

out = [
return [
artifact.abs_path()
for artifact in art_output
]

def _run(ctx: bxl.Context) -> None:
out = _check_targets_impl(ctx)

if ctx.cli_args.structured_output:
out = {
"diagnostic_paths": out,
}

ctx.output.print_json(out)

check = bxl_main(
impl = check_targets_impl,
impl = _run,
cli_args = {
"file": cli_args.string(),
# TODO(JakobDegen): Make this the default after migration
"structured-output": cli_args.bool(),
"use-clippy": cli_args.bool(),
},
)

0 comments on commit 8542040

Please sign in to comment.