Fix bzl_library deps for `//cc/common`
Copybara Import from https://github.com/bazelbuild/rules_cc/pull/513
BEGIN_PUBLIC
Fix bzl_library deps for `//cc/common` (#513)
Broken by https://github.com/bazelbuild/rules_cc/commit/b81a4f4808d05c1d9d62be90d6188b8acdc9794f
Closes #513
END_PUBLIC
PiperOrigin-RevId: 827898310
Change-Id: I72f929c48cac16911ae23e8ec6d6a9d1f14d51ca
diff --git a/cc/BUILD b/cc/BUILD
index a71d94a..21e5708 100644
--- a/cc/BUILD
+++ b/cc/BUILD
@@ -118,6 +118,7 @@
deps = [
":core_rules",
"//cc/common",
+ "//cc/common:cc_helper_bzl",
"//cc/private/rules_impl:failing_cc_proto_library_bzl",
"//cc/toolchains:toolchain_rules",
],
diff --git a/cc/common/BUILD b/cc/common/BUILD
index 3e16a9b..ee378d2 100644
--- a/cc/common/BUILD
+++ b/cc/common/BUILD
@@ -13,15 +13,28 @@
# limitations under the License.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
+load("//cc:starlark_doc_extract_helper.bzl", "starlark_doc_extract_helper")
bzl_library(
name = "common",
- srcs = glob(["*.bzl"]),
+ srcs = glob(
+ ["*.bzl"],
+ exclude = [
+ "cc_helper.bzl",
+ "cc_debug_helper.bzl",
+ "visibility.bzl",
+ "semantics.bzl",
+ "cc_helper_internal.bzl",
+ "cc_shared_library_info.bzl",
+ ],
+ ),
visibility = ["//visibility:public"],
deps = [
"//cc/private:cc_internal_bzl",
"//cc/private:paths_bzl",
"//cc/private/rules_impl:native_bzl",
+ "@bazel_skylib//lib:paths",
+ "@cc_compatibility_proxy//:symbols_bzl",
],
)
@@ -37,6 +50,32 @@
)
bzl_library(
+ name = "cc_shared_library_info_bzl",
+ srcs = ["cc_shared_library_info.bzl"],
+ visibility = ["//cc:__subpackages__"],
+ deps = [
+ "@cc_compatibility_proxy//:proxy_bzl",
+ ],
+)
+
+bzl_library(
+ name = "semantics_bzl",
+ srcs = ["semantics.bzl"],
+ visibility = ["//cc:__subpackages__"],
+)
+
+bzl_library(
+ name = "cc_helper_internal_bzl",
+ srcs = ["cc_helper_internal.bzl"],
+ visibility = ["//cc:__subpackages__"],
+ deps = [
+ "//cc/private:cc_internal_bzl",
+ "//cc/private:paths_bzl",
+ "@bazel_skylib//lib:paths",
+ ],
+)
+
+bzl_library(
name = "cc_debug_helper_bzl",
srcs = ["cc_debug_helper.bzl"],
visibility = ["//visibility:public"],
@@ -61,3 +100,23 @@
]),
visibility = ["//visibility:public"],
)
+
+# unused targets to test that we have the right bzl_library graph
+[starlark_doc_extract_helper(
+ name = f + "_doc_extract",
+ src = f,
+ visibility = ["//visibility:private"],
+ deps = [
+ ":common",
+ ],
+) for f in glob(
+ ["*.bzl"],
+ exclude = [
+ "cc_helper.bzl",
+ "cc_debug_helper.bzl",
+ "visibility.bzl",
+ "semantics.bzl",
+ "cc_helper_internal.bzl",
+ "cc_shared_library_info.bzl",
+ ],
+)]
diff --git a/cc/common/cc_helper_internal.bzl b/cc/common/cc_helper_internal.bzl
index 946b160..0192679 100644
--- a/cc/common/cc_helper_internal.bzl
+++ b/cc/common/cc_helper_internal.bzl
@@ -283,7 +283,8 @@
ctx: The rule context.
Returns:
- (int): 1: Always stamp the build information into the binary, even in [--nostamp][stamp] builds.
+ (int) Possible values are:
+ 1: Always stamp the build information into the binary, even in [--nostamp][stamp] builds.
This setting should be avoided, since it potentially kills remote caching for the binary and
any downstream actions that depend on it.
0: Always replace build information by constant values. This gives good build result caching.
@@ -348,6 +349,7 @@
Args:
file: (File) The file to get the root-relative path for.
+
Returns:
(str) The root-relative path of the file.
"""
diff --git a/cc/extensions.bzl b/cc/extensions.bzl
index e721eee..690936e 100644
--- a/cc/extensions.bzl
+++ b/cc/extensions.bzl
@@ -35,7 +35,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "proxy_bzl",
- srcs = ["proxy.bzl", "symbols.bzl"],
+ srcs = ["proxy.bzl"],
deps = [
"@rules_cc//cc/private/rules_impl:core_rules",
"@rules_cc//cc/private/rules_impl:toolchain_rules",
@@ -43,6 +43,15 @@
],
visibility = ["@rules_cc//cc:__subpackages__"],
)
+bzl_library(
+ name = "symbols_bzl",
+ srcs = ["symbols.bzl"],
+ deps = [
+ "@rules_cc//cc/private:cc_common",
+ "@rules_cc//cc/private/toolchain_config:toolchain_config_bzl",
+ ],
+ visibility = ["@rules_cc//cc:__subpackages__"],
+)
""",
)
rctx.file(
@@ -105,7 +114,13 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "proxy_bzl",
- srcs = ["proxy.bzl", "symbols.bzl"],
+ srcs = ["proxy.bzl"],
+ deps = ["@rules_cc//cc/private/rules_impl:native_bzl"],
+ visibility = ["@rules_cc//cc:__subpackages__"],
+)
+bzl_library(
+ name = "symbols_bzl",
+ srcs = ["symbols.bzl"],
deps = ["@rules_cc//cc/private/rules_impl:native_bzl"],
visibility = ["@rules_cc//cc:__subpackages__"],
)
diff --git a/cc/private/BUILD b/cc/private/BUILD
index afc3021..ef001e8 100644
--- a/cc/private/BUILD
+++ b/cc/private/BUILD
@@ -65,6 +65,7 @@
":objc_info_bzl",
"//cc/private/compile:compile_bzl",
"//cc/private/link:link_bzl",
+ "//cc/private/rules_impl:cc_toolchain_info_bzl",
"//cc/private/rules_impl:native_bzl",
"//cc/private/toolchain_config:toolchain_config_bzl",
],
@@ -98,7 +99,7 @@
name = "cc_launcher_info_bzl",
srcs = ["cc_launcher_info.bzl"],
visibility = ["//cc:__subpackages__"],
- deps = ["//cc/common"],
+ deps = ["//cc/common:cc_helper_internal_bzl"],
)
bzl_library(
diff --git a/cc/private/compile/BUILD b/cc/private/compile/BUILD
index d9dbaab..bd0daa3 100644
--- a/cc/private/compile/BUILD
+++ b/cc/private/compile/BUILD
@@ -20,7 +20,7 @@
visibility = ["//visibility:public"],
deps = [
"//cc:action_names_bzl",
- "//cc/common",
+ "//cc/common:semantics_bzl",
"//cc/private:cc_internal_bzl",
"//cc/private/rules_impl:native_bzl",
"@bazel_skylib//lib:paths",
diff --git a/cc/private/link/BUILD b/cc/private/link/BUILD
index 1ad72b4..82a64d5 100644
--- a/cc/private/link/BUILD
+++ b/cc/private/link/BUILD
@@ -20,7 +20,7 @@
visibility = ["//visibility:public"],
deps = [
"//cc:action_names_bzl",
- "//cc/common",
+ "//cc/common:semantics_bzl",
"//cc/private:cc_internal_bzl",
"//cc/private/compile:compile_bzl",
"//cc/private/rules_impl:native_bzl",
diff --git a/cc/private/rules_impl/BUILD b/cc/private/rules_impl/BUILD
index 501285f..8c7f257 100644
--- a/cc/private/rules_impl/BUILD
+++ b/cc/private/rules_impl/BUILD
@@ -56,6 +56,7 @@
"//cc:action_names_bzl",
"//cc:find_cc_toolchain_bzl",
"//cc/common",
+ "//cc/common:cc_debug_helper_bzl",
"@bazel_skylib//lib:paths",
"@com_google_protobuf//bazel/common:proto_info_bzl",
],
@@ -111,3 +112,12 @@
"@cc_compatibility_proxy//:__pkg__",
],
)
+
+bzl_library(
+ name = "cc_toolchain_info_bzl",
+ srcs = ["cc_toolchain_info.bzl"],
+ visibility = [
+ "//cc:__subpackages__",
+ "@cc_compatibility_proxy//:__pkg__",
+ ],
+)
diff --git a/cc/private/toolchain_config/BUILD b/cc/private/toolchain_config/BUILD
index ef52a72..4de3e2a 100644
--- a/cc/private/toolchain_config/BUILD
+++ b/cc/private/toolchain_config/BUILD
@@ -21,7 +21,7 @@
deps = [
"//cc:action_names_bzl",
"//cc:cc_toolchain_config_lib_bzl",
- "//cc/common",
+ "//cc/common:semantics_bzl",
"//cc/private:cc_internal_bzl",
"//cc/private/rules_impl:native_bzl",
"@bazel_skylib//lib:paths",
diff --git a/cc/starlark_doc_extract_helper.bzl b/cc/starlark_doc_extract_helper.bzl
index 5b0f7a1..6c145f3 100644
--- a/cc/starlark_doc_extract_helper.bzl
+++ b/cc/starlark_doc_extract_helper.bzl
@@ -1,6 +1,6 @@
"""Indirection to avoid breaking on Bazel 6"""
-visibility("private")
+visibility("//cc/...")
def starlark_doc_extract_helper(**kwargs):
"""Creates a starlark_doc_extract target if the native rule is available