1# Copyright (C) 2021 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 15ApexToolchainInfo = provider( 16 doc = "APEX toolchain", 17 fields = [ 18 "aapt2", 19 "avbtool", 20 "apexer", 21 "mke2fs", 22 "resize2fs", 23 "e2fsdroid", 24 "sefcontext_compile", 25 "conv_apex_manifest", 26 "android_jar", 27 "apex_compression_tool", 28 "soong_zip", 29 "jsonmodify", 30 "manifest_fixer", 31 "gen_ndk_usedby_apex", 32 "readelf", 33 "gen_java_usedby_apex", 34 "dexdeps", 35 "notice_generator", 36 ], 37) 38 39def _apex_toolchain_impl(ctx): 40 toolchain_info = platform_common.ToolchainInfo( 41 toolchain_info = ApexToolchainInfo( 42 aapt2 = ctx.file.aapt2, 43 avbtool = ctx.attr.avbtool, 44 apexer = ctx.attr.apexer, 45 mke2fs = ctx.attr.mke2fs, 46 resize2fs = ctx.attr.resize2fs, 47 e2fsdroid = ctx.attr.e2fsdroid, 48 sefcontext_compile = ctx.attr.sefcontext_compile, 49 conv_apex_manifest = ctx.attr.conv_apex_manifest, 50 android_jar = ctx.file.android_jar, 51 apex_compression_tool = ctx.attr.apex_compression_tool, 52 soong_zip = ctx.file.soong_zip, 53 jsonmodify = ctx.attr.jsonmodify, 54 manifest_fixer = ctx.attr.manifest_fixer, 55 gen_ndk_usedby_apex = ctx.attr.gen_ndk_usedby_apex, 56 readelf = ctx.attr.readelf, 57 gen_java_usedby_apex = ctx.attr.gen_java_usedby_apex, 58 dexdeps = ctx.attr.dexdeps, 59 notice_generator = ctx.attr.notice_generator, 60 ), 61 ) 62 return [toolchain_info] 63 64apex_toolchain = rule( 65 implementation = _apex_toolchain_impl, 66 attrs = { 67 "aapt2": attr.label(allow_single_file = True, cfg = "exec", executable = True, mandatory = True), 68 "android_jar": attr.label(allow_single_file = True, cfg = "exec", mandatory = True), 69 "apex_compression_tool": attr.label(cfg = "exec", executable = True, mandatory = True), 70 "apexer": attr.label(cfg = "exec", executable = True, mandatory = True), 71 "avbtool": attr.label(cfg = "exec", executable = True, mandatory = True), 72 "conv_apex_manifest": attr.label(cfg = "exec", executable = True, mandatory = True), 73 "dexdeps": attr.label(cfg = "exec", executable = True, mandatory = True), 74 "e2fsdroid": attr.label(cfg = "exec", executable = True, mandatory = True), 75 "gen_java_usedby_apex": attr.label(cfg = "exec", executable = True, mandatory = True, allow_single_file = [".sh"]), 76 "gen_ndk_usedby_apex": attr.label(cfg = "exec", executable = True, mandatory = True, allow_single_file = [".sh"]), 77 "jsonmodify": attr.label(cfg = "exec", executable = True, mandatory = True), 78 "manifest_fixer": attr.label(cfg = "exec", executable = True, mandatory = True), 79 "mke2fs": attr.label(cfg = "exec", executable = True, mandatory = True), 80 "notice_generator": attr.label(allow_single_file = True, cfg = "exec", executable = True, mandatory = True), 81 "readelf": attr.label(cfg = "exec", executable = True, mandatory = True, allow_single_file = True), 82 "resize2fs": attr.label(cfg = "exec", executable = True, mandatory = True), 83 "sefcontext_compile": attr.label(cfg = "exec", executable = True, mandatory = True), 84 # soong_zip is added as a dependency of apex_compression_tool which uses 85 # soong_zip to compress APEX files. avbtool is also used in apex_compression tool 86 # and has been added to apex toolchain previously. 87 "soong_zip": attr.label(allow_single_file = True, cfg = "exec", executable = True, mandatory = True), 88 }, 89) 90