Skip to content

Commit

Permalink
chore: remove references to @rules_cc//cc:defs.bzl (#2293)
Browse files Browse the repository at this point in the history
Referring to @rules_cc//cc:defs.bzl, refers to
@protobuf//bazel:cc_proto_library.bzl, which fetches protobuf
repository.
Referring directly to what's needed limits the fetches just to rules_cc.

Fix reference to bzl libs in rules_cc that are needed for docs
generation.

This requires rules_cc 0.0.13 or higher.

Work towards #2387,
#2378

---------

Co-authored-by: Richard Levasseur <[email protected]>
  • Loading branch information
comius and rickeylev authored Nov 12, 2024
1 parent 4864d63 commit 576e6dc
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 18 deletions.
6 changes: 4 additions & 2 deletions python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ bzl_library(
],
)

# @rules_cc does not offer a bzl_library target for @rules_cc//cc:defs.bzl
bzl_library(
name = "rules_cc_srcs_bzl",
srcs = [
Expand All @@ -644,7 +643,10 @@ bzl_library(
"@rules_cc//cc/common",
"@rules_cc//cc/toolchains:toolchain_rules",
],
deps = [":bazel_tools_bzl"],
deps = [
":bazel_tools_bzl",
"@rules_cc//cc/common",
],
)

bzl_library(
Expand Down
2 changes: 1 addition & 1 deletion python/private/attributes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""Attributes for Python rules."""

load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@rules_cc//cc:defs.bzl", "CcInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load(":common.bzl", "union_attrs")
load(":enum.bzl", "enum")
load(":flags.bzl", "PrecompileFlag", "PrecompileSourceRetentionFlag")
Expand Down
3 changes: 2 additions & 1 deletion python/private/common_bazel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@rules_cc//cc:defs.bzl", "CcInfo", "cc_common")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load(":attributes.bzl", "PrecompileAttr", "PrecompileInvalidationModeAttr", "PrecompileSourceRetentionAttr")
load(":common.bzl", "is_bool")
load(":flags.bzl", "PrecompileFlag")
Expand Down
2 changes: 1 addition & 1 deletion python/private/current_py_cc_headers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Implementation of current_py_cc_headers rule."""

load("@rules_cc//cc:defs.bzl", "CcInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")

def _current_py_cc_headers_impl(ctx):
py_cc_toolchain = ctx.toolchains["//python/cc:toolchain_type"].py_cc_toolchain
Expand Down
2 changes: 1 addition & 1 deletion python/private/current_py_cc_libs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Implementation of current_py_cc_libs rule."""

load("@rules_cc//cc:defs.bzl", "CcInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")

def _current_py_cc_libs_impl(ctx):
py_cc_toolchain = ctx.toolchains["//python/cc:toolchain_type"].py_cc_toolchain
Expand Down
3 changes: 2 additions & 1 deletion python/private/hermetic_runtime_repo_setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.
"""Setup a python-build-standalone based toolchain."""

load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library")
load("@rules_cc//cc:cc_import.bzl", "cc_import")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//python:py_runtime.bzl", "py_runtime")
load("//python:py_runtime_pair.bzl", "py_runtime_pair")
load("//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
Expand Down
2 changes: 1 addition & 1 deletion python/private/local_runtime_repo_setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Setup code called by the code generated by `local_runtime_repo`."""

load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//python:py_runtime.bzl", "py_runtime")
load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair")
load("@rules_python//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
Expand Down
2 changes: 1 addition & 1 deletion python/private/py_cc_link_params_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Providers for Python rules."""

load("@rules_cc//cc:defs.bzl", "CcInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load(":util.bzl", "define_bazel_6_provider")

DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python3"
Expand Down
2 changes: 1 addition & 1 deletion python/private/py_cc_toolchain_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ https://github.com/bazelbuild/rules_python/issues/824 is considered done.
"""

load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@rules_cc//cc:defs.bzl", "CcInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load(":py_cc_toolchain_info.bzl", "PyCcToolchainInfo")

def _py_cc_toolchain_impl(ctx):
Expand Down
2 changes: 1 addition & 1 deletion python/private/py_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//lib:structs.bzl", "structs")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@rules_cc//cc:defs.bzl", "cc_common")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load(
":attributes.bzl",
"AGNOSTIC_EXECUTABLE_ATTRS",
Expand Down
1 change: 1 addition & 0 deletions python/private/py_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def py_repositories():
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"],
)

# Needed by rules_cc, triggerred by @rules_java_prebuilt in Bazel by using @rules_cc//cc:defs.bzl
http_archive(
name = "protobuf",
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
Expand Down
2 changes: 1 addition & 1 deletion python/private/runtime_env_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""Definitions related to the Python toolchain."""

load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//python:py_runtime.bzl", "py_runtime")
load("//python:py_runtime_pair.bzl", "py_runtime_pair")
load("//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
Expand Down
2 changes: 1 addition & 1 deletion python/private/whl_filegroup/whl_filegroup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ An empty pattern will match all files.
Example usage:
```starlark
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_python//python:pip.bzl", "whl_filegroup")
whl_filegroup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Tests for current_py_cc_headers."""

load("@rules_cc//cc:defs.bzl", "CcInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite")
load("@rules_testing//lib:truth.bzl", "matching")
load("//tests/support:cc_info_subject.bzl", "cc_info_subject")
Expand Down
2 changes: 1 addition & 1 deletion tests/cc/current_py_cc_libs/current_py_cc_libs_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Tests for current_py_cc_libs."""

load("@rules_cc//cc:defs.bzl", "CcInfo")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite")
load("@rules_testing//lib:truth.bzl", "matching")
load("//tests/support:cc_info_subject.bzl", "cc_info_subject")
Expand Down
3 changes: 2 additions & 1 deletion tests/support/cc_toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite")
load("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain")
load("@rules_cc//cc/toolchains:cc_toolchain_suite.bzl", "cc_toolchain_suite")
load("@rules_testing//lib:util.bzl", "PREVENT_IMPLICIT_BUILDING_TAGS")
load("//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
load(":fake_cc_toolchain_config.bzl", "fake_cc_toolchain_config")
Expand Down
2 changes: 1 addition & 1 deletion tests/support/cc_toolchains/fake_cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""Fake for providing CcToolchainConfigInfo."""

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

def _impl(ctx):
return cc_common.create_cc_toolchain_config_info(
Expand Down
3 changes: 2 additions & 1 deletion tests/whl_filegroup/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
load("//python:defs.bzl", "py_library", "py_test")
load("//python:packaging.bzl", "py_package", "py_wheel")
load("//python:pip.bzl", "whl_filegroup")
Expand Down

0 comments on commit 576e6dc

Please sign in to comment.