Snap for 11973804 from efe843b319 to 24Q3-release

Change-Id: Ie1f1f9555e0fff90981624cac9e575bafc09300f
This commit is contained in:
Android Build Coastguard Worker 2024-06-15 01:00:40 +00:00
commit 7ec179513d
32 changed files with 283 additions and 257 deletions

View file

@ -15,7 +15,6 @@
package aconfig
import (
"fmt"
"strings"
"android/soong/android"
@ -44,8 +43,6 @@ type DeclarationsModule struct {
// The flags will only be repackaged if this prop is true.
Exportable bool
}
intermediatePath android.WritablePath
}
func DeclarationsFactory() android.Module {
@ -86,18 +83,6 @@ func (module *DeclarationsModule) DepsMutator(ctx android.BottomUpMutatorContext
}
}
func (module *DeclarationsModule) OutputFiles(tag string) (android.Paths, error) {
switch tag {
case "":
// The default output of this module is the intermediates format, which is
// not installable and in a private format that no other rules can handle
// correctly.
return []android.Path{module.intermediatePath}, nil
default:
return nil, fmt.Errorf("unsupported aconfig_declarations module reference tag %q", tag)
}
}
func joinAndPrefix(prefix string, values []string) string {
var sb strings.Builder
for _, v := range values {
@ -171,5 +156,4 @@ func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.Module
IntermediateCacheOutputPath: intermediateCacheFilePath,
IntermediateDumpOutputPath: intermediateDumpFilePath,
})
}

View file

