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