Skip to content

Commit

Permalink
Merge tag 'android-14.0.0_r50' into staging/lineage-21.0_merge-androi…
Browse files Browse the repository at this point in the history
…d-14.0.0_r50

Android 14.0.0 Release 50 (AP2A.240605.024)

* tag 'android-14.0.0_r50': (355 commits)
  release-config: sync from goog/main
  Merge "Add secretkeeper-v1-java to platform APIs" into main am: f28b569 am: 196729f
  Create rule to generate the exportable api files when checkapi is disabled
  Revert "Additional cleanup prior to adding the runtime stubs"
  Revert "Generate runtime stubs in droidstubs"
  Support partial module variants with apex_contributions
  Fix non-determinism in prebuilt selection
  Use BaseModuleName for LOCAL_MODULE
  Disable source javalib dexpreopt when using prebuilt apex
  Allow clippy::disallowed_names since it can be used for debugging
  Add the build flags for apex contribution contents
  Add a source_module_name to android_app
  Revert "Fix non-determinism in prebuilt selection"
  Fix non-determinism in prebuilt selection
  Copy imported APKs to output filename
  disablePrebuilt: also clear sanitizer-dependent Srcs
  Define libc++ config macros to nothing
  Remove --multitree-build
  Some tweaks to the aconfig flag collection logic
  Use R.txt files from aar files directly
  ...

 Conflicts:
	android/allowlists/allowlists.go
	androidmk/androidmk/android.go
	apex/apex.go
	etc/prebuilt_etc.go
	java/android_manifest.go

Change-Id: I5294562126628c0a9917f145ed933b6b13c05b3d
  • Loading branch information
