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

Split :toolchain_type to correctly cover all use cases #3800

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Silic0nS0ldier
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #3795

See issue for details.

What is the new behavior?

  • Split @rules_nodejs//nodejs:toolchain_type into @rules_nodejs//nodejs:runtime_toolchain_type and @rules_nodejs//nodejs:exec_runtime_toolchain_type.
  • @rules_nodejs//nodejs:runtime_toolchain_type is suited towards usage in the target environment (e.g. runtime for *_binary rule outputs).
  • @rules_nodejs//nodejs:exec_runtime_toolchain_type is suited towards usage within rule actions (e.g. running NodeJS directly).
  • Split behaviour is disabled by default, controlled by a new attribute incompatible_split_toolchains on;
    • node.toolchain module extension tag.
    • nodejs_register_toolchains macro.
    • nodejs_toolchains_repo repository rule (private API).
  • :resolved_toolchain target moved into @rules_nodejs//nodejs. This makes it possible to access a NodeJS toolchain implementation without needing to know the name of a user controlled generated repository (e.g. for use inside a genrule defined in another ruleset).
  • Add new toolchain type @rules_nodejs//nodejs:compilation_toolchain_type suited to usage of NodeJS as a compiler (e.g. for snapshot generation) when the exec and target platforms need to be aligned. The exact platforms can still be different, but they should at least be compatible across OS and CPU.

Does this PR introduce a breaking change?

  • Yes
  • No (but does add deprecations)

Other information

Extra TODO

  • Update issue references to point to this PR.

Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

I imagine this is approximately what needs to happen, thanks for working on it!

Is there an issue (or maybe several) which could be linked from here?
I'm not sure who's best suited to do the review, among folks in the bazel-contrib org there are certainly a few experts on toolchain types and resolution.

@fmeum
Copy link
Member

fmeum commented Jan 2, 2025

Instead of an incompatible attribute on repo rules and module extensions, it may be possible to temporarily make the new toolchain types label_flags that by default point to the old toolchain type for backwards compatibility. Enabling the new behavior would then require setting the label_flag to a new distinct type. That's a much smaller API surface and dropping the flag would only require .bazelrc changes, no source changes.

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.

3 participants