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
diff --git a/src/main/starlark/builtins_bzl/common/exports.bzl b/src/main/starlark/builtins_bzl/common/exports.bzl
index 84bd4fb..33dc18b 100755
--- a/src/main/starlark/builtins_bzl/common/exports.bzl
+++ b/src/main/starlark/builtins_bzl/common/exports.bzl
@@ -25,6 +25,8 @@
load("@_builtins//:common/proto/proto_common.bzl", "proto_common_do_not_use")
load("@_builtins//:common/proto/proto_library.bzl", "proto_library")
load("@_builtins//:common/proto/proto_lang_toolchain_wrapper.bzl", "proto_lang_toolchain")
+load("@_builtins//:common/python/py_runtime_macro.bzl", "py_runtime")
+load("@_builtins//:common/python/providers.bzl", "PyInfo", "PyRuntimeInfo")
load("@_builtins//:common/java/proto/java_lite_proto_library.bzl", "java_lite_proto_library")
load("@_builtins//:common/cc/cc_library.bzl", "cc_library")
@@ -35,6 +37,8 @@
"_builtins_dummy": "overridden value",
"CcSharedLibraryInfo": CcSharedLibraryInfo,
"proto_common_do_not_use": proto_common_do_not_use,
+ "-PyRuntimeInfo": PyRuntimeInfo,
+ "-PyInfo": PyInfo,
}
# A list of Starlarkified native rules.
@@ -55,6 +59,7 @@
"+cc_test": cc_test,
"+cc_library": cc_library,
"proto_lang_toolchain": proto_lang_toolchain,
+ "-py_runtime": py_runtime,
}
# A list of Starlark functions callable from native rules implementation.
diff --git a/src/main/starlark/builtins_bzl/common/python/providers.bzl b/src/main/starlark/builtins_bzl/common/python/providers.bzl
new file mode 100644
index 0000000..c916b11
--- /dev/null
+++ b/src/main/starlark/builtins_bzl/common/python/providers.bzl
@@ -0,0 +1,16 @@
+# Copyright 2022 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.
+"""Providers for Python rules."""
+PyRuntimeInfo = _builtins.toplevel.PyRuntimeInfo
+PyInfo = _builtins.toplevel.PyInfo
diff --git a/src/main/starlark/builtins_bzl/common/python/py_runtime_macro.bzl b/src/main/starlark/builtins_bzl/common/python/py_runtime_macro.bzl
new file mode 100644
index 0000000..6b27bcc
--- /dev/null
+++ b/src/main/starlark/builtins_bzl/common/python/py_runtime_macro.bzl
@@ -0,0 +1,22 @@
+# Copyright 2022 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.
+"""Macro to wrap the py_runtime rule."""
+
+load(":common/python/py_runtime_rule.bzl", py_runtime_rule = "py_runtime")
+
+# NOTE: The function name is purposefully selected to match the underlying
+# rule name so that e.g. 'generator_function' shows as the same name so
+# that it is less confusing to users.
+def py_runtime(**kwargs):
+ py_runtime_rule(**kwargs)
diff --git a/src/main/starlark/builtins_bzl/common/python/py_runtime_rule.bzl b/src/main/starlark/builtins_bzl/common/python/py_runtime_rule.bzl
new file mode 100644
index 0000000..01148f5
--- /dev/null
+++ b/src/main/starlark/builtins_bzl/common/python/py_runtime_rule.bzl
@@ -0,0 +1,18 @@
+# Copyright 2022 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.
+"""Implementation of py_runtime rule."""
+
+# Bind to the name "py_runtime" to preserve the kind/rule_class it shows up
+# as elsewhere.
+py_runtime = _builtins.native.py_runtime