Skip to content

Commit 092cea3

Browse files
keithpoletti-marco
authored andcommitted
Modernize bazel config
This makes this repo build with bzlmod. It also removes the empty linking context produced by `generate_fruit_config`. This works inside google but not with bazel. It also shouldn't be necessary since all this is doing is trying to propagate a header. Fixes bazelbuild/bazel#23488
1 parent 45cc058 commit 092cea3

19 files changed

Lines changed: 59 additions & 79 deletions

File tree

BUILD

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
12

23
package(default_visibility = ["//visibility:public"])
34
licenses(["notice"])
@@ -18,10 +19,13 @@ cc_library(
1819
"include/fruit/impl/**/*.h",
1920
]),
2021
hdrs = glob(["include/fruit/*.h"]),
21-
includes = ["include", "configuration/bazel"],
22+
includes = [
23+
"configuration/bazel",
24+
"include",
25+
],
26+
linkopts = ["-lm"],
2227
deps = [
23-
"@boost//:unordered",
2428
"//third_party/fruit/configuration/bazel:fruit-config-base",
29+
"@boost.unordered",
2530
],
26-
linkopts = ["-lm"],
2731
)

configuration/bazel/build_defs.bzl

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
load("@rules_cc//cc:action_names.bzl", "C_COMPILE_ACTION_NAME")
22
load("@rules_cc//cc:toolchain_utils.bzl", "find_cpp_toolchain")
3+
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
4+
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
35

46
def _generate_fruit_config_impl(ctx):
57
cc_toolchain = find_cpp_toolchain(ctx)
@@ -71,25 +73,9 @@ def _generate_fruit_config_impl(ctx):
7173
outputs = [merged_output_file],
7274
)
7375

74-
compilation_context, compilation_outputs = cc_common.compile(
75-
actions = ctx.actions,
76-
feature_configuration = feature_configuration,
77-
cc_toolchain = cc_toolchain,
78-
public_hdrs = [merged_output_file],
79-
name = "%s_link" % ctx.label.name,
80-
)
81-
82-
linking_context, linking_outputs = cc_common.create_linking_context_from_compilation_outputs(
83-
actions = ctx.actions,
84-
feature_configuration = feature_configuration,
85-
compilation_outputs = compilation_outputs,
86-
cc_toolchain = cc_toolchain,
87-
name = "%s_link" % ctx.label.name,
88-
)
89-
9076
return [
9177
DefaultInfo(files = depset([merged_output_file]), runfiles = ctx.runfiles(files = [merged_output_file])),
92-
CcInfo(compilation_context=compilation_context, linking_context=linking_context),
78+
CcInfo(compilation_context = cc_common.create_compilation_context(headers = depset([merged_output_file]))),
9379
]
9480

9581
generate_fruit_config = rule(
@@ -100,4 +86,4 @@ generate_fruit_config = rule(
10086
},
10187
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
10288
fragments = ["cpp"],
103-
)
89+
)

examples/annotated_injection/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
12

23
licenses(["notice"])
34

examples/hello_world/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
12

23
licenses(["notice"])
34

examples/multibindings/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
12

23
licenses(["notice"])
34

examples/scaling_doubles/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
12

23
licenses(["notice"])
34

examples/server/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
12

23
licenses(["notice"])
34

examples/simple_injection/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
13

24
licenses(["notice"])
35

examples/testing/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
3+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
14

25
licenses(["notice"])
36

extras/bazel_root/MODULE.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module(
2+
name = "fruit",
3+
version = "0",
4+
)
5+
6+
bazel_dep(name = "boost.unordered", version = "1.90.0.bcr.1")
7+
bazel_dep(name = "rules_cc", version = "0.2.17")
8+
bazel_dep(name = "rules_python", version = "1.0.0")
9+
10+
bazel_dep(name = "googletest", version = "1.17.0.bcr.2", dev_dependency = True, repo_name = "com_google_googletest")

0 commit comments

Comments
 (0)