Skip to content

Commit

Permalink
Create no-op builtins stubs for py_runtime, PyRuntimeInfo, and PyInfo
Browse files Browse the repository at this point in the history
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 bazelbuild#15897

PiperOrigin-RevId: 483066291
Change-Id: If297913ddbef3e32aada41e7d319c87213921f9d
  • Loading branch information
rickeylev authored and copybara-github committed Oct 22, 2022
1 parent 3e8514c commit 7190f22
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/starlark/builtins_bzl/common/exports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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.
Expand All @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions src/main/starlark/builtins_bzl/common/python/providers.bzl
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions src/main/starlark/builtins_bzl/common/python/py_runtime_macro.bzl
Original file line number Diff line number Diff line change
@@ -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)
18 changes: 18 additions & 0 deletions src/main/starlark/builtins_bzl/common/python/py_runtime_rule.bzl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7190f22

Please sign in to comment.