1// Copyright 2025 Google Inc. All rights reserved. 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 15package android 16 17import ( 18 "github.com/google/blueprint" 19) 20 21func init() { 22 RegisterOtatoolsPackageBuildComponents(InitRegistrationContext) 23 pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") 24} 25 26func RegisterOtatoolsPackageBuildComponents(ctx RegistrationContext) { 27 ctx.RegisterModuleType("otatools_package_cert_files", OtatoolsPackageFactory) 28} 29 30type OtatoolsPackage struct { 31 ModuleBase 32} 33 34func OtatoolsPackageFactory() Module { 35 module := &OtatoolsPackage{} 36 InitAndroidModule(module) 37 return module 38} 39 40var ( 41 otatoolsPackageCertRule = pctx.AndroidStaticRule("otatools_package_cert_files", blueprint.RuleParams{ 42 Command: "echo '$out : ' $$(cat $in) > ${out}.d && ${SoongZipCmd} -o $out -l $in", 43 CommandDeps: []string{"${SoongZipCmd}"}, 44 Depfile: "${out}.d", 45 Description: "Zip otatools-package cert files", 46 }) 47) 48 49func (fg *OtatoolsPackage) GenerateAndroidBuildActions(ctx ModuleContext) { 50 if ctx.ModuleDir() != "build/make/tools/otatools_package" { 51 ctx.ModuleErrorf("There can only be one otatools_package_cert_files module in build/make/tools/otatools_package") 52 return 53 } 54 fileListFile := PathForArbitraryOutput(ctx, ".module_paths", "OtaToolsCertFiles.list") 55 otatoolsPackageCertZip := PathForModuleOut(ctx, "otatools_package_cert_files.zip") 56 ctx.Build(pctx, BuildParams{ 57 Rule: otatoolsPackageCertRule, 58 Input: fileListFile, 59 Output: otatoolsPackageCertZip, 60 }) 61 ctx.SetOutputFiles([]Path{otatoolsPackageCertZip}, "") 62} 63