@ -15,7 +15,6 @@
package build_flags
import (
"fmt"
"strings"
"android/soong/android"
@ -39,8 +38,6 @@ type DeclarationsModule struct {
// aconfig files, relative to this Android.bp file
Srcs []string `android:"path"`
}
intermediatePath android.WritablePath
}
func DeclarationsFactory() android.Module {
@ -53,18 +50,6 @@ func DeclarationsFactory() android.Module {
return module
}
func (module *DeclarationsModule) OutputFiles(tag string) (android.Paths, error) {
switch tag {
case "":
// The default output of this module is the intermediates format, which is
// not installable and in a private format that no other rules can handle
// correctly.
return []android.Path{module.intermediatePath}, nil
default:
return nil, fmt.Errorf("unsupported build_flags_declarations module reference tag %q", tag)
}
}
func joinAndPrefix(prefix string, values []string) string {
var sb strings.Builder
for _, v := range values {

View file

@ -15,7 +15,6 @@
package codegen
import (
"fmt"
"maps"
"android/soong/android"
@ -40,11 +39,6 @@ type AconfigDeclarationsGroup struct {
android.DefaultableModuleBase
properties AconfigDeclarationsGroupProperties
aconfigDeclarationNames []string
intermediateCacheOutputPaths android.Paths
javaSrcjars android.Paths
modeInfos map[string]android.ModeInfo
}
type AconfigDeclarationsGroupProperties struct {
@ -77,63 +71,45 @@ func (adg *AconfigDeclarationsGroup) DepsMutator(ctx android.BottomUpMutatorCont
ctx.AddDependency(ctx.Module(), rustAconfigLibraryTag, adg.properties.Rust_aconfig_libraries...)
}
func (adg *AconfigDeclarationsGroup) VisitDeps(ctx android.ModuleContext) {
adg.modeInfos = make(map[string]android.ModeInfo)
func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
modeInfos := make(map[string]android.ModeInfo)
var aconfigDeclarationNames []string
var intermediateCacheOutputPaths android.Paths
var javaSrcjars android.Paths
ctx.VisitDirectDeps(func(dep android.Module) {
tag := ctx.OtherModuleDependencyTag(dep)
if provider, ok := android.OtherModuleProvider(ctx, dep, android.CodegenInfoProvider); ok {
// aconfig declaration names and cache files are collected for all aconfig library dependencies
adg.aconfigDeclarationNames = append(adg.aconfigDeclarationNames, provider.AconfigDeclarations...)
adg.intermediateCacheOutputPaths = append(adg.intermediateCacheOutputPaths, provider.IntermediateCacheOutputPaths...)
aconfigDeclarationNames = append(aconfigDeclarationNames, provider.AconfigDeclarations...)
intermediateCacheOutputPaths = append(intermediateCacheOutputPaths, provider.IntermediateCacheOutputPaths...)
switch tag {
case aconfigDeclarationsGroupTag:
// Will retrieve outputs from another language codegen modules when support is added
adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
maps.Copy(adg.modeInfos, provider.ModeInfos)
javaSrcjars = append(javaSrcjars, provider.Srcjars...)
maps.Copy(modeInfos, provider.ModeInfos)
case javaAconfigLibraryTag:
adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
maps.Copy(adg.modeInfos, provider.ModeInfos)
javaSrcjars = append(javaSrcjars, provider.Srcjars...)
maps.Copy(modeInfos, provider.ModeInfos)
case ccAconfigLibraryTag:
maps.Copy(adg.modeInfos, provider.ModeInfos)
maps.Copy(modeInfos, provider.ModeInfos)
case rustAconfigLibraryTag:
maps.Copy(adg.modeInfos, provider.ModeInfos)
maps.Copy(modeInfos, provider.ModeInfos)
}
}
})
}
func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) {
adg.VisitDeps(ctx)
adg.aconfigDeclarationNames = android.FirstUniqueStrings(adg.aconfigDeclarationNames)
adg.intermediateCacheOutputPaths = android.FirstUniquePaths(adg.intermediateCacheOutputPaths)
aconfigDeclarationNames = android.FirstUniqueStrings(aconfigDeclarationNames)
intermediateCacheOutputPaths = android.FirstUniquePaths(intermediateCacheOutputPaths)
android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
AconfigDeclarations: adg.aconfigDeclarationNames,
IntermediateCacheOutputPaths: adg.intermediateCacheOutputPaths,
Srcjars: adg.javaSrcjars,
ModeInfos: adg.modeInfos,
AconfigDeclarations: aconfigDeclarationNames,
IntermediateCacheOutputPaths: intermediateCacheOutputPaths,
Srcjars: javaSrcjars,
ModeInfos: modeInfos,
})
}
var _ android.OutputFileProducer = (*AconfigDeclarationsGroup)(nil)
func (adg *AconfigDeclarationsGroup) OutputFiles(tag string) (android.Paths, error) {
switch tag {
case "":
return adg.intermediateCacheOutputPaths, nil
case ".srcjars":
return adg.javaSrcjars, nil
default:
return nil, fmt.Errorf("unsupported module reference tag %s", tag)
}
}
func (adg *AconfigDeclarationsGroup) Srcjars() android.Paths {
return adg.javaSrcjars
}
func (adg *AconfigDeclarationsGroup) AconfigDeclarations() []string {
return adg.aconfigDeclarationNames
ctx.SetOutputFiles(intermediateCacheOutputPaths, "")
ctx.SetOutputFiles(javaSrcjars, ".srcjars")
}

View file

@ -15,8 +15,6 @@
package codegen
import (
"fmt"
"android/soong/android"
"android/soong/java"
@ -80,7 +78,7 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild
// Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag
declarationsModules := ctx.GetDirectDepsWithTag(declarationsTag)
if len(declarationsModules) != 1 {
panic(fmt.Errorf("Exactly one aconfig_declarations property required"))
panic("Exactly one aconfig_declarations property required")
}
declarations, _ := android.OtherModuleProvider(ctx, declarationsModules[0], android.AconfigDeclarationsProviderKey)
@ -133,10 +131,6 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild
return srcJarPath, declarations.IntermediateCacheOutputPath
}
func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) AconfigDeclarations() *string {
return proptools.StringPtr(callbacks.properties.Aconfig_declarations)
}
func isModeSupported(mode string) bool {
return android.InList(mode, aconfigSupportedModes)
}

View file

@ -44,9 +44,8 @@ type ImageInterface interface {
ExtraImageVariations(ctx BaseModuleContext) []string
// SetImageVariation is called for each newly created image variant. The receiver is the original
// module, "variation" is the name of the newly created variant and "module" is the newly created
// variant itself.
SetImageVariation(ctx BaseModuleContext, variation string, module Module)
// module, "variation" is the name of the newly created variant. "variation" is set on the receiver.
SetImageVariation(ctx BaseModuleContext, variation string)
}
const (
@ -106,7 +105,7 @@ func imageMutator(ctx BottomUpMutatorContext) {
mod := ctx.CreateVariations(variations...)
for i, v := range variations {
mod[i].base().setImageVariation(v)
m.SetImageVariation(ctx, v, mod[i])
mod[i].(ImageInterface).SetImageVariation(ctx, v)
}
}
}

View file

@ -778,6 +778,27 @@ func TestSelects(t *testing.T) {
my_string_list: &[]string{"a.cpp", "b.cpp", "c.cpp"},
},
},
{
name: "Test AppendSimpleValue",
bp: `
my_module_type {
name: "foo",
my_string_list: ["a.cpp"] + select(soong_config_variable("my_namespace", "my_variable"), {
"a": ["a.cpp"],
"b": ["b.cpp"],
default: ["c.cpp"],
}),
}
`,
vendorVars: map[string]map[string]string{
"selects_test": {
"append_to_string_list": "foo.cpp",
},
},
provider: selectsTestProvider{
my_string_list: &[]string{"a.cpp", "c.cpp", "foo.cpp"},
},
},
}
for _, tc := range testCases {
@ -892,6 +913,10 @@ func optionalToPtr[T any](o proptools.ConfigurableOptional[T]) *T {
}
func (p *selectsMockModule) GenerateAndroidBuildActions(ctx ModuleContext) {
toAppend := ctx.Config().VendorConfig("selects_test").String("append_to_string_list")
if toAppend != "" {
p.properties.My_string_list.AppendSimpleValue([]string{toAppend})
}
SetProvider(ctx, selectsTestProviderKey, selectsTestProvider{
my_bool: optionalToPtr(p.properties.My_bool.Get(ctx)),
my_string: optionalToPtr(p.properties.My_string.Get(ctx)),

View file

@ -1663,12 +1663,12 @@ var _ javaModule = (*java.DexImport)(nil)
var _ javaModule = (*java.SdkLibraryImport)(nil)
// apexFileForJavaModule creates an apexFile for a java module's dex implementation jar.
func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile {
func apexFileForJavaModule(ctx android.ModuleContext, module javaModule) apexFile {
return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath(ctx).PathOrNil())
}
// apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file.
func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
func apexFileForJavaModuleWithFile(ctx android.ModuleContext, module javaModule, dexImplementationJar android.Path) apexFile {
dirInApex := "javalib"
af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module)
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
@ -1679,10 +1679,12 @@ func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaMod
if sdkLib, ok := module.(*java.SdkLibrary); ok {
for _, install := range sdkLib.BuiltInstalledForApex() {
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
install.PackageFile(ctx)
}
} else if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
install.PackageFile(ctx)
}
}
return af

View file

@ -197,6 +197,7 @@ func (p *prebuiltCommon) initApexFilesForAndroidMk(ctx android.ModuleContext) {
// If this apex contains a system server jar, then the dexpreopt artifacts should be added as required
for _, install := range p.Dexpreopter.DexpreoptBuiltInstalledForApex() {
p.requiredModuleNames = append(p.requiredModuleNames, install.FullModuleName())
install.PackageFile(ctx)
}
}

View file

@ -131,7 +131,7 @@ func (bpf *bpf) ExtraImageVariations(ctx android.BaseModuleContext) []string {
return nil
}
func (bpf *bpf) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (bpf *bpf) SetImageVariation(ctx android.BaseModuleContext, variation string) {
bpf.properties.VendorInternal = variation == "vendor"
}

View file

@ -1,6 +1,6 @@
<<$srcs := getSources .M>>
<<$includeDirs := getIncludeDirs .Ctx .M>>
<<$cflags := (getCompilerProperties .M).Cflags>>
<<$cflags := getCflagsProperty .Ctx .M>>
<<$deps := mapLibraries .Ctx .M (concat5
(getLinkerProperties .M).Whole_static_libs
(getLinkerProperties .M).Static_libs

View file

@ -187,6 +187,10 @@ func parseTemplate(templateContents string) *template.Template {
"getCompilerProperties": func(m *Module) BaseCompilerProperties {
return m.compiler.baseCompilerProps()
},
"getCflagsProperty": func(ctx android.ModuleContext, m *Module) []string {
cflags := m.compiler.baseCompilerProps().Cflags
return cflags.GetOrDefault(ctx, nil)
},
"getLinkerProperties": func(m *Module) BaseLinkerProperties {
return m.linker.baseLinkerProps()
},

View file

@ -50,7 +50,7 @@ type BaseCompilerProperties struct {
Exclude_srcs []string `android:"path,arch_variant"`
// list of module-specific flags that will be used for C and C++ compiles.
Cflags []string `android:"arch_variant"`
Cflags proptools.Configurable[[]string] `android:"arch_variant"`
// list of module-specific flags that will be used for C++ compiles
Cppflags []string `android:"arch_variant"`
@ -98,7 +98,7 @@ type BaseCompilerProperties struct {
// list of generated headers to add to the include path. These are the names
// of genrule modules.
Generated_headers []string `android:"arch_variant,variant_prepend"`
Generated_headers proptools.Configurable[[]string] `android:"arch_variant,variant_prepend"`
// pass -frtti instead of -fno-rtti
Rtti *bool `android:"arch_variant"`
@ -274,7 +274,7 @@ func (compiler *baseCompiler) Srcs() android.Paths {
}
func (compiler *baseCompiler) appendCflags(flags []string) {
compiler.Properties.Cflags = append(compiler.Properties.Cflags, flags...)
compiler.Properties.Cflags.AppendSimpleValue(flags)
}
func (compiler *baseCompiler) appendAsflags(flags []string) {
@ -302,7 +302,7 @@ func (compiler *baseCompiler) compilerInit(ctx BaseModuleContext) {}
func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...)
deps.GeneratedSources = removeListFromList(deps.GeneratedSources, compiler.Properties.Exclude_generated_sources)
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...)
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers.GetOrDefault(ctx, nil)...)
deps.AidlLibs = append(deps.AidlLibs, compiler.Properties.Aidl.Libs...)
android.ProtoDeps(ctx, &compiler.Proto)
@ -372,7 +372,8 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
CheckBadCompilerFlags(ctx, "cflags", compiler.Properties.Cflags)
cflags := compiler.Properties.Cflags.GetOrDefault(ctx, nil)
CheckBadCompilerFlags(ctx, "cflags", cflags)
CheckBadCompilerFlags(ctx, "cppflags", compiler.Properties.Cppflags)
CheckBadCompilerFlags(ctx, "conlyflags", compiler.Properties.Conlyflags)
CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags)
@ -385,7 +386,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
esc := proptools.NinjaAndShellEscapeList
flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Cflags)...)
flags.Local.CFlags = append(flags.Local.CFlags, esc(cflags)...)
flags.Local.CppFlags = append(flags.Local.CppFlags, esc(compiler.Properties.Cppflags)...)
flags.Local.ConlyFlags = append(flags.Local.ConlyFlags, esc(compiler.Properties.Conlyflags)...)
flags.Local.AsFlags = append(flags.Local.AsFlags, esc(compiler.Properties.Asflags)...)
@ -819,7 +820,7 @@ type RustBindgenClangProperties struct {
Header_libs []string `android:"arch_variant,variant_prepend"`
// list of clang flags required to correctly interpret the headers.
Cflags []string `android:"arch_variant"`
Cflags proptools.Configurable[[]string] `android:"arch_variant"`
// list of c++ specific clang flags required to correctly interpret the headers.
// This is provided primarily to make sure cppflags defined in cc_defaults are pulled in.

View file

@ -50,6 +50,8 @@ var (
darwinSupportedSdkVersions = []string{
"11",
"12",
"13",
"14",
}
darwinAvailableLibraries = append(

View file

@ -62,6 +62,8 @@ func GenRuleFactory() android.Module {
android.InitApexModule(module)
android.InitDefaultableModule(module)
return module
}
@ -114,5 +116,5 @@ func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleCont
return variants
}
func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}

View file

@ -527,30 +527,29 @@ func squashRamdiskSrcs(m *Module) {
}
}
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module)
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
if variant == android.RamdiskVariation {
m.MakeAsPlatform()
squashRamdiskSrcs(m)
c.MakeAsPlatform()
squashRamdiskSrcs(c)
} else if variant == android.VendorRamdiskVariation {
m.MakeAsPlatform()
squashVendorRamdiskSrcs(m)
c.MakeAsPlatform()
squashVendorRamdiskSrcs(c)
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
squashRecoverySrcs(m)
c.MakeAsPlatform()
squashRecoverySrcs(c)
} else if strings.HasPrefix(variant, VendorVariation) {
m.Properties.ImageVariation = VendorVariation
c.Properties.ImageVariation = VendorVariation
if strings.HasPrefix(variant, VendorVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
c.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
}
squashVendorSrcs(m)
squashVendorSrcs(c)
} else if strings.HasPrefix(variant, ProductVariation) {
m.Properties.ImageVariation = ProductVariation
c.Properties.ImageVariation = ProductVariation
if strings.HasPrefix(variant, ProductVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
c.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
}
squashProductSrcs(m)
squashProductSrcs(c)
}
if c.NeedsVendorPublicLibraryVariants() &&

