Merge "Remove sdkPreSingleton and overlaySingleton" into main
This commit is contained in:
commit
a741e88489
7 changed files with 34 additions and 111 deletions
|
@ -78,10 +78,7 @@ func TestManifestMerger(t *testing.T) {
|
|||
}
|
||||
`
|
||||
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithOverlayBuildComponents,
|
||||
).RunTestWithBp(t, bp)
|
||||
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, bp)
|
||||
|
||||
manifestMergerRule := result.ModuleForTests("app", "android_common").Rule("manifestMerger")
|
||||
android.AssertPathRelativeToTopEquals(t, "main manifest",
|
||||
|
@ -129,10 +126,7 @@ func TestManifestValuesApplicationIdSetsPackageName(t *testing.T) {
|
|||
|
||||
`
|
||||
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithOverlayBuildComponents,
|
||||
).RunTestWithBp(t, bp)
|
||||
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, bp)
|
||||
|
||||
manifestMergerRule := result.ModuleForTests("test", "android_common").Rule("manifestMerger")
|
||||
android.AssertStringMatches(t,
|
||||
|
|
|
@ -21,14 +21,6 @@ import (
|
|||
"android/soong/android"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registerOverlayBuildComponents(android.InitRegistrationContext)
|
||||
}
|
||||
|
||||
func registerOverlayBuildComponents(ctx android.RegistrationContext) {
|
||||
ctx.RegisterPreSingletonType("overlay", OverlaySingletonFactory)
|
||||
}
|
||||
|
||||
var androidResourceIgnoreFilenames = []string{
|
||||
".svn",
|
||||
".git",
|
||||
|
@ -84,7 +76,38 @@ type globbedResourceDir struct {
|
|||
func overlayResourceGlob(ctx android.ModuleContext, a *aapt, dir android.Path) (res []globbedResourceDir,
|
||||
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
|
||||
rroEnabled := a.IsRROEnforced(ctx)
|
||||
|
@ -110,44 +133,3 @@ func overlayResourceGlob(ctx android.ModuleContext, a *aapt, dir android.Path) (
|
|||
|
||||
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) {
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithOverlayBuildComponents,
|
||||
fs.AddToFixture(),
|
||||
).RunTestWithBp(t, fmt.Sprintf(bp, testCase.prop))
|
||||
|
||||
|
@ -1283,7 +1282,6 @@ func TestAndroidResourceProcessor(t *testing.T) {
|
|||
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithOverlayBuildComponents,
|
||||
fs.AddToFixture(),
|
||||
).RunTestWithBp(t, bp)
|
||||
|
||||
|
@ -1566,7 +1564,6 @@ func TestAndroidResourceOverlays(t *testing.T) {
|
|||
t.Run(testCase.name, func(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithOverlayBuildComponents,
|
||||
fs.AddToFixture(),
|
||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||
variables.DeviceResourceOverlays = deviceResourceOverlays
|
||||
|
|
|
@ -47,10 +47,6 @@ var prepareForJavaTest = android.GroupFixturePreparers(
|
|||
cc.PrepareForTestWithCcBuildComponents,
|
||||
// Include all the default java modules.
|
||||
PrepareForTestWithDexpreopt,
|
||||
PrepareForTestWithOverlayBuildComponents,
|
||||
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
|
||||
ctx.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
|
||||
}),
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
|
|
@ -62,7 +62,6 @@ func TestRuntimeResourceOverlay(t *testing.T) {
|
|||
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithOverlayBuildComponents,
|
||||
android.FixtureModifyConfig(android.SetKatiEnabledForTests),
|
||||
fs.AddToFixture(),
|
||||
).RunTestWithBp(t, bp)
|
||||
|
@ -330,7 +329,6 @@ func TestEnforceRRO_propagatesToDependencies(t *testing.T) {
|
|||
t.Run(testCase.name, func(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithOverlayBuildComponents,
|
||||
fs.AddToFixture(),
|
||||
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||
variables.ProductResourceOverlays = productResourceOverlays
|
||||
|
|
42
java/sdk.go
42
java/sdk.go
|
@ -17,8 +17,6 @@ package java
|
|||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/java/config"
|
||||
|
@ -27,12 +25,10 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
android.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
|
||||
android.RegisterParallelSingletonType("sdk", sdkSingletonFactory)
|
||||
android.RegisterMakeVarsProvider(pctx, sdkMakeVars)
|
||||
}
|
||||
|
||||
var sdkVersionsKey = android.NewOnceKey("sdkVersionsKey")
|
||||
var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
|
||||
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
|
||||
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 {
|
||||
return sdkSingleton{}
|
||||
}
|
||||
|
|
|
@ -118,8 +118,6 @@ var PrepareForTestWithDexpreoptWithoutFakeDex2oatd = android.GroupFixturePrepare
|
|||
dexpreopt.PrepareForTestByEnablingDexpreopt,
|
||||
)
|
||||
|
||||
var PrepareForTestWithOverlayBuildComponents = android.FixtureRegisterWithContext(registerOverlayBuildComponents)
|
||||
|
||||
// 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.
|
||||
|
|
Loading…
Reference in a new issue