buck2 icon indicating copy to clipboard operation
buck2 copied to clipboard

docs: "BXL APIs" doesn't say that it means the *global object* bxl inside a bxl file

Open lf- opened this issue 5 months ago • 3 comments

https://buck2.build/docs/api/bxl/

It is unclear from immediately looking at this that it is saying that bxl is a magic global in bxl context.

Also, main is unclear: there's bxl_main which is clearly used, but I don't know whether this main does anything special.

lf- avatar Jul 07 '25 20:07 lf-

It looks like bxl_main and main are identical, but bxl_main is used in the BXL Tutorial and undocumented in the BXL APIs, and main is not used in the tutorial but is documented in the BXL APIs.

9999years avatar Jul 07 '25 20:07 9999years

yes, bxl_main and bxl.main are the same, they even share the implementation: https://github.com/facebook/buck2/blob/b29b66356ae7fce89845ec8865c65263ab1f9eec/app/buck2_bxl/src/bxl/starlark_defs/bxl_function.rs#L52-L117

PhilipMetzger avatar Jul 07 '25 20:07 PhilipMetzger

As @PhilipMetzger said, these two are identical. We have a plan to make everything that specific to bxl under bxl namespace, i.e bxl.main for this case. But we haven't started to migrate.

Nero5023 avatar Jul 08 '25 03:07 Nero5023