View file

@ -149,7 +149,7 @@ type StaticOrSharedProperties struct {
Sanitized Sanitized `android:"arch_variant"`
Cflags []string `android:"arch_variant"`
Cflags proptools.Configurable[[]string] `android:"arch_variant"`
Enabled *bool `android:"arch_variant"`
Whole_static_libs []string `android:"arch_variant"`
@ -464,9 +464,9 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla
}
if library.static() {
flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags...)
flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags.GetOrDefault(ctx, nil)...)
} else if library.shared() {
flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags...)
flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags.GetOrDefault(ctx, nil)...)
}
if library.shared() {
@ -2066,8 +2066,8 @@ func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Mod
// Check libraries in addition to cflags, since libraries may be exporting different
// include directories.
if len(staticCompiler.StaticProperties.Static.Cflags) == 0 &&
len(sharedCompiler.SharedProperties.Shared.Cflags) == 0 &&
if len(staticCompiler.StaticProperties.Static.Cflags.GetOrDefault(mctx, nil)) == 0 &&
len(sharedCompiler.SharedProperties.Shared.Cflags.GetOrDefault(mctx, nil)) == 0 &&
len(staticCompiler.StaticProperties.Static.Whole_static_libs) == 0 &&
len(sharedCompiler.SharedProperties.Shared.Whole_static_libs) == 0 &&
len(staticCompiler.StaticProperties.Static.Static_libs) == 0 &&

View file

@ -511,5 +511,5 @@ func (v *CcApiVariant) ExtraImageVariations(ctx android.BaseModuleContext) []str
return variations
}
func (v *CcApiVariant) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (v *CcApiVariant) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}

