summaryrefslogtreecommitdiff
path: root/kleaf/impl/kernel_prebuilt_utils.bzl
blob: 47aca8ecf7a65ca6324bc9403822e8f1634a9315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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 define a repository for kernel prebuilts."""

load(
    "//build/kernel/kleaf:constants.bzl",
    "DEFAULT_GKI_OUTS",
)
load(
    ":constants.bzl",
    "FILEGROUP_DEF_ARCHIVE_SUFFIX",
    "GKI_ARTIFACTS_AARCH64_OUTS",
    "SYSTEM_DLKM_COMMON_OUTS",
    "TOOLCHAIN_VERSION_FILENAME",
    "UNSTRIPPED_MODULES_ARCHIVE",
)

visibility("//build/kernel/kleaf/...")

# Key: name of repository in bazel.WORKSPACE
# target: Bazel target name in common_kernels.bzl
# outs: list of outs associated with that target name
# arch: Architecture associated with this mapping.
CI_TARGET_MAPPING = {
    # TODO(b/206079661): Allow downloaded prebuilts for x86_64 and debug targets.
    "gki_prebuilts": {
        "arch": "arm64",
        # TODO: Rename this when more architectures are added.
        "target": "kernel_aarch64",
        "gki_prebuilts_outs": GKI_ARTIFACTS_AARCH64_OUTS,
        "download_configs": [
            # - mandatory: If False, download errors are ignored.
            # - outs_mapping: local_filename -> remote_artifact_fmt
            {
                "target_suffix": "files",
                "mandatory": True,
                "outs_mapping": {item: item for item in DEFAULT_GKI_OUTS},
            },
            {
                "target_suffix": "uapi_headers",
                "mandatory": True,
                "outs_mapping": {
                    "kernel-uapi-headers.tar.gz": "kernel-uapi-headers.tar.gz",
                },
            },
            {
                "target_suffix": "unstripped_modules_archive",
                "mandatory": True,
                "outs_mapping": {
                    UNSTRIPPED_MODULES_ARCHIVE: UNSTRIPPED_MODULES_ARCHIVE,
                },
            },
            {
                "target_suffix": "headers",
                "mandatory": True,
                "outs_mapping": {
                    "kernel-headers.tar.gz": "kernel-headers.tar.gz",
                },
            },
            {
                "target_suffix": "images",
                "mandatory": True,
                # TODO(b/297934577): Update GKI prebuilts to download system_dlkm.<fs>.img
                "outs_mapping": {item: item for item in SYSTEM_DLKM_COMMON_OUTS},
            },
            {
                "target_suffix": "toolchain_version",
                "mandatory": True,
                "outs_mapping": {
                    TOOLCHAIN_VERSION_FILENAME: TOOLCHAIN_VERSION_FILENAME,
                },
            },
            {
                "target_suffix": "boot_img_archive",
                "mandatory": True,
                "outs_mapping": {
                    "boot-img.tar.gz": "boot-img.tar.gz",
                    # The others can be found by extracting the archive, see gki_artifacts_prebuilts
                },
            },
            {
                "target_suffix": "boot_img_archive_signed",
                # Do not fail immediately if this file cannot be downloaded, because it does not
                # exist for unsigned builds. A build error will be emitted by gki_artifacts_prebuilts
                # if --use_signed_prebuilts and --use_gki_prebuilts=<an unsigned build number>.
                "mandatory": False,
                "outs_mapping": {
                    # The basename is kept boot-img.tar.gz so it works with
                    # gki_artifacts_prebuilts. It is placed under the signed/
                    # directory to avoid conflicts with boot_img_archive in
                    # download_artifacts_repo.
                    # The others can be found by extracting the archive, see gki_artifacts_prebuilts
                    "signed/boot-img.tar.gz": "signed/certified-boot-img-{build_number}.tar.gz",
                },
            },
            {
                "target_suffix": "ddk_artifacts",
                "mandatory": True,
                "outs_mapping": {
                    "kernel_aarch64" + FILEGROUP_DEF_ARCHIVE_SUFFIX: "kernel_aarch64" + FILEGROUP_DEF_ARCHIVE_SUFFIX,
                },
            },
            {
                "target_suffix": "kmi_symbol_list",
                "mandatory": False,
                "outs_mapping": {
                    "abi_symbollist": "abi_symbollist",
                    "abi_symbollist.report": "abi_symbollist.report",
                },
            },
            {
                "target_suffix": "protected_modules",
                "mandatory": False,
                "outs_mapping": {
                    "gki_aarch64_protected_modules": "gki_aarch64_protected_modules",
                },
            },
        ],
    },
}