xref: /aosp_15_r20/build/bazel/rules/partitions/toolchain.bzl (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1*7594170eSAndroid Build Coastguard Worker# Copyright (C) 2022 The Android Open Source Project
2*7594170eSAndroid Build Coastguard Worker#
3*7594170eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*7594170eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*7594170eSAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*7594170eSAndroid Build Coastguard Worker#
7*7594170eSAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
8*7594170eSAndroid Build Coastguard Worker#
9*7594170eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*7594170eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*7594170eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*7594170eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*7594170eSAndroid Build Coastguard Worker# limitations under the License.
14*7594170eSAndroid Build Coastguard Worker
15*7594170eSAndroid Build Coastguard Worker"""
16*7594170eSAndroid Build Coastguard WorkerThe toolchain used by the partition rule.
17*7594170eSAndroid Build Coastguard Worker"""
18*7594170eSAndroid Build Coastguard Worker
19*7594170eSAndroid Build Coastguard WorkerPartitionToolchainInfo = provider(
20*7594170eSAndroid Build Coastguard Worker    doc = "Partitions toolchain",
21*7594170eSAndroid Build Coastguard Worker    fields = [
22*7594170eSAndroid Build Coastguard Worker        "avbtool",
23*7594170eSAndroid Build Coastguard Worker        "build_image",
24*7594170eSAndroid Build Coastguard Worker        "e2fsdroid",
25*7594170eSAndroid Build Coastguard Worker        "fec",
26*7594170eSAndroid Build Coastguard Worker        "mke2fs",
27*7594170eSAndroid Build Coastguard Worker        "mkfs_erofs",
28*7594170eSAndroid Build Coastguard Worker        "mkuserimg_mke2fs",
29*7594170eSAndroid Build Coastguard Worker        "openssl",
30*7594170eSAndroid Build Coastguard Worker        "simg2img",
31*7594170eSAndroid Build Coastguard Worker        "toybox",
32*7594170eSAndroid Build Coastguard Worker        "tune2fs",
33*7594170eSAndroid Build Coastguard Worker    ],
34*7594170eSAndroid Build Coastguard Worker)
35*7594170eSAndroid Build Coastguard Worker
36*7594170eSAndroid Build Coastguard Workerdef _partition_toolchain_impl(ctx):
37*7594170eSAndroid Build Coastguard Worker    toolchain_info = platform_common.ToolchainInfo(
38*7594170eSAndroid Build Coastguard Worker        toolchain_info = PartitionToolchainInfo(
39*7594170eSAndroid Build Coastguard Worker            avbtool = ctx.attr.avbtool,
40*7594170eSAndroid Build Coastguard Worker            build_image = ctx.attr.build_image,
41*7594170eSAndroid Build Coastguard Worker            e2fsdroid = ctx.attr.e2fsdroid,
42*7594170eSAndroid Build Coastguard Worker            fec = ctx.attr.fec,
43*7594170eSAndroid Build Coastguard Worker            mke2fs = ctx.attr.mke2fs,
44*7594170eSAndroid Build Coastguard Worker            mkfs_erofs = ctx.attr.mkfs_erofs,
45*7594170eSAndroid Build Coastguard Worker            mkuserimg_mke2fs = ctx.attr.mkuserimg_mke2fs,
46*7594170eSAndroid Build Coastguard Worker            openssl = ctx.file.openssl,
47*7594170eSAndroid Build Coastguard Worker            simg2img = ctx.attr.simg2img,
48*7594170eSAndroid Build Coastguard Worker            toybox = ctx.attr.toybox,
49*7594170eSAndroid Build Coastguard Worker            tune2fs = ctx.attr.tune2fs,
50*7594170eSAndroid Build Coastguard Worker        ),
51*7594170eSAndroid Build Coastguard Worker    )
52*7594170eSAndroid Build Coastguard Worker    return [toolchain_info]
53*7594170eSAndroid Build Coastguard Worker
54*7594170eSAndroid Build Coastguard Workerpartition_toolchain = rule(
55*7594170eSAndroid Build Coastguard Worker    implementation = _partition_toolchain_impl,
56*7594170eSAndroid Build Coastguard Worker    attrs = {
57*7594170eSAndroid Build Coastguard Worker        "avbtool": attr.label(cfg = "exec", executable = True, mandatory = True),
58*7594170eSAndroid Build Coastguard Worker        "build_image": attr.label(cfg = "exec", executable = True, mandatory = True),
59*7594170eSAndroid Build Coastguard Worker        "e2fsdroid": attr.label(cfg = "exec", executable = True, mandatory = True),
60*7594170eSAndroid Build Coastguard Worker        "fec": attr.label(cfg = "exec", executable = True, mandatory = True),
61*7594170eSAndroid Build Coastguard Worker        "mke2fs": attr.label(cfg = "exec", executable = True, mandatory = True),
62*7594170eSAndroid Build Coastguard Worker        "mkfs_erofs": attr.label(cfg = "exec", executable = True, mandatory = True),
63*7594170eSAndroid Build Coastguard Worker        "mkuserimg_mke2fs": attr.label(cfg = "exec", executable = True, mandatory = True),
64*7594170eSAndroid Build Coastguard Worker        "openssl": attr.label(allow_single_file = True, cfg = "exec", mandatory = True),
65*7594170eSAndroid Build Coastguard Worker        "simg2img": attr.label(cfg = "exec", executable = True, mandatory = True),
66*7594170eSAndroid Build Coastguard Worker        "toybox": attr.label(cfg = "exec", executable = True, mandatory = True),
67*7594170eSAndroid Build Coastguard Worker        "tune2fs": attr.label(cfg = "exec", executable = True, mandatory = True),
68*7594170eSAndroid Build Coastguard Worker    },
69*7594170eSAndroid Build Coastguard Worker)
70