Skip to content

Commit 111e65b

Browse files
authored
fix: make CcInfo/cc dep in nodejs toolchain opt-in via include_headers attribute (#3760)
1 parent 2fdb873 commit 111e65b

File tree

20 files changed

+179
-68
lines changed

20 files changed

+179
-68
lines changed

.bazelci/presubmit.yml

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ tasks:
1616
- "--test_tag_filters=-skip-on-bazelci-ubuntu"
1717
test_targets:
1818
- "//..."
19+
ubuntu1804-headers:
20+
name: ubuntu1804-headers
21+
platform: ubuntu1804
22+
working_directory: "e2e/headers"
23+
build_targets:
24+
- "//..."
25+
test_flags:
26+
- "--test_tag_filters=-skip-on-bazelci-ubuntu"
27+
test_targets:
28+
- "//..."
1929
ubuntu1804-smoke:
2030
name: ubuntu1804-smoke
2131
platform: ubuntu1804
@@ -36,9 +46,28 @@ tasks:
3646
- "--test_tag_filters=-skip-on-bazelci-ubuntu"
3747
test_targets:
3848
- "//..."
39-
macos-smoke:
49+
macos:
4050
name: macos
4151
platform: macos
52+
build_targets:
53+
- "//..."
54+
test_flags:
55+
- "--test_tag_filters=-skip-on-bazelci-macos"
56+
test_targets:
57+
- "//..."
58+
macos-headers:
59+
name: macos-headers
60+
platform: macos
61+
working_directory: "e2e/headers"
62+
build_targets:
63+
- "//..."
64+
test_flags:
65+
- "--test_tag_filters=-skip-on-bazelci-macos"
66+
test_targets:
67+
- "//..."
68+
macos-smoke:
69+
name: macos-smoke
70+
platform: macos
4271
working_directory: "e2e/smoke"
4372
build_targets:
4473
- "//..."
@@ -66,12 +95,11 @@ tasks:
6695
- "--test_tag_filters=-skip-on-bazelci-windows"
6796
test_targets:
6897
- "//..."
69-
# Temporarily disabled RBE CI until cc toolchain failures are resolved
70-
# rbe_ubuntu1604-smoke:
71-
# name: rbe_ubuntu1604-smoke
72-
# platform: rbe_ubuntu1604
73-
# working_directory: "e2e/smoke"
74-
# build_targets:
75-
# - "//..."
76-
# test_targets:
77-
# - "//..."
98+
rbe_ubuntu1604-smoke:
99+
name: rbe_ubuntu1604-smoke
100+
platform: rbe_ubuntu1604
101+
working_directory: "e2e/smoke"
102+
build_targets:
103+
- "//..."
104+
test_targets:
105+
- "//..."

.bazelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ common --nolegacy_external_runfiles
2828
# https://bazelbuild.slack.com/archives/C014RARENH0/p1691158021917459?thread_ts=1691156601.420349&cid=C014RARENH0
2929
common --check_direct_dependencies=off
3030

31+
# In the root MODULE.bazel file we don't set include_headers on the nodejs toolchain
32+
# so the `//nodejs/headers:current_node_cc_headers`` target will not build. This target
33+
# is instead tested in `e2e/headers``
34+
common --deleted_packages=nodejs/headers
35+
3136
# Load any settings specific to the current user.
3237
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
3338
# This needs to be last statement in this

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
test:
2020
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v6
2121
with:
22-
folders: '[".", "e2e/smoke", "e2e/nodejs_host"]'
22+
folders: '[".", "e2e/headers", "e2e/smoke", "e2e/nodejs_host"]'
2323
# stardoc generated docs fail on diff_test with Bazel 6.4.0 so don't test against it in root repository
2424
exclude: |
2525
[

docs/Core.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ UserBuildSettingInfo(<a href="#UserBuildSettingInfo-value">value</a>)
3434

3535
<pre>
3636
nodejs_repositories(<a href="#nodejs_repositories-name">name</a>, <a href="#nodejs_repositories-node_download_auth">node_download_auth</a>, <a href="#nodejs_repositories-node_repositories">node_repositories</a>, <a href="#nodejs_repositories-node_urls">node_urls</a>, <a href="#nodejs_repositories-node_version">node_version</a>,
37-
<a href="#nodejs_repositories-node_version_from_nvmrc">node_version_from_nvmrc</a>, <a href="#nodejs_repositories-kwargs">kwargs</a>)
37+
<a href="#nodejs_repositories-node_version_from_nvmrc">node_version_from_nvmrc</a>, <a href="#nodejs_repositories-include_headers">include_headers</a>, <a href="#nodejs_repositories-kwargs">kwargs</a>)
3838
</pre>
3939

4040
To be run in user's WORKSPACE to install rules_nodejs dependencies.
@@ -143,6 +143,14 @@ If set then the version found in the .nvmrc file is used instead of the one spec
143143

144144
Defaults to `None`
145145

146+
<h4 id="nodejs_repositories-include_headers">include_headers</h4>
147+
148+
Set headers field in NodeInfo provided by this toolchain.
149+
150+
This setting creates a dependency on a c++ toolchain.
151+
152+
Defaults to `False`
153+
146154
<h4 id="nodejs_repositories-kwargs">kwargs</h4>
147155

148156
Additional parameters

e2e/headers/.bazelrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Specifies desired output mode for running tests.
2+
# Valid values are
3+
# 'summary' to output only test status summary
4+
# 'errors' to also print test logs for failed tests
5+
# 'all' to print logs for all tests
6+
# 'streamed' to output logs for all tests in real time
7+
# (this will force tests to be executed locally one at a time regardless of --test_strategy value).
8+
common --test_output=errors
9+
10+
# Turn on --incompatible_strict_action_env which was on by default
11+
# in Bazel 0.21.0 but turned off again in 0.22.0. Follow
12+
# https://github.com/bazelbuild/bazel/issues/7026 for more details.
13+
# This flag is needed to so that the bazel cache is not invalidated
14+
# when running bazel via `yarn bazel`.
15+
# See https://github.com/angular/angular/issues/27514.
16+
common --incompatible_strict_action_env
17+
18+
# Turn off legacy external runfiles
19+
# This prevents accidentally depending on this feature, which Bazel will remove.
20+
common --nolegacy_external_runfiles

e2e/headers/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.bazelversion

e2e/headers/BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cc_test(
2+
name = "using_headers_test",
3+
srcs = ["using_headers.cc"],
4+
copts = select({
5+
"@platforms//os:windows": ["/std:c++14"],
6+
"//conditions:default": ["-std=c++14"],
7+
}),
8+
target_compatible_with = select({
9+
# Windows does not ship headers in the release artifact so this won't work yet.
10+
"@platforms//os:windows": ["@platforms//:incompatible"],
11+
"//conditions:default": [],
12+
}),
13+
deps = ["@rules_nodejs//nodejs/headers:current_node_cc_headers"],
14+
)

e2e/headers/MODULE.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
bazel_dep(name = "rules_nodejs", version = "0.0.0", dev_dependency = True)
2+
local_path_override(
3+
module_name = "rules_nodejs",
4+
path = "../..",
5+
)
6+
7+
bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True)
8+
9+
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
10+
node.toolchain(include_headers = True)

e2e/headers/WORKSPACE.bazel

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
local_repository(
4+
name = "rules_nodejs",
5+
path = "../..",
6+
)
7+
8+
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
9+
10+
nodejs_register_toolchains(include_headers = True)
11+
12+
http_archive(
13+
name = "bazel_skylib",
14+
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
15+
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz"],
16+
)

e2e/headers/WORKSPACE.bzlmod

Whitespace-only changes.

0 commit comments

Comments
 (0)