Skip to content

Commit ee21b49

Browse files
committed
Fix Bazel 9 compatibility: add explicit load() for cc_* rules
Bazel 9 removed native cc_library, cc_test, and cc_binary rules from the global scope. They now require explicit load() statements from @rules_cc. - Add load("@rules_cc//cc:cc_library.bzl", "cc_library") to BUILD files - Add load("@rules_cc//cc:cc_test.bzl", "cc_test") to BUILD files - Update build_defs.bzl macros to use loaded cc_test instead of native.cc_test
1 parent 41c1b64 commit ee21b49

5 files changed

Lines changed: 15 additions & 6 deletions

File tree

compiler/back_end/cpp/build_defs.bzl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,29 @@
1616
# vim:set ft=blazebuild:
1717
"""Rule to generate cc_tests with and without system-specific optimizations."""
1818

19+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
1920
load("@rules_python//python:py_test.bzl", "py_test")
2021

2122
def emboss_cc_test(name, copts = None, no_w_sign_compare = False, **kwargs):
2223
"""Generates cc_test rules with and without -DEMBOSS_NO_OPTIMIZATIONS."""
23-
native.cc_test(
24+
cc_test(
2425
name = name,
2526
copts = copts or [],
2627
**kwargs
2728
)
28-
native.cc_test(
29+
cc_test(
2930
name = name + "_no_opts",
3031
copts = [
3132
"-DEMBOSS_NO_OPTIMIZATIONS",
3233
] + ([] if no_w_sign_compare else ["-Wsign-compare"]) + (copts or []),
3334
**kwargs
3435
)
35-
native.cc_test(
36+
cc_test(
3637
name = name + "_no_checks",
3738
copts = ["-DEMBOSS_SKIP_CHECKS"] + (copts or []),
3839
**kwargs
3940
)
40-
native.cc_test(
41+
cc_test(
4142
name = name + "_no_checks_no_opts",
4243
copts = [
4344
"-DEMBOSS_NO_OPTIMIZATIONS",

integration/googletest/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
16+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
17+
1518
cc_library(
1619
name = "emboss_test_util",
1720
testonly = 1,

runtime/cpp/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
# Emboss C++ Runtime.
1616

17+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
18+
1719
filegroup(
1820
name = "raw_headers",
1921
srcs = [

runtime/cpp/test/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Emboss public definitions.
1616

17+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
1718
load(
1819
":build_defs.bzl",
1920
"emboss_cc_util_test",

runtime/cpp/test/build_defs.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717

1818
"""Macro to run tests both with and without optimizations."""
1919

20+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
21+
2022
def emboss_cc_util_test(name, copts = [], **kwargs):
2123
"""Constructs two cc_test targets, with and without optimizations."""
22-
native.cc_test(
24+
cc_test(
2325
name = name,
2426
copts = copts + ["-Wsign-compare"],
2527
**kwargs
2628
)
27-
native.cc_test(
29+
cc_test(
2830
name = name + "_no_opts",
2931
copts = copts + [
3032
# This is generally a dangerous flag for an individual target, but

0 commit comments

Comments
 (0)