Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: give some general guidance on how to define custom toolchains #2220

Merged
merged 1 commit into from
Sep 15, 2024

Conversation

rickeylev
Copy link
Contributor

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()

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 bazelbuild:main with commit b3862ec Sep 15, 2024
4 checks passed
@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