Skip to content

Commit 7190f22

Browse files
rickeylevcopybara-github
authored andcommitted
Create no-op builtins stubs for py_runtime, PyRuntimeInfo, and PyInfo
Subsequent changes will begin adding actual functionality. This just creates stubs than lets the `--experimental_builtins_bzl_path` and `--experimental_builtins_injection_override` flags allow working with the builtins code. Work towards #15897 PiperOrigin-RevId: 483066291 Change-Id: If297913ddbef3e32aada41e7d319c87213921f9d
1 parent 3e8514c commit 7190f22

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

src/main/starlark/builtins_bzl/common/exports.bzl

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ load("@_builtins//:common/objc/linking_support.bzl", "linking_support")
2525
load("@_builtins//:common/proto/proto_common.bzl", "proto_common_do_not_use")
2626
load("@_builtins//:common/proto/proto_library.bzl", "proto_library")
2727
load("@_builtins//:common/proto/proto_lang_toolchain_wrapper.bzl", "proto_lang_toolchain")
28+
load("@_builtins//:common/python/py_runtime_macro.bzl", "py_runtime")
29+
load("@_builtins//:common/python/providers.bzl", "PyInfo", "PyRuntimeInfo")
2830
load("@_builtins//:common/java/proto/java_lite_proto_library.bzl", "java_lite_proto_library")
2931
load("@_builtins//:common/cc/cc_library.bzl", "cc_library")
3032

@@ -35,6 +37,8 @@ exported_toplevels = {
3537
"_builtins_dummy": "overridden value",
3638
"CcSharedLibraryInfo": CcSharedLibraryInfo,
3739
"proto_common_do_not_use": proto_common_do_not_use,
40+
"-PyRuntimeInfo": PyRuntimeInfo,
41+
"-PyInfo": PyInfo,
3842
}
3943

4044
# A list of Starlarkified native rules.
@@ -55,6 +59,7 @@ exported_rules = {
5559
"+cc_test": cc_test,
5660
"+cc_library": cc_library,
5761
"proto_lang_toolchain": proto_lang_toolchain,
62+
"-py_runtime": py_runtime,
5863
}
5964

6065
# A list of Starlark functions callable from native rules implementation.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2022 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+
"""Providers for Python rules."""
15+
PyRuntimeInfo = _builtins.toplevel.PyRuntimeInfo
16+
PyInfo = _builtins.toplevel.PyInfo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2022 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+
"""Macro to wrap the py_runtime rule."""
15+
16+
load(":common/python/py_runtime_rule.bzl", py_runtime_rule = "py_runtime")
17+
18+
# NOTE: The function name is purposefully selected to match the underlying
19+
# rule name so that e.g. 'generator_function' shows as the same name so
20+
# that it is less confusing to users.
21+
def py_runtime(**kwargs):
22+
py_runtime_rule(**kwargs)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2022 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+
"""Implementation of py_runtime rule."""
15+
16+
# Bind to the name "py_runtime" to preserve the kind/rule_class it shows up
17+
# as elsewhere.
18+
py_runtime = _builtins.native.py_runtime

0 commit comments

Comments
 (0)