Skip to content

Conversation

@rickeylev
Copy link
Collaborator

From the discussion in #2216, it's clear that some better docs are needed to help people
figure out how to define a toolchain and what the different pieces me.

This gives some more explanation of the toolchain types, what they do, and how to
define them.

Along the way:

  • Add some more bazel objects to the inventory
  • Fix attribute lookups in the bazel inventory
  • Allow using parens in crossrefs, e.g. foo()

@rickeylev rickeylev requested a review from aignas as a code owner September 14, 2024 23:07
@rickeylev rickeylev force-pushed the docs.custom.toolchains branch from bea9e30 to 66691b5 Compare September 14, 2024 23:14
Copy link
Collaborator

@aignas aignas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot!

Python toolchains can be utilized in other bazel rules, such as `genrule()`, by adding the `toolchains=["@rules_python//python:current_py_toolchain"]` attribute. You can obtain the path to the Python interpreter using the `$(PYTHON2)` and `$(PYTHON3)` ["Make" Variables](https://bazel.build/reference/be/make-variables). See the
{gh-path}`test_current_py_toolchain <tests/load_from_macro/BUILD.bazel>` target for an example.

Python toolchains can be utilized in other bazel rules, such as `genrule()`, by
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, should we have a link to the bazel docs here?

Suggested change
Python toolchains can be utilized in other bazel rules, such as `genrule()`, by
Python toolchains can be utilized in other bazel rules, such as `genrule()`, by

attribute. You can obtain the path to the Python interpreter using the
`$(PYTHON2)` and `$(PYTHON3)` ["Make"
Variables](https://bazel.build/reference/be/make-variables). See the
{gh-path}`test_current_py_toolchain <tests/load_from_macro/BUILD.bazel>` target
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!


Defining toolchains for this might look something like this:

```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do our docs support this sort of highlighting?

Suggested change
```
```starlark

@rickeylev rickeylev added this pull request to the merge queue Sep 15, 2024
Merged via the queue into bazel-contrib:main with commit b3862ec Sep 15, 2024
@rickeylev rickeylev deleted the docs.custom.toolchains branch September 17, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants