Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7313,6 +7313,7 @@ Starlark:
color: "#76d275"
extensions:
- ".bzl"
- ".bxl"
- ".star"
filenames:
- BUCK
Expand Down
26 changes: 26 additions & 0 deletions samples/Starlark/part2.bxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is dual-licensed under either the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree or the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree. You may select, at your option, one of the
# above-listed licenses.

def _main(ctx: bxl.Context):
universe = ctx.target_universe(ctx.cli_args.target)
all_targets = universe.universe_target_set()
nodes = ctx.cquery().kind("^(binary|library)$", all_targets)
analysis_res_dict = ctx.analysis(nodes)
index_outputs = []
for _, analysis_res in analysis_res_dict.items():
default_info = analysis_res.as_dependency()[DefaultInfo]
index_sub_target_provider = default_info.sub_targets["index"]
index_outputs.extend(index_sub_target_provider[DefaultInfo].default_outputs)
ctx.output.print(pstr(index_outputs))

main = bxl_main(
impl = _main,
cli_args = {
"target": cli_args.target_label(),
},
)