Skip to content

Commit 754b26a

Browse files
authored
internal: add stub register_extension_name to make patching easier (bazel-contrib#1475)
Within Google, we have to patch some files so some additional tooling can capture some metadata. To make patching easier, call some no-opt stubs, which makes the patches smaller and more likely to apply without issues.
1 parent e009502 commit 754b26a

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

python/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ bzl_library(
111111
name = "py_binary_bzl",
112112
srcs = ["py_binary.bzl"],
113113
deps = [
114+
"//python/private:register_extension_info_bzl",
114115
"//python/private:util_bzl",
115116
"//python/private/common:py_binary_macro_bazel_bzl",
116117
"@rules_python_internal//:rules_python_config_bzl",
@@ -142,6 +143,7 @@ bzl_library(
142143
name = "py_library_bzl",
143144
srcs = ["py_library.bzl"],
144145
deps = [
146+
"//python/private:register_extension_info_bzl",
145147
"//python/private:util_bzl",
146148
"//python/private/common:py_library_macro_bazel_bzl",
147149
"@rules_python_internal//:rules_python_config_bzl",
@@ -182,6 +184,7 @@ bzl_library(
182184
name = "py_test_bzl",
183185
srcs = ["py_test.bzl"],
184186
deps = [
187+
"//python/private:register_extension_info_bzl",
185188
"//python/private:util_bzl",
186189
"//python/private/common:py_test_macro_bazel_bzl",
187190
"@rules_python_internal//:rules_python_config_bzl",

python/private/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ bzl_library(
163163
deps = [":bazel_tools_bzl"],
164164
)
165165

166+
bzl_library(
167+
name = "register_extension_info_bzl",
168+
srcs = ["register_extension_info.bzl"],
169+
)
170+
166171
bzl_library(
167172
name = "render_pkg_aliases_bzl",
168173
srcs = ["render_pkg_aliases.bzl"],
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2023 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Stub implementation to make patching easier."""
15+
16+
# buildifier: disable=unused-variable
17+
def register_extension_info(**kwargs):
18+
"""A no-op stub to make Google patching easier."""

python/py_binary.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Public entry point for py_binary."""
1616

1717
load("@rules_python_internal//:rules_python_config.bzl", "config")
18+
load("//python/private:register_extension_info.bzl", "register_extension_info")
1819
load("//python/private:util.bzl", "add_migration_tag")
1920
load("//python/private/common:py_binary_macro_bazel.bzl", _starlark_py_binary = "py_binary")
2021

@@ -33,3 +34,8 @@ def py_binary(**attrs):
3334
fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886")
3435

3536
_py_binary_impl(**add_migration_tag(attrs))
37+
38+
register_extension_info(
39+
extension = py_binary,
40+
label_regex_for_dep = "{extension_name}",
41+
)

python/py_library.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Public entry point for py_library."""
1616

1717
load("@rules_python_internal//:rules_python_config.bzl", "config")
18+
load("//python/private:register_extension_info.bzl", "register_extension_info")
1819
load("//python/private:util.bzl", "add_migration_tag")
1920
load("//python/private/common:py_library_macro_bazel.bzl", _starlark_py_library = "py_library")
2021

@@ -31,3 +32,8 @@ def py_library(**attrs):
3132
fail("Python 2 is no longer supported: https://github.com/bazelbuild/rules_python/issues/886")
3233

3334
_py_library_impl(**add_migration_tag(attrs))
35+
36+
register_extension_info(
37+
extension = py_library,
38+
label_regex_for_dep = "{extension_name}",
39+
)

python/py_test.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Public entry point for py_test."""
1616

1717
load("@rules_python_internal//:rules_python_config.bzl", "config")
18+
load("//python/private:register_extension_info.bzl", "register_extension_info")
1819
load("//python/private:util.bzl", "add_migration_tag")
1920
load("//python/private/common:py_test_macro_bazel.bzl", _starlark_py_test = "py_test")
2021

@@ -34,3 +35,8 @@ def py_test(**attrs):
3435

3536
# buildifier: disable=native-python
3637
_py_test_impl(**add_migration_tag(attrs))
38+
39+
register_extension_info(
40+
extension = py_test,
41+
label_regex_for_dep = "{extension_name}",
42+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy