blob: 83a56a2b5a23ac7715e232054223b4c5e2d33a57 [file] [log] [blame]
Artur Satayev849f8442020-04-28 14:57:42 +01001/*
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 (
Artur Satayeva4405fa2020-05-14 15:15:01 +010020 "github.com/google/blueprint"
Artur Satayev9af168d2020-06-24 10:17:19 +000021
22 "android/soong/android"
Artur Satayev849f8442020-04-28 14:57:42 +010023)
24
25func init() {
26 android.RegisterSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory)
27}
28
29type apexDepsInfoSingleton struct {
Artur Satayev9af168d2020-06-24 10:17:19 +000030 // Output file with all flatlists from updatable modules' deps-info combined
31 updatableFlatListsPath android.OutputPath
Artur Satayev849f8442020-04-28 14:57:42 +010032}
33
34func apexDepsInfoSingletonFactory() android.Singleton {
35 return &apexDepsInfoSingleton{}
36}
37
Artur Satayev9af168d2020-06-24 10:17:19 +000038var combineFilesRule = pctx.AndroidStaticRule("combineFilesRule",
39 blueprint.RuleParams{
Artur Satayev849f8442020-04-28 14:57:42 +010040 Command: "cat $out.rsp | xargs cat > $out",
41 Rspfile: "$out.rsp",
42 RspfileContent: "$in",
Artur Satayev9af168d2020-06-24 10:17:19 +000043 },
Artur Satayev849f8442020-04-28 14:57:42 +010044)
45
46func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContext) {
Artur Satayev9af168d2020-06-24 10:17:19 +000047 updatableFlatLists := android.Paths{}
Artur Satayev849f8442020-04-28 14:57:42 +010048 ctx.VisitAllModules(func(module android.Module) {
49 if binaryInfo, ok := module.(android.ApexBundleDepsInfoIntf); ok {
Artur Satayev9af168d2020-06-24 10:17:19 +000050 if path := binaryInfo.FlatListPath(); path != nil {
51 if binaryInfo.Updatable() {
52 updatableFlatLists = append(updatableFlatLists, path)
Artur Satayev849f8442020-04-28 14:57:42 +010053 }
54 }
55 }
56 })
57
Artur Satayev9af168d2020-06-24 10:17:19 +000058 s.updatableFlatListsPath = android.PathForOutput(ctx, "apex", "depsinfo", "updatable-flatlists.txt")
Artur Satayev849f8442020-04-28 14:57:42 +010059 ctx.Build(pctx, android.BuildParams{
Artur Satayev9af168d2020-06-24 10:17:19 +000060 Rule: combineFilesRule,
61 Description: "Generate " + s.updatableFlatListsPath.String(),
62 Inputs: updatableFlatLists,
63 Output: s.updatableFlatListsPath,
Artur Satayev849f8442020-04-28 14:57:42 +010064 })
Artur Satayev849f8442020-04-28 14:57:42 +010065}