diff options
Diffstat (limited to 'android')
-rw-r--r-- | android/Android.bp | 2 | ||||
-rw-r--r-- | android/androidmk.go | 18 | ||||
-rw-r--r-- | android/configurable_properties.go | 3 | ||||
-rw-r--r-- | android/module.go | 18 | ||||
-rw-r--r-- | android/module_proxy.go | 4 | ||||
-rw-r--r-- | android/otatools_package_cert_zip.go | 62 | ||||
-rw-r--r-- | android/packaging.go | 41 | ||||
-rw-r--r-- | android/raw_files.go | 7 | ||||
-rw-r--r-- | android/test_suites.go | 6 | ||||
-rw-r--r-- | android/util.go | 30 | ||||
-rw-r--r-- | android/variable.go | 4 |
11 files changed, 141 insertions, 54 deletions
diff --git a/android/Android.bp b/android/Android.bp index 00dc50ac2..97d634fb5 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -12,6 +12,7 @@ bootstrap_go_package { "blueprint-gobtools", "blueprint-metrics", "blueprint-pool", + "blueprint-syncmap", "sbox_proto", "soong", "soong-android_team_proto", @@ -83,6 +84,7 @@ bootstrap_go_package { "nothing.go", "notices.go", "onceper.go", + "otatools_package_cert_zip.go", "override_module.go", "package.go", "package_ctx.go", diff --git a/android/androidmk.go b/android/androidmk.go index 784559312..e32835946 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -435,13 +435,18 @@ func getDistContributions(ctx ConfigAndOtherModuleProviderContext, mod Module) * suffix = *dist.Suffix } - productString := "" - if dist.Append_artifact_with_product != nil && *dist.Append_artifact_with_product { - productString = fmt.Sprintf("_%s", ctx.Config().DeviceProduct()) + prependProductString := "" + if proptools.Bool(dist.Prepend_artifact_with_product) { + prependProductString = fmt.Sprintf("%s-", ctx.Config().DeviceProduct()) } - if suffix != "" || productString != "" { - dest = strings.TrimSuffix(dest, ext) + suffix + productString + ext + appendProductString := "" + if proptools.Bool(dist.Append_artifact_with_product) { + appendProductString = fmt.Sprintf("_%s", ctx.Config().DeviceProduct()) + } + + if suffix != "" || appendProductString != "" || prependProductString != "" { + dest = prependProductString + strings.TrimSuffix(dest, ext) + suffix + appendProductString + ext } if dist.Dir != nil { @@ -510,6 +515,9 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod Module) { a.EntryMap = make(map[string][]string) base := mod.base() name := base.BaseModuleName() + if bmn, ok := mod.(baseModuleName); ok { + name = bmn.BaseModuleName() + } if a.OverrideName != "" { name = a.OverrideName } diff --git a/android/configurable_properties.go b/android/configurable_properties.go index 2c794a186..bde33e99b 100644 --- a/android/configurable_properties.go +++ b/android/configurable_properties.go @@ -7,7 +7,8 @@ import "github.com/google/blueprint/proptools" // to indicate a "default" case. func CreateSelectOsToBool(cases map[string]*bool) proptools.Configurable[bool] { var resultCases []proptools.ConfigurableCase[bool] - for pattern, value := range cases { + for _, pattern := range SortedKeys(cases) { + value := cases[pattern] if pattern == "" { resultCases = append(resultCases, proptools.NewConfigurableCase( []proptools.ConfigurablePattern{proptools.NewDefaultConfigurablePattern()}, diff --git a/android/module.go b/android/module.go index ecd0f239c..1538861d3 100644 --- a/android/module.go +++ b/android/module.go @@ -45,6 +45,14 @@ type Module interface { // For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go GenerateAndroidBuildActions(ModuleContext) + // CleanupAfterBuildActions is called after ModuleBase.GenerateBuildActions is finished. + // If all interactions with this module are handled via providers instead of direct access + // to the module then it can free memory attached to the module. + // This is a temporary measure to reduce memory usage, eventually blueprint's reference + // to the Module should be dropped after GenerateAndroidBuildActions once all accesses + // can be done through providers. + CleanupAfterBuildActions() + // Add dependencies to the components of a module, i.e. modules that are created // by the module and which are considered to be part of the creating module. // @@ -200,6 +208,12 @@ type Dist struct { // no change to the artifact file name. Append_artifact_with_product *bool `android:"arch_variant"` + // If true, then the artifact file will be prepended with <product name>-. For + // example, if the product is coral and the module is an android_app module + // of name foo, then the artifact would be coral-foo.apk. If false, there is + // no change to the artifact file name. + Prepend_artifact_with_product *bool `android:"arch_variant"` + // A string tag to select the OutputFiles associated with the tag. // // If no tag is specified then it will select the default dist paths provided @@ -2387,8 +2401,12 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) }) } } + + m.module.CleanupAfterBuildActions() } +func (m *ModuleBase) CleanupAfterBuildActions() {} + func SetJarJarPrefixHandler(handler func(ModuleContext)) { if jarJarPrefixHandler != nil { panic("jarJarPrefixHandler already set") diff --git a/android/module_proxy.go b/android/module_proxy.go index 561c4770c..81d90e9a0 100644 --- a/android/module_proxy.go +++ b/android/module_proxy.go @@ -27,6 +27,10 @@ func (m ModuleProxy) GenerateAndroidBuildActions(context ModuleContext) { panic("method is not implemented on ModuleProxy") } +func (m ModuleProxy) CleanupAfterBuildActions() { + panic("method is not implemented on ModuleProxy") +} + func (m ModuleProxy) ComponentDepsMutator(ctx BottomUpMutatorContext) { panic("method is not implemented on ModuleProxy") } diff --git a/android/otatools_package_cert_zip.go b/android/otatools_package_cert_zip.go new file mode 100644 index 000000000..3a654cfe5 --- /dev/null +++ b/android/otatools_package_cert_zip.go @@ -0,0 +1,62 @@ +// Copyright 2025 Google Inc. All rights reserved. +// +// 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 android + +import ( + "github.com/google/blueprint" +) + +func init() { + RegisterOtatoolsPackageBuildComponents(InitRegistrationContext) + pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") +} + +func RegisterOtatoolsPackageBuildComponents(ctx RegistrationContext) { + ctx.RegisterModuleType("otatools_package_cert_files", OtatoolsPackageFactory) +} + +type OtatoolsPackage struct { + ModuleBase +} + +func OtatoolsPackageFactory() Module { + module := &OtatoolsPackage{} + InitAndroidModule(module) + return module +} + +var ( + otatoolsPackageCertRule = pctx.AndroidStaticRule("otatools_package_cert_files", blueprint.RuleParams{ + Command: "echo '$out : ' $$(cat $in) > ${out}.d && ${SoongZipCmd} -o $out -l $in", + CommandDeps: []string{"${SoongZipCmd}"}, + Depfile: "${out}.d", + Description: "Zip otatools-package cert files", + }) +) + +func (fg *OtatoolsPackage) GenerateAndroidBuildActions(ctx ModuleContext) { + if ctx.ModuleDir() != "build/make/tools/otatools_package" { + ctx.ModuleErrorf("There can only be one otatools_package_cert_files module in build/make/tools/otatools_package") + return + } + fileListFile := PathForArbitraryOutput(ctx, ".module_paths", "OtaToolsCertFiles.list") + otatoolsPackageCertZip := PathForModuleOut(ctx, "otatools_package_cert_files.zip") + ctx.Build(pctx, BuildParams{ + Rule: otatoolsPackageCertRule, + Input: fileListFile, + Output: otatoolsPackageCertZip, + }) + ctx.SetOutputFiles([]Path{otatoolsPackageCertZip}, "") +} diff --git a/android/packaging.go b/android/packaging.go index bb1fe4e45..bf1840929 100644 --- a/android/packaging.go +++ b/android/packaging.go @@ -506,13 +506,11 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont // all packaging specs gathered from the high priority deps. var highPriorities []PackagingSpec - // Name of the dependency which requested the packaging spec. - // If this dep is overridden, the packaging spec will not be installed via this dependency chain. - // (the packaging spec might still be installed if there are some other deps which depend on it). - var depNames []string - // list of module names overridden - var overridden []string + overridden := make(map[string]bool) + + // all installed modules which are not overridden. + modulesToInstall := make(map[string]bool) var arches []ArchType for _, target := range getSupportedTargets(ctx) { @@ -529,6 +527,7 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont return false } + // find all overridden modules and packaging specs ctx.VisitDirectDepsProxy(func(child ModuleProxy) { depTag := ctx.OtherModuleDependencyTag(child) if pi, ok := depTag.(PackagingItem); !ok || !pi.IsPackagingItem() { @@ -556,20 +555,32 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont regularPriorities = append(regularPriorities, ps) } - depNames = append(depNames, child.Name()) - overridden = append(overridden, ps.overrides.ToSlice()...) + for o := range ps.overrides.Iter() { + overridden[o] = true + } + } + }) + + // gather modules to install, skipping overridden modules + ctx.WalkDeps(func(child, parent Module) bool { + owner := ctx.OtherModuleName(child) + if o, ok := child.(OverridableModule); ok { + if overriddenBy := o.GetOverriddenBy(); overriddenBy != "" { + owner = overriddenBy + } + } + if overridden[owner] { + return false } + modulesToInstall[owner] = true + return true }) filterOverridden := func(input []PackagingSpec) []PackagingSpec { - // input minus packaging specs that are overridden + // input minus packaging specs that are not installed var filtered []PackagingSpec - for index, ps := range input { - if ps.owner != "" && InList(ps.owner, overridden) { - continue - } - // The dependency which requested this packaging spec has been overridden. - if InList(depNames[index], overridden) { + for _, ps := range input { + if !modulesToInstall[ps.owner] { continue } filtered = append(filtered, ps) diff --git a/android/raw_files.go b/android/raw_files.go index fd371965c..ebba4d145 100644 --- a/android/raw_files.go +++ b/android/raw_files.go @@ -26,6 +26,7 @@ import ( "testing" "github.com/google/blueprint" + "github.com/google/blueprint/syncmap" "github.com/google/blueprint/proptools" ) @@ -213,10 +214,10 @@ type rawFileInfo struct { var rawFileSetKey OnceKey = NewOnceKey("raw file set") -func getRawFileSet(config Config) *SyncMap[string, rawFileInfo] { +func getRawFileSet(config Config) *syncmap.SyncMap[string, rawFileInfo] { return config.Once(rawFileSetKey, func() any { - return &SyncMap[string, rawFileInfo]{} - }).(*SyncMap[string, rawFileInfo]) + return &syncmap.SyncMap[string, rawFileInfo]{} + }).(*syncmap.SyncMap[string, rawFileInfo]) } // ContentFromFileRuleForTests returns the content that was passed to a WriteFileRule for use diff --git a/android/test_suites.go b/android/test_suites.go index 9eaf78549..dbcd48c79 100644 --- a/android/test_suites.go +++ b/android/test_suites.go @@ -42,6 +42,12 @@ type TestSuiteInfo struct { var TestSuiteInfoProvider = blueprint.NewProvider[TestSuiteInfo]() +type SupportFilesInfo struct { + SupportFiles InstallPaths +} + +var SupportFilesInfoProvider = blueprint.NewProvider[SupportFilesInfo]() + func (t *testSuiteFiles) GenerateBuildActions(ctx SingletonContext) { files := make(map[string]map[string]InstallPaths) diff --git a/android/util.go b/android/util.go index 7b305b575..4520f400e 100644 --- a/android/util.go +++ b/android/util.go @@ -23,7 +23,6 @@ import ( "runtime" "sort" "strings" - "sync" "github.com/google/blueprint/proptools" ) @@ -646,35 +645,6 @@ func AddToStringSet(set map[string]bool, items []string) { } } -// SyncMap is a wrapper around sync.Map that provides type safety via generics. -type SyncMap[K comparable, V any] struct { - sync.Map -} - -// Load returns the value stored in the map for a key, or the zero value if no -// value is present. -// The ok result indicates whether value was found in the map. -func (m *SyncMap[K, V]) Load(key K) (value V, ok bool) { - v, ok := m.Map.Load(key) - if !ok { - return *new(V), false - } - return v.(V), true -} - -// Store sets the value for a key. -func (m *SyncMap[K, V]) Store(key K, value V) { - m.Map.Store(key, value) -} - -// LoadOrStore returns the existing value for the key if present. -// Otherwise, it stores and returns the given value. -// The loaded result is true if the value was loaded, false if stored. -func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) { - v, loaded := m.Map.LoadOrStore(key, value) - return v.(V), loaded -} - // AppendIfNotZero append the given value to the slice if it is not the zero value // for its type. func AppendIfNotZero[T comparable](slice []T, value T) []T { diff --git a/android/variable.go b/android/variable.go index 357d137c7..f00dd138b 100644 --- a/android/variable.go +++ b/android/variable.go @@ -715,6 +715,10 @@ type PartitionVariables struct { ReleaseToolsExtensionDir string `json:",omitempty"` + BoardPartialOtaUpdatePartitionsList []string `json:",omitempty"` + BoardFlashBlockSize string `json:",omitempty"` + BootloaderInUpdatePackage bool `json:",omitempty"` + BoardFastbootInfoFile string `json:",omitempty"` } |