Remove sdkPreSingleton and overlaySingleton
These were the only 2 pre-singletons in soong. sdkPreSingleton is totally unused. overlaySingleton can be done during GenerateAndroidBuildActions instead. Test: m nothing --no-skip-soong-tests Change-Id: Ieb5ab92f18cb56be4049c0842f61df8aa02dc52c
This commit is contained in:
parent
eb852927d4
commit
9bef67488d
7 changed files with 34 additions and 111 deletions
|
@ -78,10 +78,7 @@ func TestManifestMerger(t *testing.T) {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
result := android.GroupFixturePreparers(
|
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, bp)
|
||||||
PrepareForTestWithJavaDefaultModules,
|
|
||||||
PrepareForTestWithOverlayBuildComponents,
|
|
||||||
).RunTestWithBp(t, bp)
|
|
||||||
|
|
||||||
manifestMergerRule := result.ModuleForTests("app", "android_common").Rule("manifestMerger")
|
manifestMergerRule := result.ModuleForTests("app", "android_common").Rule("manifestMerger")
|
||||||
android.AssertPathRelativeToTopEquals(t, "main manifest",
|
android.AssertPathRelativeToTopEquals(t, "main manifest",
|
||||||
|
@ -129,10 +126,7 @@ func TestManifestValuesApplicationIdSetsPackageName(t *testing.T) {
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
result := android.GroupFixturePreparers(
|
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, bp)
|
||||||
PrepareForTestWithJavaDefaultModules,
|
|
||||||
PrepareForTestWithOverlayBuildComponents,
|
|
||||||
).RunTestWithBp(t, bp)
|
|
||||||
|
|
||||||
manifestMergerRule := result.ModuleForTests("test", "android_common").Rule("manifestMerger")
|
manifestMergerRule := result.ModuleForTests("test", "android_common").Rule("manifestMerger")
|
||||||
android.AssertStringMatches(t,
|
android.AssertStringMatches(t,
|
||||||
|
|
|
@ -21,14 +21,6 @@ import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
registerOverlayBuildComponents(android.InitRegistrationContext)
|
|
||||||
}
|
|
||||||
|
|
||||||
func registerOverlayBuildComponents(ctx android.RegistrationContext) {
|
|
||||||
ctx.RegisterPreSingletonType("overlay", OverlaySingletonFactory)
|
|
||||||
}
|
|
||||||
|
|
||||||
var androidResourceIgnoreFilenames = []string{
|
var androidResourceIgnoreFilenames = []string{
|
||||||
".svn",
|
".svn",
|
||||||
".git",
|
".git",
|
||||||
|
@ -84,7 +76,38 @@ type globbedResourceDir struct {
|
||||||
func overlayResourceGlob(ctx android.ModuleContext, a *aapt, dir android.Path) (res []globbedResourceDir,
|
func overlayResourceGlob(ctx android.ModuleContext, a *aapt, dir android.Path) (res []globbedResourceDir,
|
||||||
rroDirs []rroDir) {
|
rroDirs []rroDir) {
|
||||||
|
|
||||||
overlayData := ctx.Config().Get(overlayDataKey).([]overlayGlobResult)
|
overlayData := ctx.Config().Once(overlayDataKey, func() interface{} {
|
||||||
|
var overlayData []overlayGlobResult
|
||||||
|
|
||||||
|
appendOverlayData := func(overlayDirs []string, t overlayType) {
|
||||||
|
for i := range overlayDirs {
|
||||||
|
// Iterate backwards through the list of overlay directories so that the later, lower-priority
|
||||||
|
// directories in the list show up earlier in the command line to aapt2.
|
||||||
|
overlay := overlayDirs[len(overlayDirs)-1-i]
|
||||||
|
var result overlayGlobResult
|
||||||
|
result.dir = overlay
|
||||||
|
result.overlayType = t
|
||||||
|
|
||||||
|
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), androidResourceIgnoreFilenames)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ModuleErrorf("failed to glob resource dir %q: %s", overlay, err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var paths android.Paths
|
||||||
|
for _, f := range files {
|
||||||
|
if !strings.HasSuffix(f, "/") {
|
||||||
|
paths = append(paths, android.PathForSource(ctx, f))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.paths = android.PathsToDirectorySortedPaths(paths)
|
||||||
|
overlayData = append(overlayData, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
appendOverlayData(ctx.Config().DeviceResourceOverlays(), device)
|
||||||
|
appendOverlayData(ctx.Config().ProductResourceOverlays(), product)
|
||||||
|
return overlayData
|
||||||
|
}).([]overlayGlobResult)
|
||||||
|
|
||||||
// Runtime resource overlays (RRO) may be turned on by the product config for some modules
|
// Runtime resource overlays (RRO) may be turned on by the product config for some modules
|
||||||
rroEnabled := a.IsRROEnforced(ctx)
|
rroEnabled := a.IsRROEnforced(ctx)
|
||||||
|
@ -110,44 +133,3 @@ func overlayResourceGlob(ctx android.ModuleContext, a *aapt, dir android.Path) (
|
||||||
|
|
||||||
return res, rroDirs
|
return res, rroDirs
|
||||||
}
|
}
|
||||||
|
|
||||||
func OverlaySingletonFactory() android.Singleton {
|
|
||||||
return overlaySingleton{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type overlaySingleton struct{}
|
|
||||||
|
|
||||||
func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|
||||||
var overlayData []overlayGlobResult
|
|
||||||
|
|
||||||
appendOverlayData := func(overlayDirs []string, t overlayType) {
|
|
||||||
for i := range overlayDirs {
|
|
||||||
// Iterate backwards through the list of overlay directories so that the later, lower-priority
|
|
||||||
// directories in the list show up earlier in the command line to aapt2.
|
|
||||||
overlay := overlayDirs[len(overlayDirs)-1-i]
|
|
||||||
var result overlayGlobResult
|
|
||||||
result.dir = overlay
|
|
||||||
result.overlayType = t
|
|
||||||
|
|
||||||
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), androidResourceIgnoreFilenames)
|
|
||||||
if err != nil {
|
|
||||||
ctx.Errorf("failed to glob resource dir %q: %s", overlay, err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var paths android.Paths
|
|
||||||
for _, f := range files {
|
|
||||||
if !strings.HasSuffix(f, "/") {
|
|
||||||
paths = append(paths, android.PathForSource(ctx, f))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.paths = android.PathsToDirectorySortedPaths(paths)
|
|
||||||
overlayData = append(overlayData, result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
appendOverlayData(ctx.Config().DeviceResourceOverlays(), device)
|
|
||||||
appendOverlayData(ctx.Config().ProductResourceOverlays(), product)
|
|
||||||
ctx.Config().Once(overlayDataKey, func() interface{} {
|
|
||||||
return overlayData
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
@ -558,7 +558,6 @@ func TestResourceDirs(t *testing.T) {
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
PrepareForTestWithJavaDefaultModules,
|
PrepareForTestWithJavaDefaultModules,
|
||||||
PrepareForTestWithOverlayBuildComponents,
|
|
||||||
fs.AddToFixture(),
|
fs.AddToFixture(),
|
||||||
).RunTestWithBp(t, fmt.Sprintf(bp, testCase.prop))
|
).RunTestWithBp(t, fmt.Sprintf(bp, testCase.prop))
|
||||||
|
|
||||||
|
@ -1283,7 +1282,6 @@ func TestAndroidResourceProcessor(t *testing.T) {
|
||||||
|
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
PrepareForTestWithJavaDefaultModules,
|
PrepareForTestWithJavaDefaultModules,
|
||||||
PrepareForTestWithOverlayBuildComponents,
|
|
||||||
fs.AddToFixture(),
|
fs.AddToFixture(),
|
||||||
).RunTestWithBp(t, bp)
|
).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
|
@ -1566,7 +1564,6 @@ func TestAndroidResourceOverlays(t *testing.T) {
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
PrepareForTestWithJavaDefaultModules,
|
PrepareForTestWithJavaDefaultModules,
|
||||||
PrepareForTestWithOverlayBuildComponents,
|
|
||||||
fs.AddToFixture(),
|
fs.AddToFixture(),
|
||||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
variables.DeviceResourceOverlays = deviceResourceOverlays
|
variables.DeviceResourceOverlays = deviceResourceOverlays
|
||||||
|
|
|
@ -47,10 +47,6 @@ var prepareForJavaTest = android.GroupFixturePreparers(
|
||||||
cc.PrepareForTestWithCcBuildComponents,
|
cc.PrepareForTestWithCcBuildComponents,
|
||||||
// Include all the default java modules.
|
// Include all the default java modules.
|
||||||
PrepareForTestWithDexpreopt,
|
PrepareForTestWithDexpreopt,
|
||||||
PrepareForTestWithOverlayBuildComponents,
|
|
||||||
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
|
|
||||||
ctx.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
|
|
@ -62,7 +62,6 @@ func TestRuntimeResourceOverlay(t *testing.T) {
|
||||||
|
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
PrepareForTestWithJavaDefaultModules,
|
PrepareForTestWithJavaDefaultModules,
|
||||||
PrepareForTestWithOverlayBuildComponents,
|
|
||||||
android.FixtureModifyConfig(android.SetKatiEnabledForTests),
|
android.FixtureModifyConfig(android.SetKatiEnabledForTests),
|
||||||
fs.AddToFixture(),
|
fs.AddToFixture(),
|
||||||
).RunTestWithBp(t, bp)
|
).RunTestWithBp(t, bp)
|
||||||
|
@ -330,7 +329,6 @@ func TestEnforceRRO_propagatesToDependencies(t *testing.T) {
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
PrepareForTestWithJavaDefaultModules,
|
PrepareForTestWithJavaDefaultModules,
|
||||||
PrepareForTestWithOverlayBuildComponents,
|
|
||||||
fs.AddToFixture(),
|
fs.AddToFixture(),
|
||||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
variables.ProductResourceOverlays = productResourceOverlays
|
variables.ProductResourceOverlays = productResourceOverlays
|
||||||
|
|
42
java/sdk.go
42
java/sdk.go
|
@ -17,8 +17,6 @@ package java
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/java/config"
|
"android/soong/java/config"
|
||||||
|
@ -27,12 +25,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
|
|
||||||
android.RegisterParallelSingletonType("sdk", sdkSingletonFactory)
|
android.RegisterParallelSingletonType("sdk", sdkSingletonFactory)
|
||||||
android.RegisterMakeVarsProvider(pctx, sdkMakeVars)
|
android.RegisterMakeVarsProvider(pctx, sdkMakeVars)
|
||||||
}
|
}
|
||||||
|
|
||||||
var sdkVersionsKey = android.NewOnceKey("sdkVersionsKey")
|
|
||||||
var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
|
var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
|
||||||
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
|
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
|
||||||
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
|
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
|
||||||
|
@ -213,44 +209,6 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sdkPreSingletonFactory() android.Singleton {
|
|
||||||
return sdkPreSingleton{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type sdkPreSingleton struct{}
|
|
||||||
|
|
||||||
func (sdkPreSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|
||||||
sdkJars, err := ctx.GlobWithDeps("prebuilts/sdk/*/public/android.jar", nil)
|
|
||||||
if err != nil {
|
|
||||||
ctx.Errorf("failed to glob prebuilts/sdk/*/public/android.jar: %s", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
var sdkVersions []int
|
|
||||||
for _, sdkJar := range sdkJars {
|
|
||||||
dir := filepath.Base(filepath.Dir(filepath.Dir(sdkJar)))
|
|
||||||
v, err := strconv.Atoi(dir)
|
|
||||||
if scerr, ok := err.(*strconv.NumError); ok && scerr.Err == strconv.ErrSyntax {
|
|
||||||
continue
|
|
||||||
} else if err != nil {
|
|
||||||
ctx.Errorf("invalid sdk jar %q, %s, %v", sdkJar, err.Error())
|
|
||||||
}
|
|
||||||
sdkVersions = append(sdkVersions, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Ints(sdkVersions)
|
|
||||||
|
|
||||||
ctx.Config().Once(sdkVersionsKey, func() interface{} { return sdkVersions })
|
|
||||||
}
|
|
||||||
|
|
||||||
func LatestSdkVersionInt(ctx android.EarlyModuleContext) int {
|
|
||||||
sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int)
|
|
||||||
latestSdkVersion := 0
|
|
||||||
if len(sdkVersions) > 0 {
|
|
||||||
latestSdkVersion = sdkVersions[len(sdkVersions)-1]
|
|
||||||
}
|
|
||||||
return latestSdkVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
func sdkSingletonFactory() android.Singleton {
|
func sdkSingletonFactory() android.Singleton {
|
||||||
return sdkSingleton{}
|
return sdkSingleton{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,8 +118,6 @@ var PrepareForTestWithDexpreoptWithoutFakeDex2oatd = android.GroupFixturePrepare
|
||||||
dexpreopt.PrepareForTestByEnablingDexpreopt,
|
dexpreopt.PrepareForTestByEnablingDexpreopt,
|
||||||
)
|
)
|
||||||
|
|
||||||
var PrepareForTestWithOverlayBuildComponents = android.FixtureRegisterWithContext(registerOverlayBuildComponents)
|
|
||||||
|
|
||||||
// Prepare a fixture to use all java module types, mutators and singletons fully.
|
// Prepare a fixture to use all java module types, mutators and singletons fully.
|
||||||
//
|
//
|
||||||
// This should only be used by tests that want to run with as much of the build enabled as possible.
|
// This should only be used by tests that want to run with as much of the build enabled as possible.
|
||||||
|
|
Loading…
Reference in a new issue