View file

@ -88,7 +88,7 @@ func main() {
return
}
// Write the makefile where release_config.mk is going to look for it.
err = configs.WriteMakefile(makefilePath, targetRelease)
err = config.WriteMakefile(makefilePath, targetRelease, configs)
if err != nil {
panic(err)
}
@ -97,7 +97,7 @@ func main() {
for _, c := range configs.GetSortedReleaseConfigs() {
if c.Name != targetRelease {
makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, c.Name))
err = configs.WriteMakefile(makefilePath, c.Name)
err = config.WriteMakefile(makefilePath, c.Name, configs)
if err != nil {
panic(err)
}

View file

@ -24,6 +24,7 @@ bootstrap_go_package {
"golang-protobuf-reflect-protoreflect",
"golang-protobuf-runtime-protoimpl",
"soong-cmd-release_config-proto",
"blueprint-pathtools",
],
srcs: [
"flag_artifact.go",

View file

@ -82,6 +82,15 @@ func FlagArtifactsFactory(artifactsPath string) *FlagArtifacts {
return &ret
}
func (fas *FlagArtifacts) SortedFlagNames() []string {
var names []string
for k, _ := range *fas {
names = append(names, k)
}
slices.Sort(names)
return names
}
func (fa *FlagArtifact) GenerateFlagDeclarationArtifact() *rc_proto.FlagDeclarationArtifact {
ret := &rc_proto.FlagDeclarationArtifact{
Name: fa.FlagDeclaration.Name,
@ -135,9 +144,11 @@ func (src *FlagArtifact) Clone() *FlagArtifact {
value := &rc_proto.Value{}
proto.Merge(value, src.Value)
return &FlagArtifact{
FlagDeclaration: src.FlagDeclaration,
Traces: src.Traces,
Value: value,
FlagDeclaration: src.FlagDeclaration,
Traces: src.Traces,
Value: value,
DeclarationIndex: src.DeclarationIndex,
Redacted: src.Redacted,
}
}

View file

@ -17,6 +17,7 @@ package release_config_lib
import (
"cmp"
"fmt"
"os"
"path/filepath"
"regexp"
"slices"
@ -169,8 +170,12 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro
if err != nil {
return err
}
iConfig.GenerateReleaseConfig(configs)
if err := config.InheritConfig(iConfig); err != nil {
err = iConfig.GenerateReleaseConfig(configs)
if err != nil {
return err
}
err = config.InheritConfig(iConfig)
if err != nil {
return err
}
}
@ -310,6 +315,74 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro
return nil
}
// Write the makefile for this targetRelease.
func (config *ReleaseConfig) WriteMakefile(outFile, targetRelease string, configs *ReleaseConfigs) error {
makeVars := make(map[string]string)
myFlagArtifacts := config.FlagArtifacts.Clone()
// Sort the flags by name first.
names := myFlagArtifacts.SortedFlagNames()
partitions := make(map[string][]string)
vNames := []string{}
addVar := func(name, suffix, value string) {
fullName := fmt.Sprintf("_ALL_RELEASE_FLAGS.%s.%s", name, suffix)
vNames = append(vNames, fullName)
makeVars[fullName] = value
}
for _, name := range names {
flag := myFlagArtifacts[name]
decl := flag.FlagDeclaration
for _, container := range decl.Containers {
partitions[container] = append(partitions[container], name)
}
value := MarshalValue(flag.Value)
makeVars[name] = value
addVar(name, "TYPE", ValueType(flag.Value))
addVar(name, "PARTITIONS", strings.Join(decl.Containers, " "))
addVar(name, "DEFAULT", MarshalValue(decl.Value))
addVar(name, "VALUE", value)
addVar(name, "DECLARED_IN", *flag.Traces[0].Source)
addVar(name, "SET_IN", *flag.Traces[len(flag.Traces)-1].Source)
addVar(name, "NAMESPACE", *decl.Namespace)
}
pNames := []string{}
for k := range partitions {
pNames = append(pNames, k)
}
slices.Sort(pNames)
// Now sort the make variables, and output them.
slices.Sort(vNames)
// Write the flags as:
// _ALL_RELELASE_FLAGS
// _ALL_RELEASE_FLAGS.PARTITIONS.*
// all _ALL_RELEASE_FLAGS.*, sorted by name
// Final flag values, sorted by name.
data := fmt.Sprintf("# TARGET_RELEASE=%s\n", config.Name)
if targetRelease != config.Name {
data += fmt.Sprintf("# User specified TARGET_RELEASE=%s\n", targetRelease)
}
// As it stands this list is not per-product, but conceptually it is, and will be.
data += fmt.Sprintf("ALL_RELEASE_CONFIGS_FOR_PRODUCT :=$= %s\n", strings.Join(configs.GetAllReleaseNames(), " "))
data += fmt.Sprintf("_used_files := %s\n", strings.Join(config.GetSortedFileList(), " "))
data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " "))
for _, pName := range pNames {
data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " "))
}
for _, vName := range vNames {
data += fmt.Sprintf("%s :=$= %s\n", vName, makeVars[vName])
}
data += "\n\n# Values for all build flags\n"
for _, name := range names {
data += fmt.Sprintf("%s :=$= %s\n", name, makeVars[name])
}
return os.WriteFile(outFile, []byte(data), 0644)
}
func (config *ReleaseConfig) WritePartitionBuildFlags(outDir string) error {
var err error
for partition, flags := range config.PartitionBuildFlags {

View file

@ -395,94 +395,10 @@ func (configs *ReleaseConfigs) GetAllReleaseNames() []string {
allReleaseNames = append(allReleaseNames, v.Name)
allReleaseNames = append(allReleaseNames, v.OtherNames...)
}
slices.SortFunc(allReleaseNames, func(a, b string) int {
return cmp.Compare(a, b)
})
slices.Sort(allReleaseNames)
return allReleaseNames
}
// Write the makefile for this targetRelease.
func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) error {
makeVars := make(map[string]string)
config, err := configs.GetReleaseConfig(targetRelease)
if err != nil {
return err
}
myFlagArtifacts := config.FlagArtifacts.Clone()
// Sort the flags by name first.
names := []string{}
for k, _ := range myFlagArtifacts {
names = append(names, k)
}
slices.SortFunc(names, func(a, b string) int {
return cmp.Compare(a, b)
})
partitions := make(map[string][]string)
vNames := []string{}
addVar := func(name, suffix, value string) {
fullName := fmt.Sprintf("_ALL_RELEASE_FLAGS.%s.%s", name, suffix)
vNames = append(vNames, fullName)
makeVars[fullName] = value
}
for _, name := range names {
flag := myFlagArtifacts[name]
decl := flag.FlagDeclaration
for _, container := range decl.Containers {
partitions[container] = append(partitions[container], name)
}
value := MarshalValue(flag.Value)
makeVars[name] = value
addVar(name, "TYPE", ValueType(flag.Value))
addVar(name, "PARTITIONS", strings.Join(decl.Containers, " "))
addVar(name, "DEFAULT", MarshalValue(decl.Value))
addVar(name, "VALUE", value)
addVar(name, "DECLARED_IN", *flag.Traces[0].Source)
addVar(name, "SET_IN", *flag.Traces[len(flag.Traces)-1].Source)
addVar(name, "NAMESPACE", *decl.Namespace)
}
pNames := []string{}
for k := range partitions {
pNames = append(pNames, k)
}
slices.SortFunc(pNames, func(a, b string) int {
return cmp.Compare(a, b)
})
// Now sort the make variables, and output them.
slices.SortFunc(vNames, func(a, b string) int {
return cmp.Compare(a, b)
})
// Write the flags as:
// _ALL_RELELASE_FLAGS
// _ALL_RELEASE_FLAGS.PARTITIONS.*
// all _ALL_RELEASE_FLAGS.*, sorted by name
// Final flag values, sorted by name.
data := fmt.Sprintf("# TARGET_RELEASE=%s\n", config.Name)
if targetRelease != config.Name {
data += fmt.Sprintf("# User specified TARGET_RELEASE=%s\n", targetRelease)
}
// As it stands this list is not per-product, but conceptually it is, and will be.
data += fmt.Sprintf("ALL_RELEASE_CONFIGS_FOR_PRODUCT :=$= %s\n", strings.Join(configs.GetAllReleaseNames(), " "))
data += fmt.Sprintf("_used_files := %s\n", strings.Join(config.GetSortedFileList(), " "))
data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " "))
for _, pName := range pNames {
data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " "))
}
for _, vName := range vNames {
data += fmt.Sprintf("%s :=$= %s\n", vName, makeVars[vName])
}
data += "\n\n# Values for all build flags\n"
for _, name := range names {
data += fmt.Sprintf("%s :=$= %s\n", name, makeVars[name])
}
return os.WriteFile(outFile, []byte(data), 0644)
}
func (configs *ReleaseConfigs) GenerateReleaseConfigs(targetRelease string) error {
otherNames := make(map[string][]string)
for aliasName, aliasTarget := range configs.Aliases {

View file

@ -25,6 +25,7 @@ import (
"slices"
"strings"
"github.com/google/blueprint/pathtools"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
)
@ -101,7 +102,7 @@ func WriteFormattedMessage(path, format string, message proto.Message) (err erro
if err != nil {
return err
}
return os.WriteFile(path, data, 0644)
return pathtools.WriteFileIfChanged(path, data, 0644)
}
// Read a message from a file.

View file

@ -241,7 +241,7 @@ func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []stri
return nil
}
func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}
func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
@ -268,17 +268,6 @@ func (p *PrebuiltEtc) OutputFile() android.OutputPath {
return p.outputFilePaths[0]
}
var _ android.OutputFileProducer = (*PrebuiltEtc)(nil)
func (p *PrebuiltEtc) OutputFiles(tag string) (android.Paths, error) {
switch tag {
case "":
return p.outputFilePaths.Paths(), nil
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}
}
func (p *PrebuiltEtc) SubDir() string {
if subDir := proptools.String(p.subdirProperties.Sub_dir); subDir != "" {
return subDir
@ -420,6 +409,8 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
for _, ip := range installs {
ip.addInstallRules(ctx)
}
ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
}
type installProperties struct {

View file

@ -650,7 +650,7 @@ func (x noopImageInterface) VendorRamdiskVariantNeeded(android.BaseModuleContext
func (x noopImageInterface) DebugRamdiskVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) RecoveryVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) ExtraImageVariations(ctx android.BaseModuleContext) []string { return nil }
func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string) {
}
func NewGenSrcs() *Module {

View file

@ -2544,7 +2544,7 @@ func collectDirectDepsProviders(ctx android.ModuleContext) (result *JarJarProvid
case Implementation:
return RenameUseInclude, "info"
default:
//fmt.Printf("LJ: %v -> %v StubsLinkType unknown\n", module, m)
//fmt.Printf("collectDirectDepsProviders: %v -> %v StubsLinkType unknown\n", module, m)
// Fall through to the heuristic logic.
}
switch reflect.TypeOf(m).String() {

View file

@ -96,6 +96,10 @@ func (install dexpreopterInstall) ToMakeEntries() android.AndroidMkEntries {
}
}
func (install dexpreopterInstall) PackageFile(ctx android.ModuleContext) android.PackagingSpec {
return ctx.PackageFile(install.installDirOnDevice, install.installFileOnDevice, install.outputPathOnHost)
}
type Dexpreopter struct {
dexpreopter
}
@ -541,10 +545,18 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
// Use the path of the dex file to determine the library name
isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(dexJarStem)
partition := d.installPath.Partition()
dexpreoptPartition := d.installPath.Partition()
// dexpreoptPartition is set to empty for dexpreopts of system APEX and system_other.
// In case of system APEX, however, we can set it to "system" manually.
// TODO(b/346662300): Let dexpreopter generate the installPath for dexpreopt files instead of
// using the dex location to generate the installPath.
if isApexSystemServerJar {
dexpreoptPartition = "system"
}
for _, install := range dexpreoptRule.Installs() {
// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
partition := dexpreoptPartition
if strings.HasPrefix(installDir, partition+"/") {
installDir = strings.TrimPrefix(installDir, partition+"/")
} else {

View file

@ -236,7 +236,8 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
esc := proptools.NinjaAndShellEscapeList
// Filter out invalid cflags
for _, flag := range b.ClangProperties.Cflags {
cflagsProp := b.ClangProperties.Cflags.GetOrDefault(ctx, nil)
for _, flag := range cflagsProp {
if flag == "-x c++" || flag == "-xc++" {
ctx.PropertyErrorf("cflags",
"-x c++ should not be specified in cflags; setting cpp_std specifies this is a C++ header, or change the file extension to '.hpp' or '.hh'")
@ -248,7 +249,7 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
}
// Module defined clang flags and include paths
cflags = append(cflags, esc(b.ClangProperties.Cflags)...)
cflags = append(cflags, esc(cflagsProp)...)
for _, include := range b.ClangProperties.Local_include_dirs {
cflags = append(cflags, "-I"+android.PathForModuleSrc(ctx, include).String())
implicits = append(implicits, android.PathForModuleSrc(ctx, include))

View file

@ -197,21 +197,20 @@ func (mod *Module) InVendorOrProduct() bool {
return mod.InVendor() || mod.InProduct()
}
func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module)
func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string) {
if variant == android.VendorRamdiskVariation {
m.MakeAsPlatform()
mod.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
mod.MakeAsPlatform()
} else if strings.HasPrefix(variant, cc.VendorVariation) {
m.Properties.ImageVariation = cc.VendorVariation
mod.Properties.ImageVariation = cc.VendorVariation
if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
}
} else if strings.HasPrefix(variant, cc.ProductVariation) {
m.Properties.ImageVariation = cc.ProductVariation
mod.Properties.ImageVariation = cc.ProductVariation
if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
mod.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
}
}
}

View file

@ -99,6 +99,12 @@ type shBinaryProperties struct {
// Make this module available when building for recovery.
Recovery_available *bool
// The name of the image this module is built for
ImageVariation string `blueprint:"mutated"`
// Suffix for the name of Android.mk entries generated by this module
SubName string `blueprint:"mutated"`
}
type TestProperties struct {
@ -207,15 +213,15 @@ var _ android.ImageInterface = (*ShBinary)(nil)
func (s *ShBinary) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (s *ShBinary) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return !s.ModuleBase.InstallInRecovery() && !s.ModuleBase.InstallInRamdisk()
return !s.InstallInRecovery() && !s.InstallInRamdisk() && !s.InstallInVendorRamdisk() && !s.ModuleBase.InstallInVendor()
}
func (s *ShBinary) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(s.properties.Ramdisk_available) || s.ModuleBase.InstallInRamdisk()
return proptools.Bool(s.properties.Ramdisk_available) || s.InstallInRamdisk()
}
func (s *ShBinary) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(s.properties.Vendor_ramdisk_available) || s.ModuleBase.InstallInVendorRamdisk()
return proptools.Bool(s.properties.Vendor_ramdisk_available) || s.InstallInVendorRamdisk()
}
func (s *ShBinary) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
@ -223,14 +229,43 @@ func (s *ShBinary) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool
}
func (s *ShBinary) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(s.properties.Recovery_available) || s.ModuleBase.InstallInRecovery()
return proptools.Bool(s.properties.Recovery_available) || s.InstallInRecovery()
}
func (s *ShBinary) ExtraImageVariations(ctx android.BaseModuleContext) []string {
return nil
extraVariations := []string{}
if s.InstallInProduct() {
extraVariations = append(extraVariations, cc.ProductVariation)
}
if s.InstallInVendor() {
extraVariations = append(extraVariations, cc.VendorVariation)
}
return extraVariations
}
func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string) {
s.properties.ImageVariation = variation
}
// Overrides ModuleBase.InstallInRamdisk() so that the install rule respects
// Ramdisk_available property for ramdisk variant
func (s *ShBinary) InstallInRamdisk() bool {
return s.ModuleBase.InstallInRamdisk() ||
(proptools.Bool(s.properties.Ramdisk_available) && s.properties.ImageVariation == android.RamdiskVariation)
}
// Overrides ModuleBase.InstallInVendorRamdisk() so that the install rule respects
// Vendor_ramdisk_available property for vendor ramdisk variant
func (s *ShBinary) InstallInVendorRamdisk() bool {
return s.ModuleBase.InstallInVendorRamdisk() ||
(proptools.Bool(s.properties.Vendor_ramdisk_available) && s.properties.ImageVariation == android.VendorRamdiskVariation)
}
// Overrides ModuleBase.InstallInRecovery() so that the install rule respects
// Recovery_available property for recovery variant
func (s *ShBinary) InstallInRecovery() bool {
return s.ModuleBase.InstallInRecovery() ||
(proptools.Bool(s.properties.Recovery_available) && s.properties.ImageVariation == android.RecoveryVariation)
}
func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) {
@ -260,11 +295,24 @@ func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) {
Output: s.outputFilePath,
Input: s.sourceFilePath,
})
s.properties.SubName = s.GetSubname(ctx)
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: []string{s.sourceFilePath.String()}})
ctx.SetOutputFiles(android.Paths{s.outputFilePath}, "")
}
func (s *ShBinary) GetSubname(ctx android.ModuleContext) string {
ret := ""
if s.properties.ImageVariation != "" {
if s.properties.ImageVariation != cc.VendorVariation {
ret = "." + s.properties.ImageVariation
}
}
return ret
}
func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
s.generateAndroidBuildActions(ctx)
installDir := android.PathForModuleInstall(ctx, "bin", proptools.String(s.properties.Sub_dir))
@ -278,7 +326,7 @@ func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
func (s *ShBinary) AndroidMkEntries() []android.AndroidMkEntries {
return []android.AndroidMkEntries{android.AndroidMkEntries{
return []android.AndroidMkEntries{{
Class: "EXECUTABLES",
OutputFile: android.OptionalPathForPath(s.outputFilePath),
Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
@ -289,6 +337,7 @@ func (s *ShBinary) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !s.Installable())
},
},
SubName: s.properties.SubName,
}}
}