mikeNG authored and anoosragh69 committed Jun 25, 2024
1 parent 3824227 commit cf7e9cc
Show file tree
Hide file tree
Showing 321 changed files with 13,291 additions and 6,872 deletions.
4 changes: 3 additions & 1 deletion OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ [email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

per-file build/soong/ui/build/androidmk_denylist.go = [email protected], [email protected]
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ subpackages) can use this module.
* `["//visibility:override"]`: Discards any rules inherited from defaults or a
creating module. Can only be used at the beginning of a list of visibility
rules.
* `["//visibility:any_partition"]`: Any modules of type android_filesystem
or android_system_image can use this module. Intended for modules that no one
should link against, but should still be included in soong-built partitions.
* `["//some/package:__pkg__", "//other/package:__pkg__"]`: Only modules in
`some/package` and `other/package` (defined in `some/package/*.bp` and
`other/package/*.bp`) have access to this module. Note that sub-packages do not
Expand Down Expand Up @@ -603,7 +606,7 @@ ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR=build/soong \
* [Build Performance](docs/perf.md)
* [Generating CLion Projects](docs/clion.md)
* [Generating YouCompleteMe/VSCode compile\_commands.json file](docs/compdb.md)
* Make-specific documentation: [build/make/README.md](https://android.googlesource.com/platform/build/+/master/README.md)
* Make-specific documentation: [build/make/README.md](https://android.googlesource.com/platform/build/+/main/README.md)

## Developing for Soong

Expand Down
1 change: 1 addition & 0 deletions aconfig/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bootstrap_go_package {
"aconfig_declarations_test.go",
"aconfig_values_test.go",
"aconfig_value_set_test.go",
"all_aconfig_declarations_test.go",
],
pluginFor: ["soong_build"],
}
86 changes: 12 additions & 74 deletions aconfig/aconfig_declarations.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ type DeclarationsModule struct {

// Container(system/vendor/apex) that this module belongs to
Container string

// The flags will only be repackaged if this prop is true.
Exportable bool
}

intermediatePath android.WritablePath
Expand Down Expand Up @@ -112,38 +115,17 @@ func optionalVariable(prefix string, value string) string {
return sb.String()
}

// Provider published by aconfig_value_set
type DeclarationsProviderData struct {
Package string
Container string
IntermediateCacheOutputPath android.WritablePath
IntermediateDumpOutputPath android.WritablePath
}

var DeclarationsProviderKey = blueprint.NewProvider(DeclarationsProviderData{})

// This is used to collect the aconfig declarations info on the transitive closure,
// the data is keyed on the container.
type TransitiveDeclarationsInfo struct {
AconfigFiles map[string]android.Paths
}

var TransitiveDeclarationsInfoProvider = blueprint.NewProvider(TransitiveDeclarationsInfo{})

func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag
valuesFiles := make([]android.Path, 0)
ctx.VisitDirectDeps(func(dep android.Module) {
if !ctx.OtherModuleHasProvider(dep, valueSetProviderKey) {
// Other modules get injected as dependencies too, for example the license modules
return
}
depData := ctx.OtherModuleProvider(dep, valueSetProviderKey).(valueSetProviderData)
paths, ok := depData.AvailablePackages[module.properties.Package]
if ok {
valuesFiles = append(valuesFiles, paths...)
for _, path := range paths {
module.properties.Values = append(module.properties.Values, path.String())
if depData, ok := android.OtherModuleProvider(ctx, dep, valueSetProviderKey); ok {
paths, ok := depData.AvailablePackages[module.properties.Package]
if ok {
valuesFiles = append(valuesFiles, paths...)
for _, path := range paths {
module.properties.Values = append(module.properties.Values, path.String())
}
}
}
})
Expand Down Expand Up @@ -177,56 +159,12 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
Description: "aconfig_text",
})

ctx.SetProvider(DeclarationsProviderKey, DeclarationsProviderData{
android.SetProvider(ctx, android.AconfigDeclarationsProviderKey, android.AconfigDeclarationsProviderData{
Package: module.properties.Package,
Container: module.properties.Container,
Exportable: module.properties.Exportable,
IntermediateCacheOutputPath: intermediateCacheFilePath,
IntermediateDumpOutputPath: intermediateDumpFilePath,
})

}
func CollectDependencyAconfigFiles(ctx android.ModuleContext, mergedAconfigFiles *map[string]android.Paths) {
if *mergedAconfigFiles == nil {
*mergedAconfigFiles = make(map[string]android.Paths)
}
ctx.VisitDirectDeps(func(module android.Module) {
if dep := ctx.OtherModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData); dep.IntermediateCacheOutputPath != nil {
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath)
return
}
if dep := ctx.OtherModuleProvider(module, TransitiveDeclarationsInfoProvider).(TransitiveDeclarationsInfo); len(dep.AconfigFiles) > 0 {
for container, v := range dep.AconfigFiles {
(*mergedAconfigFiles)[container] = append((*mergedAconfigFiles)[container], v...)
}
}
})

for container, aconfigFiles := range *mergedAconfigFiles {
(*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, aconfigFiles)
}

ctx.SetProvider(TransitiveDeclarationsInfoProvider, TransitiveDeclarationsInfo{
AconfigFiles: *mergedAconfigFiles,
})
}

func mergeAconfigFiles(ctx android.ModuleContext, inputs android.Paths) android.Paths {
inputs = android.LastUniquePaths(inputs)
if len(inputs) == 1 {
return android.Paths{inputs[0]}
}

output := android.PathForModuleOut(ctx, "aconfig_merged.pb")

ctx.Build(pctx, android.BuildParams{
Rule: mergeAconfigFilesRule,
Description: "merge aconfig files",
Inputs: inputs,
Output: output,
Args: map[string]string{
"flags": android.JoinWithPrefix(inputs.Strings(), "--cache "),
},
})

return android.Paths{output}
}
23 changes: 22 additions & 1 deletion aconfig/aconfig_declarations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestAconfigDeclarations(t *testing.T) {
name: "module_name",
package: "com.example.package",
container: "com.android.foo",
exportable: true,
srcs: [
"foo.aconfig",
"bar.aconfig",
Expand All @@ -38,13 +39,33 @@ func TestAconfigDeclarations(t *testing.T) {
module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)

// Check that the provider has the right contents
depData := result.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData)
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
android.AssertStringEquals(t, "package", depData.Package, "com.example.package")
android.AssertStringEquals(t, "container", depData.Container, "com.android.foo")
android.AssertBoolEquals(t, "exportable", depData.Exportable, true)
if !strings.HasSuffix(depData.IntermediateCacheOutputPath.String(), "/intermediate.pb") {
t.Errorf("Missing intermediates proto path in provider: %s", depData.IntermediateCacheOutputPath.String())
}
if !strings.HasSuffix(depData.IntermediateDumpOutputPath.String(), "/intermediate.txt") {
t.Errorf("Missing intermediates text path in provider: %s", depData.IntermediateDumpOutputPath.String())
}
}

