diff options
author | Yifan Hong <elsk@google.com> | 2023-07-21 17:46:16 -0700 |
---|---|---|
committer | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-08-04 16:36:07 +0000 |
commit | c65bd33899f46d6d677605d03b1c8b53a5bf513c (patch) | |
tree | 2ed4213bba7ac08a84e93fa26f7d629eb77ba5e6 | |
parent | ba5acaf9a72ca56b1a9c445f5525bc1bc368edd3 (diff) | |
download | build-android-gs-shusky-5.15-android14-d1.tar.gz |
kleaf: Add targets to retrieve python runtime.android-14.0.0_r0.8android-14.0.0_r0.18main-16k-gs-shusky-5.15android-gs-shusky-udc-d1android-gs-shusky-5.15-android14-d1
These internal targets returns files for the python runtime.
Test: TH
Bug: 291816237
Change-Id: I62507c4961638e8878d76fd623d16cf666f5f80f
-rw-r--r-- | kleaf/impl/BUILD.bazel | 16 | ||||
-rw-r--r-- | kleaf/impl/python.bzl | 37 |
2 files changed, 53 insertions, 0 deletions
diff --git a/kleaf/impl/BUILD.bazel b/kleaf/impl/BUILD.bazel index d533094..b65d3f8 100644 --- a/kleaf/impl/BUILD.bazel +++ b/kleaf/impl/BUILD.bazel @@ -19,6 +19,11 @@ load("@bazel_skylib//lib:selects.bzl", "selects") load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "bool_setting") load(":kernel_platform_toolchain.bzl", "kernel_platform_toolchain") load(":kernel_toolchains.bzl", "kernel_toolchains") +load( + ":python.bzl", + "python_interpreter_file", + "python_runtime_files", +) bzl_library( name = "impl", @@ -86,6 +91,7 @@ bzl_library( "merged_kernel_uapi_headers.bzl", "modules_prepare.bzl", "out_headers_allowlist_archive.bzl", + "python.bzl", "raw_kmi_symbol_list.bzl", "scripts_config_arg_builder.bzl", "srcs_aspect.bzl", @@ -358,3 +364,13 @@ platform( "@platforms//cpu:x86_64", ], ) + +python_interpreter_file( + name = "python_interpreter_file", + visibility = ["//build/kernel:__pkg__"], +) + +python_runtime_files( + name = "python_runtime_files", + visibility = ["//build/kernel:__pkg__"], +) diff --git a/kleaf/impl/python.bzl b/kleaf/impl/python.bzl new file mode 100644 index 0000000..2ab384c --- /dev/null +++ b/kleaf/impl/python.bzl @@ -0,0 +1,37 @@ +# Copyright (C) 2023 The Android Open Source Project +# +# 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. + +"""Utilities to get files from Python toolchain.""" + +visibility("//build/kernel/kleaf/...") + +_PY_TOOLCHAIN_TYPE = "@bazel_tools//tools/python:toolchain_type" + +def _python_interpreter_file_impl(ctx): + return DefaultInfo(files = depset([ctx.toolchains[_PY_TOOLCHAIN_TYPE].py3_runtime.interpreter])) + +python_interpreter_file = rule( + doc = "Resolves to the Python interpreter from resolved Python toolchain.", + implementation = _python_interpreter_file_impl, + toolchains = [config_common.toolchain_type(_PY_TOOLCHAIN_TYPE, mandatory = True)], +) + +def _python_runtime_files_impl(ctx): + return DefaultInfo(files = ctx.toolchains[_PY_TOOLCHAIN_TYPE].py3_runtime.files) + +python_runtime_files = rule( + doc = "Resolves to the Python runtime files from resolved Python toolchain.", + implementation = _python_runtime_files_impl, + toolchains = [config_common.toolchain_type(_PY_TOOLCHAIN_TYPE, mandatory = True)], +) |