2020-04-28 15:57:42 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package apex
|
|
|
|
|
|
|
|
import (
|
2020-05-14 16:15:01 +02:00
|
|
|
"github.com/google/blueprint"
|
2020-06-24 12:17:19 +02:00
|
|
|
|
|
|
|
"android/soong/android"
|
2020-04-28 15:57:42 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
android.RegisterSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory)
|
|
|
|
}
|
|
|
|
|
|
|
|
type apexDepsInfoSingleton struct {
|
2020-06-24 12:17:19 +02:00
|
|
|
// Output file with all flatlists from updatable modules' deps-info combined
|
|
|
|
updatableFlatListsPath android.OutputPath
|
2020-04-28 15:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func apexDepsInfoSingletonFactory() android.Singleton {
|
|
|
|
return &apexDepsInfoSingleton{}
|
|
|
|
}
|
|
|
|
|
2020-06-24 12:17:19 +02:00
|
|
|
var combineFilesRule = pctx.AndroidStaticRule("combineFilesRule",
|
|
|
|
blueprint.RuleParams{
|
2020-04-28 15:57:42 +02:00
|
|
|
Command: "cat $out.rsp | xargs cat > $out",
|
|
|
|
Rspfile: "$out.rsp",
|
|
|
|
RspfileContent: "$in",
|
2020-06-24 12:17:19 +02:00
|
|
|
},
|
2020-04-28 15:57:42 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
2020-06-24 12:17:19 +02:00
|
|
|
updatableFlatLists := android.Paths{}
|
2020-04-28 15:57:42 +02:00
|
|
|
ctx.VisitAllModules(func(module android.Module) {
|
|
|
|
if binaryInfo, ok := module.(android.ApexBundleDepsInfoIntf); ok {
|
2020-06-24 12:17:19 +02:00
|
|
|
if path := binaryInfo.FlatListPath(); path != nil {
|
|
|
|
if binaryInfo.Updatable() {
|
|
|
|
updatableFlatLists = append(updatableFlatLists, path)
|
2020-04-28 15:57:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-06-24 12:17:19 +02:00
|
|
|
s.updatableFlatListsPath = android.PathForOutput(ctx, "apex", "depsinfo", "updatable-flatlists.txt")
|
2020-04-28 15:57:42 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2020-06-24 12:17:19 +02:00
|
|
|
Rule: combineFilesRule,
|
|
|
|
Description: "Generate " + s.updatableFlatListsPath.String(),
|
|
|
|
Inputs: updatableFlatLists,
|
|
|
|
Output: s.updatableFlatListsPath,
|
2020-04-28 15:57:42 +02:00
|
|
|
})
|
|
|
|
}
|