func TestAconfigDeclarationsWithExportableUnset(t *testing.T) {
bp := `
aconfig_declarations {
name: "module_name",
package: "com.example.package",
container: "com.android.foo",
srcs: [
"foo.aconfig",
"bar.aconfig",
],
}
`
result := runTest(t, android.FixtureExpectsNoErrors, bp)

module := result.ModuleForTests("module_name", "").Module().(*DeclarationsModule)
depData, _ := android.SingletonModuleProvider(result, module, android.AconfigDeclarationsProviderKey)
android.AssertBoolEquals(t, "exportable", depData.Exportable, false)
}
16 changes: 6 additions & 10 deletions aconfig/aconfig_value_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type valueSetProviderData struct {
AvailablePackages map[string]android.Paths
}

var valueSetProviderKey = blueprint.NewProvider(valueSetProviderData{})
var valueSetProviderKey = blueprint.NewProvider[valueSetProviderData]()

func (module *ValueSetModule) DepsMutator(ctx android.BottomUpMutatorContext) {
deps := ctx.AddDependency(ctx.Module(), valueSetTag, module.properties.Values...)
Expand All @@ -73,18 +73,14 @@ func (module *ValueSetModule) GenerateAndroidBuildActions(ctx android.ModuleCont
// to append values to their aconfig actions.
packages := make(map[string]android.Paths)
ctx.VisitDirectDeps(func(dep android.Module) {
if !ctx.OtherModuleHasProvider(dep, valuesProviderKey) {
// Other modules get injected as dependencies too, for example the license modules
return
if depData, ok := android.OtherModuleProvider(ctx, dep, valuesProviderKey); ok {
srcs := make([]android.Path, len(depData.Values))
copy(srcs, depData.Values)
packages[depData.Package] = srcs
}
depData := ctx.OtherModuleProvider(dep, valuesProviderKey).(valuesProviderData)

srcs := make([]android.Path, len(depData.Values))
copy(srcs, depData.Values)
packages[depData.Package] = srcs

})
ctx.SetProvider(valueSetProviderKey, valueSetProviderData{
android.SetProvider(ctx, valueSetProviderKey, valueSetProviderData{
AvailablePackages: packages,
})
}
2 changes: 1 addition & 1 deletion aconfig/aconfig_value_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ func TestAconfigValueSet(t *testing.T) {
module := result.ModuleForTests("module_name", "").Module().(*ValueSetModule)

// Check that the provider has the right contents
depData := result.ModuleProvider(module, valueSetProviderKey).(valueSetProviderData)
depData, _ := android.SingletonModuleProvider(result, module, valueSetProviderKey)
android.AssertStringEquals(t, "AvailablePackages", "blah.aconfig_values", depData.AvailablePackages["foo.package"][0].String())
}
4 changes: 2 additions & 2 deletions aconfig/aconfig_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type valuesProviderData struct {
Values android.Paths
}

var valuesProviderKey = blueprint.NewProvider(valuesProviderData{})
var valuesProviderKey = blueprint.NewProvider[valuesProviderData]()

func (module *ValuesModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if len(module.properties.Package) == 0 {
Expand All @@ -64,5 +64,5 @@ func (module *ValuesModule) GenerateAndroidBuildActions(ctx android.ModuleContex
Package: module.properties.Package,
Values: android.PathsForModuleSrc(ctx, module.properties.Srcs),
}
ctx.SetProvider(valuesProviderKey, providerData)
android.SetProvider(ctx, valuesProviderKey, providerData)
}
2 changes: 1 addition & 1 deletion aconfig/aconfig_values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAconfigValues(t *testing.T) {
module := result.ModuleForTests("module_name", "").Module().(*ValuesModule)

// Check that the provider has the right contents
depData := result.ModuleProvider(module, valuesProviderKey).(valuesProviderData)
depData, _ := android.SingletonModuleProvider(result, module, valuesProviderKey)
android.AssertStringEquals(t, "package", "foo.package", depData.Package)
android.AssertPathsEndWith(t, "srcs", []string{"blah.aconfig_values"}, depData.Values)
}
49 changes: 41 additions & 8 deletions aconfig/all_aconfig_declarations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package aconfig

import (
"android/soong/android"
"fmt"
)

// A singleton module that collects all of the aconfig flags declared in the
Expand All @@ -30,34 +31,66 @@ func AllAconfigDeclarationsFactory() android.Singleton {
}

type allAconfigDeclarationsSingleton struct {
intermediatePath android.OutputPath
intermediateBinaryProtoPath android.OutputPath
intermediateTextProtoPath android.OutputPath
}

func (this *allAconfigDeclarationsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
// Find all of the aconfig_declarations modules
var packages = make(map[string]int)
var cacheFiles android.Paths
ctx.VisitAllModules(func(module android.Module) {
if !ctx.ModuleHasProvider(module, DeclarationsProviderKey) {
decl, ok := android.SingletonModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey)
if !ok {
return
}
decl := ctx.ModuleProvider(module, DeclarationsProviderKey).(DeclarationsProviderData)
cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath)
packages[decl.Package]++
})

// Generate build action for aconfig
this.intermediatePath = android.PathForIntermediates(ctx, "all_aconfig_declarations.pb")
var numOffendingPkg = 0
for pkg, cnt := range packages {
if cnt > 1 {
fmt.Printf("%d aconfig_declarations found for package %s\n", cnt, pkg)
numOffendingPkg++
}
}

if numOffendingPkg > 0 {
panic(fmt.Errorf("Only one aconfig_declarations allowed for each package."))
}

// Generate build action for aconfig (binary proto output)
this.intermediateBinaryProtoPath = android.PathForIntermediates(ctx, "all_aconfig_declarations.pb")
ctx.Build(pctx, android.BuildParams{
Rule: AllDeclarationsRule,
Inputs: cacheFiles,
Output: this.intermediatePath,
Output: this.intermediateBinaryProtoPath,
Description: "all_aconfig_declarations",
Args: map[string]string{
"cache_files": android.JoinPathsWithPrefix(cacheFiles, "--cache "),
},
})
ctx.Phony("all_aconfig_declarations", this.intermediatePath)
ctx.Phony("all_aconfig_declarations", this.intermediateBinaryProtoPath)

// Generate build action for aconfig (text proto output)
this.intermediateTextProtoPath = android.PathForIntermediates(ctx, "all_aconfig_declarations.textproto")
ctx.Build(pctx, android.BuildParams{
Rule: AllDeclarationsRuleTextProto,
Inputs: cacheFiles,
Output: this.intermediateTextProtoPath,
Description: "all_aconfig_declarations_textproto",
Args: map[string]string{
"cache_files": android.JoinPathsWithPrefix(cacheFiles, "--cache "),
},
})
ctx.Phony("all_aconfig_declarations_textproto", this.intermediateTextProtoPath)
}

func (this *allAconfigDeclarationsSingleton) MakeVars(ctx android.MakeVarsContext) {
ctx.DistForGoal("droid", this.intermediatePath)
ctx.DistForGoal("droid", this.intermediateBinaryProtoPath)
for _, goal := range []string{"droid", "sdk"} {
ctx.DistForGoalWithFilename(goal, this.intermediateBinaryProtoPath, "flags.pb")
ctx.DistForGoalWithFilename(goal, this.intermediateTextProtoPath, "flags.textproto")
}
}
48 changes: 48 additions & 0 deletions aconfig/all_aconfig_declarations_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2024 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 aconfig

import (
"testing"

"android/soong/android"
)

func TestTwoAconfigDeclarationsPerPackage(t *testing.T) {
bp := `
aconfig_declarations {
name: "module_name.foo",
package: "com.example.package",
container: "com.android.foo",
srcs: [
"foo.aconfig",
],
}
aconfig_declarations {
name: "module_name.bar",
package: "com.example.package",
container: "com.android.foo",
srcs: [
"bar.aconfig",
],
}
`
errMsg := "Only one aconfig_declarations allowed for each package."
android.GroupFixturePreparers(
PrepareForTestWithAconfigBuildComponents).
ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(errMsg)).
RunTestWithBp(t, bp)
}
Loading

0 comments on commit cf7e9cc

Please sign in to comment.