1/* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package apex 18 19import ( 20 "github.com/google/blueprint" 21 22 "android/soong/android" 23) 24 25func init() { 26 android.RegisterSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory) 27} 28 29type apexDepsInfoSingleton struct { 30 // Output file with all flatlists from updatable modules' deps-info combined 31 updatableFlatListsPath android.OutputPath 32} 33 34func apexDepsInfoSingletonFactory() android.Singleton { 35 return &apexDepsInfoSingleton{} 36} 37 38var combineFilesRule = pctx.AndroidStaticRule("combineFilesRule", 39 blueprint.RuleParams{ 40 Command: "cat $out.rsp | xargs cat > $out", 41 Rspfile: "$out.rsp", 42 RspfileContent: "$in", 43 }, 44) 45 46func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContext) { 47 updatableFlatLists := android.Paths{} 48 ctx.VisitAllModules(func(module android.Module) { 49 if binaryInfo, ok := module.(android.ApexBundleDepsInfoIntf); ok { 50 if path := binaryInfo.FlatListPath(); path != nil { 51 if binaryInfo.Updatable() { 52 updatableFlatLists = append(updatableFlatLists, path) 53 } 54 } 55 } 56 }) 57 58 s.updatableFlatListsPath = android.PathForOutput(ctx, "apex", "depsinfo", "updatable-flatlists.txt") 59 ctx.Build(pctx, android.BuildParams{ 60 Rule: combineFilesRule, 61 Description: "Generate " + s.updatableFlatListsPath.String(), 62 Inputs: updatableFlatLists, 63 Output: s.updatableFlatListsPath, 64 }) 65} 66