Wrap PackageContext and SingletonContext
Wrap blueprint.PackageContext so that the *Func methods can provide an android.Config instead of an interface{}. The modified signatures means that every method in ModuleContext and SingletonContext that takes a blueprint.PackageContext now needs to be wrapped to take an android.PackageContext. SingletonContext wasn't previously wrapped at all, but as long as it is, wrap everything like ModuleContext does. This requires updating every Singleton to use the android-specific methods. Test: builds, all Soong tests pass Change-Id: I4f22085ebca7def6c5cde49e8210b59d994ba625
This commit is contained in:
@@ -16,22 +16,19 @@ package android
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterSingletonType("api_levels", ApiLevelsSingleton)
|
||||
}
|
||||
|
||||
func ApiLevelsSingleton() blueprint.Singleton {
|
||||
func ApiLevelsSingleton() Singleton {
|
||||
return &apiLevelsSingleton{}
|
||||
}
|
||||
|
||||
type apiLevelsSingleton struct{}
|
||||
|
||||
func createApiLevelsJson(ctx blueprint.SingletonContext, file string,
|
||||
func createApiLevelsJson(ctx SingletonContext, file WritablePath,
|
||||
apiLevelsMap map[string]int) {
|
||||
|
||||
jsonStr, err := json.Marshal(apiLevelsMap)
|
||||
@@ -39,21 +36,21 @@ func createApiLevelsJson(ctx blueprint.SingletonContext, file string,
|
||||
ctx.Errorf(err.Error())
|
||||
}
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
ctx.Build(pctx, BuildParams{
|
||||
Rule: WriteFile,
|
||||
Description: "generate " + filepath.Base(file),
|
||||
Outputs: []string{file},
|
||||
Description: "generate " + file.Base(),
|
||||
Output: file,
|
||||
Args: map[string]string{
|
||||
"content": string(jsonStr[:]),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func GetApiLevelsJson(ctx PathContext) Path {
|
||||
func GetApiLevelsJson(ctx PathContext) WritablePath {
|
||||
return PathForOutput(ctx, "api_levels.json")
|
||||
}
|
||||
|
||||
func (a *apiLevelsSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
||||
func (a *apiLevelsSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
baseApiLevel := 9000
|
||||
apiLevelsMap := map[string]int{
|
||||
"G": 9,
|
||||
@@ -74,5 +71,5 @@ func (a *apiLevelsSingleton) GenerateBuildActions(ctx blueprint.SingletonContext
|
||||
}
|
||||
|
||||
apiLevelsJson := GetApiLevelsJson(ctx)
|
||||
createApiLevelsJson(ctx, apiLevelsJson.String(), apiLevelsMap)
|
||||
createApiLevelsJson(ctx, apiLevelsJson, apiLevelsMap)
|
||||
}
|
||||
|
Reference in New Issue
Block a user