Enable C++ rules and providers
PiperOrigin-RevId: 834233788
Change-Id: Ia75c16711dcf08133dadca4fd2d7edd445caab63
diff --git a/cc/common/BUILD b/cc/common/BUILD
index c8c6f73..d564807 100644
--- a/cc/common/BUILD
+++ b/cc/common/BUILD
@@ -17,17 +17,13 @@
bzl_library(
name = "common",
- srcs = glob(
- ["*.bzl"],
- exclude = [
- "cc_helper.bzl",
- "cc_debug_helper.bzl",
- "visibility.bzl",
- "semantics.bzl",
- "cc_helper_internal.bzl",
- "cc_shared_library_info.bzl",
- ],
- ),
+ srcs = [
+ "cc_common.bzl",
+ "cc_info.bzl",
+ "cc_shared_library_hint_info.bzl",
+ "debug_package_info.bzl",
+ "objc_info.bzl",
+ ],
visibility = ["//visibility:public"],
deps = [
"//cc/private:cc_internal_bzl",
@@ -57,7 +53,7 @@
srcs = ["cc_shared_library_info.bzl"],
visibility = ["//cc:__subpackages__"],
deps = [
- "@cc_compatibility_proxy//:proxy_bzl",
+ "@cc_compatibility_proxy//:symbols_bzl",
],
)
diff --git a/cc/common/cc_helper_internal.bzl b/cc/common/cc_helper_internal.bzl
index 317d8b2..fbf4078 100644
--- a/cc/common/cc_helper_internal.bzl
+++ b/cc/common/cc_helper_internal.bzl
@@ -84,6 +84,7 @@
("", "third_party/bazel_rules/rules_python"),
# Various
("", "research/colab"),
+ ("", "javatests/com/google/devtools/grok/kythe"),
] + CREATE_COMPILE_ACTION_API_ALLOWLISTED_PACKAGES
_CC_SOURCE = [".cc", ".cpp", ".cxx", ".c++", ".C", ".cu", ".cl"]
diff --git a/cc/common/cc_shared_library_info.bzl b/cc/common/cc_shared_library_info.bzl
index db42d78..a108ca5 100644
--- a/cc/common/cc_shared_library_info.bzl
+++ b/cc/common/cc_shared_library_info.bzl
@@ -13,6 +13,6 @@
# limitations under the License.
"""CcSharedLibraryInfo"""
-load("@cc_compatibility_proxy//:proxy.bzl", _CcSharedLibraryInfo = "CcSharedLibraryInfo")
+load("@cc_compatibility_proxy//:symbols.bzl", _CcSharedLibraryInfo = "CcSharedLibraryInfo")
CcSharedLibraryInfo = _CcSharedLibraryInfo
diff --git a/cc/extensions.bzl b/cc/extensions.bzl
index f98e588..be14af2 100644
--- a/cc/extensions.bzl
+++ b/cc/extensions.bzl
@@ -48,6 +48,7 @@
srcs = ["symbols.bzl"],
deps = [
"@rules_cc//cc/private:cc_common",
+ "@rules_cc//cc/private:cc_shared_library_info_bzl",
"@rules_cc//cc/private/toolchain_config:toolchain_config_bzl",
],
visibility = ["@rules_cc//cc:__subpackages__"],
@@ -60,7 +61,7 @@
load("@rules_cc//cc/private/rules_impl:cc_binary.bzl", _cc_binary = "cc_binary")
load("@rules_cc//cc/private/rules_impl:cc_import.bzl", _cc_import = "cc_import")
load("@rules_cc//cc/private/rules_impl:cc_library.bzl", _cc_library = "cc_library")
-load("@rules_cc//cc/private/rules_impl:cc_shared_library.bzl", _cc_shared_library = "cc_shared_library", _CcSharedLibraryInfo = "CcSharedLibraryInfo")
+load("@rules_cc//cc/private/rules_impl:cc_shared_library.bzl", _cc_shared_library = "cc_shared_library")
load("@rules_cc//cc/private/rules_impl:cc_static_library.bzl", _cc_static_library = "cc_static_library")
load("@rules_cc//cc/private/rules_impl:cc_test.bzl", _cc_test = "cc_test")
load("@rules_cc//cc/private/rules_impl:objc_import.bzl", _objc_import = "objc_import")
@@ -86,8 +87,6 @@
propeller_optimize = _propeller_optimize
cc_toolchain = _cc_toolchain
cc_toolchain_alias = _cc_toolchain_alias
-
-CcSharedLibraryInfo = _CcSharedLibraryInfo
""",
)
rctx.file(
@@ -95,9 +94,10 @@
"""
load("@rules_cc//cc/private:cc_common.bzl", _cc_common = "cc_common")
load("@rules_cc//cc/private:cc_info.bzl", _CcInfo = "CcInfo")
-load("@rules_cc//cc/private/toolchain_config:cc_toolchain_config_info.bzl", _CcToolchainConfigInfo = "CcToolchainConfigInfo")
+load("@rules_cc//cc/private:cc_shared_library_info.bzl", _CcSharedLibraryInfo = "CcSharedLibraryInfo")
load("@rules_cc//cc/private:debug_package_info.bzl", _DebugPackageInfo = "DebugPackageInfo")
load("@rules_cc//cc/private:objc_info.bzl", _ObjcInfo = "ObjcInfo")
+load("@rules_cc//cc/private/toolchain_config:cc_toolchain_config_info.bzl", _CcToolchainConfigInfo = "CcToolchainConfigInfo")
cc_common = _cc_common
CcInfo = _CcInfo
@@ -105,6 +105,7 @@
CcToolchainConfigInfo = _CcToolchainConfigInfo
ObjcInfo = _ObjcInfo
new_objc_provider = _ObjcInfo
+CcSharedLibraryInfo = _CcSharedLibraryInfo
""",
)
else:
diff --git a/cc/private/BUILD b/cc/private/BUILD
index ef001e8..41575bc 100644
--- a/cc/private/BUILD
+++ b/cc/private/BUILD
@@ -90,6 +90,15 @@
)
bzl_library(
+ name = "cc_shared_library_info_bzl",
+ srcs = ["cc_shared_library_info.bzl"],
+ visibility = [
+ "//cc:__subpackages__",
+ "@cc_compatibility_proxy//:__pkg__",
+ ],
+)
+
+bzl_library(
name = "cc_shared_library_hint_info_bzl",
srcs = ["cc_shared_library_hint_info.bzl"],
visibility = ["//cc:__subpackages__"],
diff --git a/cc/private/cc_shared_library_info.bzl b/cc/private/cc_shared_library_info.bzl
new file mode 100644
index 0000000..a9cd71d
--- /dev/null
+++ b/cc/private/cc_shared_library_info.bzl
@@ -0,0 +1,27 @@
+# Copyright 2025 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""CcSharedLibraryInfo"""
+
+CcSharedLibraryInfo = provider(
+ "Information about a cc shared library.",
+ fields = {
+ "dynamic_deps": "All shared libraries depended on transitively",
+ "exports": "cc_libraries that are linked statically and exported",
+ "link_once_static_libs": "All libraries linked statically into this library that should " +
+ "only be linked once, e.g. because they have static " +
+ "initializers. If we try to link them more than once, " +
+ "we will throw an error",
+ "linker_input": "the resulting linker input artifact for the shared library",
+ },
+)
diff --git a/cc/private/rules_impl/BUILD b/cc/private/rules_impl/BUILD
index e83f84b..9f9ab06 100644
--- a/cc/private/rules_impl/BUILD
+++ b/cc/private/rules_impl/BUILD
@@ -55,10 +55,12 @@
],
deps = [
":objc_common",
+ ":objc_compilation_support_bzl",
"//cc:action_names_bzl",
"//cc:find_cc_toolchain_bzl",
"//cc/common",
"//cc/common:cc_debug_helper_bzl",
+ "//cc/common:cc_shared_library_info_bzl",
"@bazel_skylib//lib:paths",
"@com_google_protobuf//bazel/common:proto_info_bzl",
],
@@ -103,6 +105,20 @@
)
bzl_library(
+ name = "objc_compilation_support_bzl",
+ srcs = ["objc_compilation_support.bzl"],
+ visibility = [
+ "//cc:__subpackages__",
+ "//third_party/bazel_rules/rules_apple/apple:__subpackages__",
+ ],
+ deps = [
+ ":objc_common",
+ "//cc/common:cc_helper_bzl",
+ "@bazel_skylib//lib:paths",
+ ],
+)
+
+bzl_library(
name = "native_bzl",
srcs = ["native.bzl"],
visibility = [
diff --git a/cc/private/rules_impl/cc_shared_library.bzl b/cc/private/rules_impl/cc_shared_library.bzl
index de232a5..41c4316 100644
--- a/cc/private/rules_impl/cc_shared_library.bzl
+++ b/cc/private/rules_impl/cc_shared_library.bzl
@@ -21,6 +21,7 @@
load("//cc/common:cc_helper.bzl", "cc_helper")
load("//cc/common:cc_info.bzl", "CcInfo")
load("//cc/common:cc_shared_library_hint_info.bzl", "CcSharedLibraryHintInfo")
+load("//cc/common:cc_shared_library_info.bzl", "CcSharedLibraryInfo")
load("//cc/common:semantics.bzl", "semantics")
# TODO(#5200): Add export_define to library_to_link and cc_library
@@ -39,18 +40,6 @@
"linkable_more_than_once": "Linkable into more than a single cc_shared_library",
}, # buildifier: disable=unsorted-dict-items
)
-CcSharedLibraryInfo = provider(
- "Information about a cc shared library.",
- fields = {
- "dynamic_deps": "All shared libraries depended on transitively",
- "exports": "cc_libraries that are linked statically and exported",
- "link_once_static_libs": "All libraries linked statically into this library that should " +
- "only be linked once, e.g. because they have static " +
- "initializers. If we try to link them more than once, " +
- "we will throw an error",
- "linker_input": "the resulting linker input artifact for the shared library",
- },
-)
def _programmatic_error(message = ""):
fail("Your build has triggered a programmatic error in the cc_shared_library rule. " +
diff --git a/cc/toolchains/BUILD b/cc/toolchains/BUILD
index 00c17e3..5ebf9c8 100644
--- a/cc/toolchains/BUILD
+++ b/cc/toolchains/BUILD
@@ -25,6 +25,8 @@
"//cc/private:paths_bzl",
"//cc/private/rules_impl:cc_flags_supplier_lib_bzl",
"//cc/private/rules_impl:native_bzl",
+ "//cc/private/rules_impl:toolchain_rules",
+ "//cc/private/rules_impl/fdo:fdo_rules",
"//cc/toolchains/impl:toolchain_impl_rules",
"@bazel_skylib//rules/directory:glob",
"@cc_compatibility_proxy//:proxy_bzl",