View file

@ -49,8 +49,6 @@ type syspropJavaGenRule struct {
android.ModuleBase
properties syspropGenProperties
genSrcjars android.Paths
}
type syspropRustGenRule struct {
@ -59,7 +57,6 @@ type syspropRustGenRule struct {
properties rustLibraryProperties
}
var _ android.OutputFileProducer = (*syspropJavaGenRule)(nil)
var _ rust.SourceProvider = (*syspropRustGenRule)(nil)
var (
@ -100,6 +97,7 @@ func (g *syspropJavaGenRule) GenerateAndroidBuildActions(ctx android.ModuleConte
}
})
var genSrcjars android.Paths
for _, syspropFile := range android.PathsForModuleSrc(ctx, g.properties.Srcs) {
srcJarFile := android.GenPathWithExt(ctx, "sysprop", syspropFile, "srcjar")
@ -114,8 +112,10 @@ func (g *syspropJavaGenRule) GenerateAndroidBuildActions(ctx android.ModuleConte
},
})
g.genSrcjars = append(g.genSrcjars, srcJarFile)
genSrcjars = append(genSrcjars, srcJarFile)
}
ctx.SetOutputFiles(genSrcjars, "")
}
func (g *syspropJavaGenRule) DepsMutator(ctx android.BottomUpMutatorContext) {
@ -124,15 +124,6 @@ func (g *syspropJavaGenRule) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddFarVariationDependencies(nil, nil, proptools.String(g.properties.Check_api))
}
func (g *syspropJavaGenRule) OutputFiles(tag string) (android.Paths, error) {
switch tag {
case "":
return g.genSrcjars, nil
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}
}
func syspropJavaGenFactory() android.Module {
g := &syspropJavaGenRule{}
g.AddProperties(&g.properties)

View file

@ -19,10 +19,13 @@ import (
)
var androidmk_denylist []string = []string{
"bionic/",
"chained_build_config/",
"cts/",
"dalvik/",
"developers/",
"development/",
"device/sample/",
"frameworks/",
// Do not block other directories in kernel/, see b/319658303.
"kernel/configs/",
@ -31,6 +34,10 @@ var androidmk_denylist []string = []string{
"libcore/",
"libnativehelper/",
"pdk/",
"prebuilts/",
"sdk/",
"test/",
"trusty/",
// Add back toolchain/ once defensive Android.mk files are removed
//"toolchain/",
}