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:
@@ -64,9 +64,9 @@ func init() {
|
||||
|
||||
pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS)
|
||||
|
||||
pctx.VariableFunc("JavaHome", func(config interface{}) (string, error) {
|
||||
pctx.VariableFunc("JavaHome", func(config android.Config) (string, error) {
|
||||
// This is set up and guaranteed by soong_ui
|
||||
return config.(android.Config).Getenv("ANDROID_JAVA_HOME"), nil
|
||||
return config.Getenv("ANDROID_JAVA_HOME"), nil
|
||||
})
|
||||
|
||||
pctx.SourcePathVariable("JavaToolchain", "${JavaHome}/bin")
|
||||
@@ -85,9 +85,9 @@ func init() {
|
||||
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
||||
pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips")
|
||||
pctx.HostBinToolVariable("Zip2ZipCmd", "zip2zip")
|
||||
pctx.VariableFunc("DxCmd", func(config interface{}) (string, error) {
|
||||
if config.(android.Config).IsEnvFalse("USE_D8") {
|
||||
if config.(android.Config).UnbundledBuild() || config.(android.Config).IsPdkBuild() {
|
||||
pctx.VariableFunc("DxCmd", func(config android.Config) (string, error) {
|
||||
if config.IsEnvFalse("USE_D8") {
|
||||
if config.UnbundledBuild() || config.IsPdkBuild() {
|
||||
return "prebuilts/build-tools/common/bin/dx", nil
|
||||
} else {
|
||||
path, err := pctx.HostBinToolPath(config, "dx")
|
||||
@@ -104,9 +104,9 @@ func init() {
|
||||
return path.String(), nil
|
||||
}
|
||||
})
|
||||
pctx.VariableFunc("TurbineJar", func(config interface{}) (string, error) {
|
||||
pctx.VariableFunc("TurbineJar", func(config android.Config) (string, error) {
|
||||
turbine := "turbine.jar"
|
||||
if config.(android.Config).UnbundledBuild() {
|
||||
if config.UnbundledBuild() {
|
||||
return "prebuilts/build-tools/common/framework/" + turbine, nil
|
||||
} else {
|
||||
path, err := pctx.HostJavaToolPath(config, turbine)
|
||||
@@ -122,8 +122,8 @@ func init() {
|
||||
|
||||
pctx.HostBinToolVariable("SoongJavacWrapper", "soong_javac_wrapper")
|
||||
|
||||
pctx.VariableFunc("JavacWrapper", func(config interface{}) (string, error) {
|
||||
if override := config.(android.Config).Getenv("JAVAC_WRAPPER"); override != "" {
|
||||
pctx.VariableFunc("JavacWrapper", func(config android.Config) (string, error) {
|
||||
if override := config.Getenv("JAVAC_WRAPPER"); override != "" {
|
||||
return override + " ", nil
|
||||
}
|
||||
return "", nil
|
||||
|
@@ -14,6 +14,8 @@
|
||||
|
||||
package config
|
||||
|
||||
import "android/soong/android"
|
||||
|
||||
var (
|
||||
// These will be filled out by external/error_prone/soong/error_prone.go if it is available
|
||||
ErrorProneJavacJar string
|
||||
@@ -25,7 +27,7 @@ var (
|
||||
|
||||
// Wrapper that grabs value of val late so it can be initialized by a later module's init function
|
||||
func errorProneVar(name string, val *string) {
|
||||
pctx.VariableFunc(name, func(config interface{}) (string, error) {
|
||||
pctx.VariableFunc(name, func(config android.Config) (string, error) {
|
||||
return *val, nil
|
||||
})
|
||||
}
|
||||
|
14
java/gen.go
14
java/gen.go
@@ -28,8 +28,6 @@ func init() {
|
||||
pctx.HostBinToolVariable("aidlCmd", "aidl")
|
||||
pctx.SourcePathVariable("logtagsCmd", "build/tools/java-event-log-tags.py")
|
||||
pctx.SourcePathVariable("mergeLogtagsCmd", "build/tools/merge-event-log-tags.py")
|
||||
|
||||
pctx.IntermediatesPathVariable("allLogtagsFile", "all-event-log-tags.txt")
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -117,7 +115,7 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
return outSrcFiles
|
||||
}
|
||||
|
||||
func LogtagsSingleton() blueprint.Singleton {
|
||||
func LogtagsSingleton() android.Singleton {
|
||||
return &logtagsSingleton{}
|
||||
}
|
||||
|
||||
@@ -127,18 +125,18 @@ type logtagsProducer interface {
|
||||
|
||||
type logtagsSingleton struct{}
|
||||
|
||||
func (l *logtagsSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
||||
func (l *logtagsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
var allLogtags android.Paths
|
||||
ctx.VisitAllModules(func(module blueprint.Module) {
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
if logtags, ok := module.(logtagsProducer); ok {
|
||||
allLogtags = append(allLogtags, logtags.logtags()...)
|
||||
}
|
||||
})
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: mergeLogtags,
|
||||
Description: "merge logtags",
|
||||
Outputs: []string{"$allLogtagsFile"},
|
||||
Inputs: allLogtags.Strings(),
|
||||
Output: android.PathForIntermediates(ctx, "all-event-log-tags.txt"),
|
||||
Inputs: allLogtags,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user