Skip to content

Commit

Permalink
Fix failures at head
Browse files Browse the repository at this point in the history
Copybara Import from #353

BEGIN_PUBLIC
Fix failures at head (#353)

Closes #353
END_PUBLIC

COPYBARA_INTEGRATE_REVIEW=#353 from comius:fix-failures de049f8
PiperOrigin-RevId: 724296104
Change-Id: Icdc4c692446824803a3407c7a4d815687c1ae1df
  • Loading branch information
comius authored and copybara-github committed Feb 7, 2025
1 parent 3e5817b commit a116227
Show file tree
Hide file tree
Showing 30 changed files with 40 additions and 27 deletions.
1 change: 1 addition & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test_targets: &test_targets
- "//examples/..."
- "//tests/..."
- "-//examples/custom_toolchain:legacy_selector" # Example only works on Linux
- "-//tests/system_library:system_library_test" # Only intended to work in WORKSPACE files
- "-//tests/rule_based_toolchain/tool_map:_duplicate_action_test_subject" # Intentionally broken rule.

build_targets_bazel_6: &build_targets_bazel_6
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ register_toolchains("@local_config_cc_toolchains//:all")
bazel_dep(name = "rules_shell", version = "0.2.0", dev_dependency = True)
bazel_dep(name = "googletest", version = "1.15.2", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.7.0", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)
2 changes: 1 addition & 1 deletion cc/cc_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ def cc_binary(**attrs):
else:
attrs["deps"] = [_LINK_EXTRA_LIB]

# buildifier: disable=native-cc
# buildifier: disable=native-cc-binary
native.cc_binary(**attrs)
2 changes: 1 addition & 1 deletion cc/cc_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"""cc_import rule"""

def cc_import(**kwargs):
native.cc_import(**kwargs) # buildifier: disable=native-cc
native.cc_import(**kwargs) # buildifier: disable=native-cc-import
2 changes: 1 addition & 1 deletion cc/cc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"""cc_library rule"""

def cc_library(**kwargs):
native.cc_library(**kwargs) # buildifier: disable=native-cc
native.cc_library(**kwargs) # buildifier: disable=native-cc-library
2 changes: 1 addition & 1 deletion cc/cc_shared_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"""cc_library rule"""

def cc_shared_library(**kwargs):
native.cc_shared_library(**kwargs) # buildifier: disable=native-cc
native.cc_shared_library(**kwargs) # buildifier: disable=native-cc-shared-library
2 changes: 1 addition & 1 deletion cc/cc_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ def cc_test(**attrs):
else:
attrs["deps"] = [_LINK_EXTRA_LIB]

# buildifier: disable=native-cc
# buildifier: disable=native-cc-test
native.cc_test(**attrs)
2 changes: 2 additions & 0 deletions cc/common/cc_shared_library_hint_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
# limitations under the License.
"""CcSharedLibraryInfo"""

load("//cc/common:cc_common.bzl", "cc_common")

# Backward compatibility with Bazel 6
CcSharedLibraryHintInfo = getattr(cc_common, "CcSharedLibraryHintInfo", provider("CcSharedLibraryHintInfo", fields = ["attributes", "owners"]))
3 changes: 2 additions & 1 deletion cc/find_cc_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# 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.

"""
Helpers for CC Toolchains.
Expand Down Expand Up @@ -53,6 +52,8 @@ https://github.com/bazelbuild/bazel/issues/7260 is flipped (and support for old
Bazel version is not needed), it's enough to only keep the toolchain type.
"""

load("//cc/common:cc_common.bzl", "cc_common")

CC_TOOLCHAIN_TYPE = Label("@bazel_tools//tools/cpp:toolchain_type")

CC_TOOLCHAIN_ATTRS = {
Expand Down
2 changes: 1 addition & 1 deletion cc/objc_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"""objc_import rule"""

def objc_import(**kwargs):
native.objc_import(**kwargs) # buildifier: disable=native-cc
native.objc_import(**kwargs) # buildifier: disable=native-cc-objc-import
2 changes: 1 addition & 1 deletion cc/objc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"""objc_library rule"""

def objc_library(**kwargs):
native.objc_library(**kwargs) # buildifier: disable=native-cc
native.objc_library(**kwargs) # buildifier: disable=native-cc-objc-library
1 change: 1 addition & 0 deletions cc/private/rules_impl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bzl_library(
name = "cc_flags_supplier_lib_bzl",
srcs = ["cc_flags_supplier_lib.bzl"],
visibility = ["//cc:__subpackages__"],
deps = ["//cc/common"],
)

bzl_library(
Expand Down
2 changes: 2 additions & 0 deletions cc/private/rules_impl/cc_flags_supplier_lib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
"""Library of functions that provide the CC_FLAGS Make variable."""

load("//cc/common:cc_common.bzl", "cc_common")

# This should match the logic in CcCommon.computeCcFlags:
def build_cc_flags(ctx, cc_toolchain, action_name):
"""Determine the value for CC_FLAGS based on the given toolchain.
Expand Down
13 changes: 6 additions & 7 deletions cc/private/rules_impl/native.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@
# 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.

#
# Redefine native symbols with a new name as a workaround for
# exporting them in `//third_party/bazel_rules/rules_proto/proto:defs.bzl` with their original name.
#
# While we cannot force users to load these symbol due to the lack of a
# allowlisting mechanism, we can still export them and tell users to
# load it to make a future migration to pure Starlark easier.

"""Lovely workaround to be able to expose native constants pretending to be Starlark."""

# buildifier: disable=native-cc
# buildifier: disable=native-cc-info
NativeCcInfo = CcInfo

# buildifier: disable=native-cc
# buildifier: disable=native-cc-debug-package-info
NativeDebugPackageInfo = DebugPackageInfo

# buildifier: disable=native-cc
# buildifier: disable=native-cc-toolchain-config-info
NativeCcToolchainConfigInfo = CcToolchainConfigInfo

# buildifier: disable=native-cc
# buildifier: disable=native-cc-common
native_cc_common = cc_common

# buildifier: disable=native-cc
# buildifier: disable=native-cc-shared-library-info
NativeCcSharedLibraryInfo = CcSharedLibraryInfo
2 changes: 1 addition & 1 deletion cc/private/toolchain/armeabi_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
# 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.

"""A Starlark cc_toolchain configuration rule"""

load(
"@rules_cc//cc:cc_toolchain_config_lib.bzl",
"feature",
"tool_path",
)
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

def _impl(ctx):
toolchain_identifier = "stub_armeabi-v7a"
Expand Down
2 changes: 1 addition & 1 deletion cc/private/toolchain/bsd_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# 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.

"""A Starlark cc_toolchain configuration rule for FreeBSD and OpenBSD."""

load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES")
Expand All @@ -25,6 +24,7 @@ load(
"tool_path",
"with_feature_set",
) # buildifier: disable=deprecated-function
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

all_compile_actions = [
ACTION_NAMES.c_compile,
Expand Down
2 changes: 1 addition & 1 deletion cc/private/toolchain/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# 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.

"""A Starlark cc_toolchain configuration rule"""

load(
Expand Down Expand Up @@ -40,6 +39,7 @@ load(
"tool_path",
"with_feature_set",
)
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

all_compile_actions = [
_C_COMPILE_ACTION_NAME,
Expand Down
3 changes: 2 additions & 1 deletion cc/private/toolchain/empty_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
# 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.

"""A fake C++ toolchain configuration rule"""

load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

def _impl(ctx):
out = ctx.actions.declare_file(ctx.label.name)
ctx.actions.write(out, "Fake executable")
Expand Down
2 changes: 1 addition & 1 deletion cc/private/toolchain/unix_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# 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.

"""A Starlark cc_toolchain configuration rule"""

load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES")
Expand All @@ -30,6 +29,7 @@ load(
"variable_with_value",
"with_feature_set",
)
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

def _target_os_version(ctx):
platform_type = ctx.fragments.apple.single_arch_platform.platform_type
Expand Down
2 changes: 1 addition & 1 deletion cc/private/toolchain/windows_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# 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.

"""A Starlark cc_toolchain configuration rule for Windows"""

load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES")
Expand All @@ -30,6 +29,7 @@ load(
"variable_with_value",
"with_feature_set",
)
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

all_compile_actions = [
ACTION_NAMES.c_compile,
Expand Down
2 changes: 1 addition & 1 deletion cc/toolchains/cc_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"""cc_toolchain rule"""

def cc_toolchain(**kwargs):
native.cc_toolchain(**kwargs) # buildifier: disable=native-cc
native.cc_toolchain(**kwargs) # buildifier: disable=native-cc-toolchain
2 changes: 1 addition & 1 deletion cc/toolchains/cc_toolchain_suite.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"""cc_toolchain_suite rule"""

def cc_toolchain_suite(**kwargs):
native.cc_toolchain_suite(**kwargs) # buildifier: disable=native-cc
native.cc_toolchain_suite(**kwargs) # buildifier: disable=native-cc-toolchain-suite
2 changes: 1 addition & 1 deletion cc/toolchains/fdo_prefetch_hints.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"""fdo_prefetch_hints rule"""

def fdo_prefetch_hints(**kwargs):
native.fdo_prefetch_hints(**kwargs) # buildifier: disable=native-cc
native.fdo_prefetch_hints(**kwargs) # buildifier: disable=native-cc-fdo-prefetch-hints
2 changes: 1 addition & 1 deletion cc/toolchains/fdo_profile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"""fdo_profile rule"""

def fdo_profile(**kwargs):
native.fdo_profile(**kwargs) # buildifier: disable=native-cc
native.fdo_profile(**kwargs) # buildifier: disable=native-cc-fdo-profile
1 change: 1 addition & 0 deletions cc/toolchains/impl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ bzl_library(
name = "toolchain_impl_rules",
srcs = glob(["*.bzl"]),
visibility = ["//cc/toolchains:__subpackages__"],
deps = ["//cc/common"],
)
1 change: 1 addition & 0 deletions cc/toolchains/impl/toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
"""Implementation of the cc_toolchain rule."""

load("//cc/common:cc_common.bzl", "cc_common")
load(
"//cc/toolchains:cc_toolchain_info.bzl",
"ActionTypeSetInfo",
Expand Down
1 change: 1 addition & 0 deletions examples/custom_toolchain/toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ advanced usage.
"""

load("@rules_cc//cc:cc_toolchain_config_lib.bzl", "tool_path") # buildifier: disable=deprecated-function
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

def _impl(ctx):
tool_paths = [
Expand Down
2 changes: 1 addition & 1 deletion examples/experimental_cc_shared_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def cc_shared_library_permissions(**kwargs):
native.cc_shared_library_permissions(**kwargs)

def cc_shared_library(**kwargs):
native.cc_shared_library(**kwargs)
native.cc_shared_library(**kwargs) # buildifier: disable=native-cc-shared-library
2 changes: 2 additions & 0 deletions examples/my_c_archive/my_c_archive.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

load("@rules_cc//cc:action_names.bzl", "CPP_LINK_STATIC_LIBRARY_ACTION_NAME")
load("@rules_cc//cc:find_cc_toolchain.bzl", "CC_TOOLCHAIN_ATTRS", "find_cpp_toolchain", "use_cc_toolchain")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load("//examples/my_c_compile:my_c_compile.bzl", "MyCCompileInfo")

def _my_c_archive_impl(ctx):
Expand Down
1 change: 1 addition & 0 deletions examples/my_c_compile/my_c_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

load("@rules_cc//cc:action_names.bzl", "C_COMPILE_ACTION_NAME")
load("@rules_cc//cc:find_cc_toolchain.bzl", "CC_TOOLCHAIN_ATTRS", "find_cpp_toolchain", "use_cc_toolchain")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

MyCCompileInfo = provider(doc = "", fields = ["object"])

Expand Down

0 comments on commit a116227

Please sign in to comment.