Skip to content

Commit

Permalink
Use new BXL helper functions for target discovery
Browse files Browse the repository at this point in the history
Summary: Just refactoring code, nothing changes

Reviewed By: echistyakov, malanka

Differential Revision: D69930467

fbshipit-source-id: 3c6c228f9b37848e0f229de32ca4d7bd46ab4895
  • Loading branch information
podtserkovskiy authored and facebook-github-bot committed Feb 20, 2025
1 parent 0de1287 commit 92bdd0b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions glean/lang/go/targets.bxl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

load("@prelude//bxl:lazy.bxl", "batch_apply_lazy_catch_each", "partition_results")

def _report_errors(errors: list[bxl.Error]):
for error in errors:
print(error.message) #buildifier: disable=print

# Find all targets eligible for indexing.
def _impl_discover(ctx: bxl.Context):
uquery = ctx.uquery()
Expand Down Expand Up @@ -31,13 +37,10 @@ def _impl_discover(ctx: bxl.Context):
print("Go targets (non-generated+thrift):", len(go_targets)) # buildifier: disable=print

# exclude broken and incompatible with current platform
conf_results = ctx.lazy.join_all([ctx.lazy.configured_target_node(t).catch() for t in go_targets]).resolve()
valid_targets = []
for result in conf_results:
if result.is_ok():
valid_targets.append(result.unwrap())
else:
print(result.unwrap_err().message) #buildifier: disable=print
results = batch_apply_lazy_catch_each(ctx, ctx.lazy.configured_target_node, list(go_targets))
targets, errors = partition_results(results)
_report_errors(errors)
valid_targets = bxl.ctarget_set(targets)

print("Go targets (valid&compatible):", len(valid_targets)) # buildifier: disable=print

Expand Down

0 comments on commit 92bdd0b

Please sign in to comment.