Skip to content

Commit 2335af2

Browse files
committed
chore(rules): load from @rules_cc directly
per review comments
1 parent 875a44c commit 2335af2

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

d/private/rules/BUILD.bazel

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ bzl_library(
2323
"//docs:__subpackages__",
2424
],
2525
deps = [
26-
"@bazel_tools//tools/build_defs/cc:action_names.bzl",
27-
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
26+
"@rules_cc//cc:action_names_bzl",
27+
"@rules_cc//cc:find_cc_toolchain_bzl",
2828
"@rules_cc//cc/common",
29-
"@rules_cc//cc:find_cc_toolchain_bzl", # transitive dependency of @bazel_tools//tools/cpp:toolchain_utils.bzl
3029
],
3130
)
3231

@@ -54,7 +53,10 @@ bzl_library(
5453
"//d:__subpackages__",
5554
"//docs:__subpackages__",
5655
],
57-
deps = ["//d/private/rules:common"],
56+
deps = [
57+
"//d/private/rules:common",
58+
"@rules_cc//cc:find_cc_toolchain_bzl",
59+
],
5860
)
5961

6062
bzl_library(
@@ -64,5 +66,8 @@ bzl_library(
6466
"//d:__subpackages__",
6567
"//docs:__subpackages__",
6668
],
67-
deps = ["//d/private/rules:common"],
69+
deps = [
70+
"//d/private/rules:common",
71+
"@rules_cc//cc:find_cc_toolchain_bzl",
72+
],
6873
)

d/private/rules/binary.bzl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""D test rule for compiling binaries."""
22

3-
load(
4-
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
5-
"use_cpp_toolchain",
6-
)
3+
load("@rules_cc//cc:find_cc_toolchain.bzl", "use_cc_toolchain")
74
load("//d/private/rules:common.bzl", "TARGET_TYPE", "compilation_action", "runnable_attrs")
85

96
def _d_binary_impl(ctx):
@@ -13,7 +10,7 @@ def _d_binary_impl(ctx):
1310
d_binary = rule(
1411
implementation = _d_binary_impl,
1512
attrs = runnable_attrs,
16-
toolchains = ["//d:toolchain_type"] + use_cpp_toolchain(),
13+
toolchains = ["//d:toolchain_type"] + use_cc_toolchain(),
1714
fragments = ["cpp"],
1815
executable = True,
1916
)

d/private/rules/cc_toolchain.bzl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22
Helper functions to extract the C++ toolchain and linker options for linking.
33
"""
44

5-
load(
6-
"@bazel_tools//tools/build_defs/cc:action_names.bzl",
7-
"CPP_LINK_EXECUTABLE_ACTION_NAME",
8-
)
9-
load(
10-
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
11-
"find_cpp_toolchain",
12-
)
5+
load("@rules_cc//cc:action_names.bzl", "CPP_LINK_EXECUTABLE_ACTION_NAME")
6+
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
137
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
148

159
_UNSUPPORTED_FEATURES = [
@@ -67,7 +61,7 @@ def find_cc_toolchain_for_linking(ctx):
6761
- cc_linking_options: The linker options
6862
- env: The environment variables to set for the linker
6963
"""
70-
cc_toolchain = find_cpp_toolchain(ctx)
64+
cc_toolchain = find_cc_toolchain(ctx)
7165
feature_configuration = cc_common.configure_features(
7266
ctx = ctx,
7367
cc_toolchain = cc_toolchain,

d/private/rules/test.bzl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""D test rule for compiling and running D unit tests."""
22

3-
load(
4-
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
5-
"use_cpp_toolchain",
6-
)
3+
load("@rules_cc//cc:find_cc_toolchain.bzl", "use_cc_toolchain")
74
load("//d/private/rules:common.bzl", "TARGET_TYPE", "compilation_action", "runnable_attrs")
85

96
def _d_test_impl(ctx):
@@ -13,7 +10,7 @@ def _d_test_impl(ctx):
1310
d_test = rule(
1411
implementation = _d_test_impl,
1512
attrs = runnable_attrs,
16-
toolchains = ["//d:toolchain_type"] + use_cpp_toolchain(),
13+
toolchains = ["//d:toolchain_type"] + use_cc_toolchain(),
1714
fragments = ["cpp"],
1815
test = True,
1916
)

0 commit comments

Comments
 (0)