diff --git a/src/main/starlark/builtins_bzl/common/exports.bzl b/src/main/starlark/builtins_bzl/common/exports.bzl index 84bd4fba9183f9..33dc18b24a2a4d 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/objc/linking_support.bzl", "linking_support") 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 @@ exported_toplevels = { "_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 @@ exported_rules = { "+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 00000000000000..c916b11a2592b3 --- /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 00000000000000..6b27bccfcc1feb --- /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 00000000000000..01148f594e7950 --- /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