Skip to content

Use headers attribute for toolchains only if it is set#3704

Merged
alexeagle merged 1 commit into
bazel-contrib:mainfrom
avdv:compat-node_cc_headers-optional
Nov 16, 2023
Merged

Use headers attribute for toolchains only if it is set#3704
alexeagle merged 1 commit into
bazel-contrib:mainfrom
avdv:compat-node_cc_headers-optional

Conversation

@avdv

@avdv avdv commented Nov 16, 2023

Copy link
Copy Markdown
Contributor

This effectively establishes backward compatibility with users of previous
rules_nodejs that create custom toolchains and do not pass the headers
attribute to node_toolchain which would otherwise fail with:

ERROR: /.../external/rules_haskell_nix_node_toolchain/BUILD:4:15: in node_toolchain rule @rules_haskell_nix_node_toolchain//:node_nixpkgs:
Traceback (most recent call last):
  File "/.../external/rules_nodejs/nodejs/toolchain.bzl", line 102, column 43, in _node_toolchain_impl
     "CcInfo": ctx.attr.headers[CcInfo],
Error: type \'NoneType\' has no operator [](Provider)

See comments in #3694

cc @DavidZbarsky-at

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: backward-compatibility enhancement

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No (quite contrary actually ;-))

Other information

This effectively establishes backward compatibility with users of previous
rules_nodejs that create custom toolchains and do not pass the `headers`
attribute to `node_toolchain` which would otherwise fail with:

```
ERROR: /.../external/rules_haskell_nix_node_toolchain/BUILD:4:15: in node_toolchain rule @rules_haskell_nix_node_toolchain//:node_nixpkgs:
Traceback (most recent call last):
  File "/.../external/rules_nodejs/nodejs/toolchain.bzl", line 102, column 43, in _node_toolchain_impl
     "CcInfo": ctx.attr.headers[CcInfo],
Error: type \'NoneType\' has no operator [](Provider)
```
@alexeagle alexeagle merged commit a040f89 into bazel-contrib:main Nov 16, 2023
@avdv avdv deleted the compat-node_cc_headers-optional branch November 17, 2023 07:26
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