diff options
| -rw-r--r-- | android/apex.go | 7 | ||||
| -rw-r--r-- | android/build_prop.go | 2 | ||||
| -rw-r--r-- | android/config.go | 4 | ||||
| -rw-r--r-- | android/container.go | 4 | ||||
| -rw-r--r-- | android/container_violations.go | 4 | ||||
| -rw-r--r-- | android/module.go | 50 | ||||
| -rw-r--r-- | android/neverallow.go | 53 | ||||
| -rw-r--r-- | android/variable.go | 1 | ||||
| -rw-r--r-- | apex/apex.go | 2 | ||||
| -rw-r--r-- | apex/dexpreopt_bootjars_test.go | 103 | ||||
| -rw-r--r-- | cc/cc.go | 2 | ||||
| -rw-r--r-- | filesystem/logical_partition.go | 14 | ||||
| -rw-r--r-- | genrule/allowlists.go | 1 | ||||
| -rw-r--r-- | genrule/genrule.go | 32 | ||||
| -rw-r--r-- | java/aar.go | 10 | ||||
| -rw-r--r-- | java/app.go | 6 | ||||
| -rw-r--r-- | java/base.go | 2 | ||||
| -rw-r--r-- | java/bootclasspath_fragment.go | 2 | ||||
| -rw-r--r-- | java/device_host_converter.go | 2 | ||||
| -rw-r--r-- | java/dexpreopt_bootjars.go | 4 | ||||
| -rw-r--r-- | java/droidstubs.go | 5 | ||||
| -rw-r--r-- | java/java.go | 8 | ||||
| -rw-r--r-- | java/jdeps.go | 14 | ||||
| -rw-r--r-- | java/jdeps_test.go | 48 | ||||
| -rw-r--r-- | java/sdk_library.go | 4 | ||||
| -rw-r--r-- | java/system_modules.go | 2 | ||||
| -rw-r--r-- | java/systemserver_classpath_fragment.go | 2 | ||||
| -rw-r--r-- | linkerconfig/linkerconfig.go | 1 |
28 files changed, 284 insertions, 105 deletions
diff --git a/android/apex.go b/android/apex.go index 028be57ec..79ee0a8f8 100644 --- a/android/apex.go +++ b/android/apex.go @@ -475,13 +475,6 @@ const ( AvailableToAnyApex = "//apex_available:anyapex" ) -var ( - AvailableToRecognziedWildcards = []string{ - AvailableToPlatform, - AvailableToAnyApex, - } -) - // CheckAvailableForApex provides the default algorithm for checking the apex availability. When the // availability is empty, it defaults to ["//apex_available:platform"] which means "available to the // platform but not available to any APEX". When the list is not empty, `what` is matched against diff --git a/android/build_prop.go b/android/build_prop.go index 13d59f9f5..ede93ed20 100644 --- a/android/build_prop.go +++ b/android/build_prop.go @@ -63,6 +63,8 @@ func (p *buildPropModule) propFiles(ctx ModuleContext) Paths { return ctx.Config().SystemExtPropFiles(ctx) } else if partition == "product" { return ctx.Config().ProductPropFiles(ctx) + } else if partition == "odm" { + return ctx.Config().OdmPropFiles(ctx) } return nil } diff --git a/android/config.go b/android/config.go index 2f6ade794..bbb08dde7 100644 --- a/android/config.go +++ b/android/config.go @@ -2057,6 +2057,10 @@ func (c *config) ProductPropFiles(ctx PathContext) Paths { return PathsForSource(ctx, c.productVariables.ProductPropFiles) } +func (c *config) OdmPropFiles(ctx PathContext) Paths { + return PathsForSource(ctx, c.productVariables.OdmPropFiles) +} + func (c *config) EnableUffdGc() string { return String(c.productVariables.EnableUffdGc) } diff --git a/android/container.go b/android/container.go index f01c07606..f150ff31a 100644 --- a/android/container.go +++ b/android/container.go @@ -93,6 +93,10 @@ var globallyAllowlistedDependencies = []string{ // This module is implicitly added as a dependency for java modules even when the // dependency specifies sdk_version. "framework-res", + + // jacocoagent is implicitly added as a dependency in coverage builds, and is not installed + // on the device. + "jacocoagent", } // Returns true when the dependency is globally allowlisted for inter-container dependency diff --git a/android/container_violations.go b/android/container_violations.go index 14cd61b1f..e67533dbe 100644 --- a/android/container_violations.go +++ b/android/container_violations.go @@ -870,6 +870,10 @@ var ContainerDependencyViolationAllowlist = map[string][]string{ "net-utils-device-common-struct-base", // apex [com.android.tethering] -> system }, + "NfcNciApex": { + "android.permission.flags-aconfig-java", // apex [com.android.nfcservices] -> apex [com.android.permission, test_com.android.permission] + }, + "okhttp-norepackage": { "okhttp-android-util-log", // apex [com.android.adservices, com.android.devicelock, com.android.extservices] -> system }, diff --git a/android/module.go b/android/module.go index 35513d69d..9f73729fb 100644 --- a/android/module.go +++ b/android/module.go @@ -111,10 +111,6 @@ type Module interface { TargetRequiredModuleNames() []string VintfFragmentModuleNames(ctx ConfigAndErrorContext) []string - // TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive - // dependencies with dependency tags for which IsInstallDepNeeded() returns true. - TransitivePackagingSpecs() []PackagingSpec - ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools.ConfigurableEvaluator } @@ -830,8 +826,7 @@ type ModuleBase struct { // The primary licenses property, may be nil, records license metadata for the module. primaryLicensesProperty applicableLicensesProperty - noAddressSanitizer bool - packagingSpecsDepSet *DepSet[PackagingSpec] + noAddressSanitizer bool hooks hooks @@ -1437,10 +1432,6 @@ func isInstallDepNeeded(dep Module, tag blueprint.DependencyTag) bool { return IsInstallDepNeededTag(tag) } -func (m *ModuleBase) TransitivePackagingSpecs() []PackagingSpec { - return m.packagingSpecsDepSet.ToList() -} - func (m *ModuleBase) NoAddressSanitizer() bool { return m.noAddressSanitizer } @@ -1929,6 +1920,13 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) if ctx.Failed() { return } + + if x, ok := m.module.(IDEInfo); ok { + var result IdeInfo + x.IDEInfo(ctx, &result) + result.BaseModuleName = x.BaseModuleName() + SetProvider(ctx, IdeInfoProviderKey, result) + } } if incrementalEnabled && cacheKey != nil { @@ -1968,8 +1966,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) ctx.TransitiveInstallFiles = NewDepSet[InstallPath](TOPOLOGICAL, ctx.installFiles, dependencyInstallFiles) installFiles.TransitiveInstallFiles = ctx.TransitiveInstallFiles - m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, ctx.packagingSpecs, dependencyPackagingSpecs) - installFiles.TransitivePackagingSpecs = m.packagingSpecsDepSet + installFiles.TransitivePackagingSpecs = NewDepSet[PackagingSpec](TOPOLOGICAL, ctx.packagingSpecs, dependencyPackagingSpecs) SetProvider(ctx, InstallFilesProvider, installFiles) buildLicenseMetadata(ctx, ctx.licenseMetadataFile) @@ -2710,7 +2707,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) { // Collect information for opening IDE project files in java/jdeps.go. type IDEInfo interface { - IDEInfo(ideInfo *IdeInfo) + IDEInfo(ctx BaseModuleContext, ideInfo *IdeInfo) BaseModuleName() string } @@ -2722,7 +2719,9 @@ type IDECustomizedModuleName interface { IDECustomizedModuleName() string } +// Collect information for opening IDE project files in java/jdeps.go. type IdeInfo struct { + BaseModuleName string `json:"-"` Deps []string `json:"dependencies,omitempty"` Srcs []string `json:"srcs,omitempty"` Aidl_include_dirs []string `json:"aidl_include_dirs,omitempty"` @@ -2736,6 +2735,31 @@ type IdeInfo struct { Libs []string `json:"libs,omitempty"` } +// Merge merges two IdeInfos and produces a new one, leaving the origional unchanged +func (i IdeInfo) Merge(other IdeInfo) IdeInfo { + return IdeInfo{ + Deps: mergeStringLists(i.Deps, other.Deps), + Srcs: mergeStringLists(i.Srcs, other.Srcs), + Aidl_include_dirs: mergeStringLists(i.Aidl_include_dirs, other.Aidl_include_dirs), + Jarjar_rules: mergeStringLists(i.Jarjar_rules, other.Jarjar_rules), + Jars: mergeStringLists(i.Jars, other.Jars), + Classes: mergeStringLists(i.Classes, other.Classes), + Installed_paths: mergeStringLists(i.Installed_paths, other.Installed_paths), + SrcJars: mergeStringLists(i.SrcJars, other.SrcJars), + Paths: mergeStringLists(i.Paths, other.Paths), + Static_libs: mergeStringLists(i.Static_libs, other.Static_libs), + Libs: mergeStringLists(i.Libs, other.Libs), + } +} + +// mergeStringLists appends the two string lists together and returns a new string list, +// leaving the originals unchanged. Duplicate strings will be deduplicated. +func mergeStringLists(a, b []string) []string { + return FirstUniqueStrings(Concat(a, b)) +} + +var IdeInfoProviderKey = blueprint.NewProvider[IdeInfo]() + func CheckBlueprintSyntax(ctx BaseModuleContext, filename string, contents string) []error { bpctx := ctx.blueprintBaseModuleContext() return blueprint.CheckBlueprintSyntax(bpctx.ModuleFactories(), filename, contents) diff --git a/android/neverallow.go b/android/neverallow.go index 0f363e78f..a68f5ea79 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -287,7 +287,7 @@ func neverallowMutator(ctx BottomUpMutatorContext) { continue } - if !n.appliesToProperties(properties) { + if !n.appliesToProperties(ctx, properties) { continue } @@ -604,9 +604,9 @@ func (r *rule) appliesToModuleType(moduleType string) bool { return (len(r.moduleTypes) == 0 || InList(moduleType, r.moduleTypes)) && !InList(moduleType, r.unlessModuleTypes) } -func (r *rule) appliesToProperties(properties []interface{}) bool { - includeProps := hasAllProperties(properties, r.props) - excludeProps := hasAnyProperty(properties, r.unlessProps) +func (r *rule) appliesToProperties(ctx BottomUpMutatorContext, properties []interface{}) bool { + includeProps := hasAllProperties(ctx, properties, r.props) + excludeProps := hasAnyProperty(ctx, properties, r.unlessProps) return includeProps && !excludeProps } @@ -644,25 +644,25 @@ func fieldNamesForProperties(propertyNames string) []string { return names } -func hasAnyProperty(properties []interface{}, props []ruleProperty) bool { +func hasAnyProperty(ctx BottomUpMutatorContext, properties []interface{}, props []ruleProperty) bool { for _, v := range props { - if hasProperty(properties, v) { + if hasProperty(ctx, properties, v) { return true } } return false } -func hasAllProperties(properties []interface{}, props []ruleProperty) bool { +func hasAllProperties(ctx BottomUpMutatorContext, properties []interface{}, props []ruleProperty) bool { for _, v := range props { - if !hasProperty(properties, v) { + if !hasProperty(ctx, properties, v) { return false } } return true } -func hasProperty(properties []interface{}, prop ruleProperty) bool { +func hasProperty(ctx BottomUpMutatorContext, properties []interface{}, prop ruleProperty) bool { for _, propertyStruct := range properties { propertiesValue := reflect.ValueOf(propertyStruct).Elem() for _, v := range prop.fields { @@ -679,14 +679,14 @@ func hasProperty(properties []interface{}, prop ruleProperty) bool { return prop.matcher.Test(value) } - if matchValue(propertiesValue, check) { + if matchValue(ctx, propertiesValue, check) { return true } } return false } -func matchValue(value reflect.Value, check func(string) bool) bool { +func matchValue(ctx BottomUpMutatorContext, value reflect.Value, check func(string) bool) bool { if !value.IsValid() { return false } @@ -698,19 +698,26 @@ func matchValue(value reflect.Value, check func(string) bool) bool { value = value.Elem() } - switch value.Kind() { - case reflect.String: - return check(value.String()) - case reflect.Bool: - return check(strconv.FormatBool(value.Bool())) - case reflect.Int: - return check(strconv.FormatInt(value.Int(), 10)) - case reflect.Slice: - slice, ok := value.Interface().([]string) - if !ok { - panic("Can only handle slice of string") + switch v := value.Interface().(type) { + case string: + return check(v) + case bool: + return check(strconv.FormatBool(v)) + case int: + return check(strconv.FormatInt((int64)(v), 10)) + case []string: + for _, v := range v { + if check(v) { + return true + } } - for _, v := range slice { + return false + case proptools.Configurable[string]: + return check(v.GetOrDefault(ctx, "")) + case proptools.Configurable[bool]: + return check(strconv.FormatBool(v.GetOrDefault(ctx, false))) + case proptools.Configurable[[]string]: + for _, v := range v.GetOrDefault(ctx, nil) { if check(v) { return true } diff --git a/android/variable.go b/android/variable.go index 10205e388..14f1756bf 100644 --- a/android/variable.go +++ b/android/variable.go @@ -512,6 +512,7 @@ type ProductVariables struct { SystemPropFiles []string `json:",omitempty"` SystemExtPropFiles []string `json:",omitempty"` ProductPropFiles []string `json:",omitempty"` + OdmPropFiles []string `json:",omitempty"` EnableUffdGc *string `json:",omitempty"` } diff --git a/apex/apex.go b/apex/apex.go index 2feaaeee1..d5776b5de 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2873,7 +2873,7 @@ func isStaticExecutableAllowed(apex string, exec string) bool { } // Collect information for opening IDE project files in java/jdeps.go. -func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) { +func (a *apexBundle) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...) dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...) dpInfo.Deps = append(dpInfo.Deps, a.properties.ResolvedSystemserverclasspathFragments...) diff --git a/apex/dexpreopt_bootjars_test.go b/apex/dexpreopt_bootjars_test.go index 95db37d0a..d8ee4ba6c 100644 --- a/apex/dexpreopt_bootjars_test.go +++ b/apex/dexpreopt_bootjars_test.go @@ -409,3 +409,106 @@ func TestDexpreoptProfileWithMultiplePrebuiltArtApexes(t *testing.T) { android.AssertStringListContains(t, tc.desc, inputs, tc.expectedProfile) } } + +// Check that dexpreopt works with Google mainline prebuilts even in workspaces where source is missing +func TestDexpreoptWithMainlinePrebuiltNoSource(t *testing.T) { + bp := ` + // Platform. + + platform_bootclasspath { + name: "platform-bootclasspath", + fragments: [ + { + apex: "com.android.art", + module: "art-bootclasspath-fragment", + }, + ], + } + + // Source AOSP ART apex + java_library { + name: "core-oj", + srcs: ["core-oj.java"], + installable: true, + apex_available: [ + "com.android.art", + ], + } + + bootclasspath_fragment { + name: "art-bootclasspath-fragment", + image_name: "art", + contents: ["core-oj"], + apex_available: [ + "com.android.art", + ], + hidden_api: { + split_packages: ["*"], + }, + } + + apex_key { + name: "com.android.art.key", + public_key: "com.android.art.avbpubkey", + private_key: "com.android.art.pem", + } + + apex { + name: "com.android.art", + key: "com.android.art.key", + bootclasspath_fragments: ["art-bootclasspath-fragment"], + updatable: false, + } + + + // Prebuilt Google ART APEX. + + java_import { + name: "core-oj", + jars: ["core-oj.jar"], + apex_available: [ + "com.android.art", + ], + } + + prebuilt_bootclasspath_fragment { + name: "art-bootclasspath-fragment", + image_name: "art", + contents: ["core-oj"], + hidden_api: { + annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv", + metadata: "my-bootclasspath-fragment/metadata.csv", + index: "my-bootclasspath-fragment/index.csv", + stub_flags: "my-bootclasspath-fragment/stub-flags.csv", + all_flags: "my-bootclasspath-fragment/all-flags.csv", + }, + apex_available: [ + "com.android.art", + ], + } + + prebuilt_apex { + name: "com.google.android.art", + apex_name: "com.android.art", + src: "com.android.art-arm.apex", + exported_bootclasspath_fragments: ["art-bootclasspath-fragment"], + } + + apex_contributions { + name: "art.prebuilt.contributions", + api_domain: "com.android.art", + contents: ["prebuilt_com.google.android.art"], + } + ` + res := android.GroupFixturePreparers( + java.PrepareForTestWithDexpreopt, + java.PrepareForTestWithJavaSdkLibraryFiles, + java.FixtureConfigureBootJars("com.android.art:core-oj"), + PrepareForTestWithApexBuildComponents, + prepareForTestWithArtApex, + android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "art.prebuilt.contributions"), + ).RunTestWithBp(t, bp) + if !java.CheckModuleHasDependency(t, res.TestContext, "dex_bootjars", "android_common", "prebuilt_com.google.android.art") { + t.Errorf("Expected dexpreopt to use prebuilt apex") + } +} @@ -3042,7 +3042,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } if dep.Target().Os != ctx.Os() { - ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName) + ctx.ModuleErrorf("OS mismatch between %q (%s) and %q (%s)", ctx.ModuleName(), ctx.Os().Name, depName, dep.Target().Os.Name) return } if dep.Target().Arch.ArchType != ctx.Arch().ArchType { diff --git a/filesystem/logical_partition.go b/filesystem/logical_partition.go index e483fe472..988a57b08 100644 --- a/filesystem/logical_partition.go +++ b/filesystem/logical_partition.go @@ -146,9 +146,16 @@ func (l *logicalPartition) GenerateAndroidBuildActions(ctx android.ModuleContext partitionNames[pName] = true } // Get size of the partition by reading the -size.txt file - pSize := fmt.Sprintf("$(cat %s)", sparseImageSizes[pName]) + var pSize string + if size, hasSize := sparseImageSizes[pName]; hasSize { + pSize = fmt.Sprintf("$(cat %s)", size) + } else { + pSize = "0" + } cmd.FlagWithArg("--partition=", fmt.Sprintf("%s:readonly:%s:%s", pName, pSize, gName)) - cmd.FlagWithInput("--image="+pName+"=", sparseImages[pName]) + if image, hasImage := sparseImages[pName]; hasImage { + cmd.FlagWithInput("--image="+pName+"=", image) + } } } @@ -192,6 +199,9 @@ func (l *logicalPartition) GenerateAndroidBuildActions(ctx android.ModuleContext // Add a rule that converts the filesystem for the given partition to the given rule builder. The // path to the sparse file and the text file having the size of the partition are returned. func sparseFilesystem(ctx android.ModuleContext, p partitionProperties, builder *android.RuleBuilder) (sparseImg android.OutputPath, sizeTxt android.OutputPath) { + if p.Filesystem == nil { + return + } img := android.PathForModuleSrc(ctx, proptools.String(p.Filesystem)) name := proptools.String(p.Name) sparseImg = android.PathForModuleOut(ctx, name+".img").OutputPath diff --git a/genrule/allowlists.go b/genrule/allowlists.go index 7c71b77ef..4f1b320f8 100644 --- a/genrule/allowlists.go +++ b/genrule/allowlists.go @@ -17,7 +17,6 @@ package genrule var ( SandboxingDenyModuleList = []string{ // go/keep-sorted start - "aidl_camera_build_version", "com.google.pixel.camera.hal.manifest", // go/keep-sorted end } diff --git a/genrule/genrule.go b/genrule/genrule.go index b8b996820..fd72d3c15 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -243,13 +243,35 @@ func toolDepsMutator(ctx android.BottomUpMutatorContext) { } } +var buildNumberAllowlistKey = android.NewOnceKey("genruleBuildNumberAllowlistKey") + // This allowlist should be kept to the bare minimum, it's // intended for things that existed before the build number // was tightly controlled. Prefer using libbuildversion // via the use_version_lib property of cc modules. -var genrule_build_number_allowlist = map[string]bool{ - "build/soong/tests:gen": true, - "tools/tradefederation/core:tradefed_zip": true, +// This is a function instead of a global map so that +// soong plugins cannot add entries to the allowlist +func isModuleInBuildNumberAllowlist(ctx android.ModuleContext) bool { + allowlist := ctx.Config().Once(buildNumberAllowlistKey, func() interface{} { + // Define the allowlist as a list and then copy it into a map so that + // gofmt doesn't change unnecessary lines trying to align the values of the map. + allowlist := []string{ + // go/keep-sorted start + "build/soong/tests:gen", + "hardware/google/camera/common/hal/aidl_service:aidl_camera_build_version", + "tools/tradefederation/core:tradefed_zip", + "vendor/google/services/LyricCameraHAL/src/apex:com.google.pixel.camera.hal.manifest", + // go/keep-sorted end + } + allowlistMap := make(map[string]bool, len(allowlist)) + for _, a := range allowlist { + allowlistMap[a] = true + } + return allowlistMap + }).(map[string]bool) + + _, ok := allowlist[ctx.ModuleDir()+":"+ctx.ModuleName()] + return ok } // generateCommonBuildActions contains build action generation logic @@ -547,7 +569,7 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) { cmd.ImplicitTools(tools) cmd.ImplicitPackagedTools(packagedTools) if proptools.Bool(g.properties.Uses_order_only_build_number_file) { - if _, ok := genrule_build_number_allowlist[ctx.ModuleDir()+":"+ctx.ModuleName()]; !ok { + if !isModuleInBuildNumberAllowlist(ctx) { ctx.ModuleErrorf("Only allowlisted modules may use uses_order_only_build_number_file: true") } cmd.OrderOnly(ctx.Config().BuildNumberFile(ctx)) @@ -625,7 +647,7 @@ func (g *Module) setOutputFiles(ctx android.ModuleContext) { } // Collect information for opening IDE project files in java/jdeps.go. -func (g *Module) IDEInfo(dpInfo *android.IdeInfo) { +func (g *Module) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { dpInfo.Srcs = append(dpInfo.Srcs, g.Srcs().Strings()...) for _, src := range g.properties.ResolvedSrcs { if strings.HasPrefix(src, ":") { diff --git a/java/aar.go b/java/aar.go index e6ad5022b..1bd372f95 100644 --- a/java/aar.go +++ b/java/aar.go @@ -914,12 +914,12 @@ func (a *AndroidLibrary) setOutputFiles(ctx android.ModuleContext) { setOutputFiles(ctx, a.Library.Module) } -func (a *AndroidLibrary) IDEInfo(dpInfo *android.IdeInfo) { - a.Library.IDEInfo(dpInfo) - a.aapt.IDEInfo(dpInfo) +func (a *AndroidLibrary) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { + a.Library.IDEInfo(ctx, dpInfo) + a.aapt.IDEInfo(ctx, dpInfo) } -func (a *aapt) IDEInfo(dpInfo *android.IdeInfo) { +func (a *aapt) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { if a.rJar != nil { dpInfo.Jars = append(dpInfo.Jars, a.rJar.String()) } @@ -1451,6 +1451,6 @@ func AARImportFactory() android.Module { return module } -func (a *AARImport) IDEInfo(dpInfo *android.IdeInfo) { +func (a *AARImport) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { dpInfo.Jars = append(dpInfo.Jars, a.headerJarFile.String(), a.rJar.String()) } diff --git a/java/app.go b/java/app.go index 1ebf658a1..abd78b7ed 100644 --- a/java/app.go +++ b/java/app.go @@ -1243,9 +1243,9 @@ func (a *AndroidApp) EnableCoverageIfNeeded() {} var _ cc.Coverage = (*AndroidApp)(nil) -func (a *AndroidApp) IDEInfo(dpInfo *android.IdeInfo) { - a.Library.IDEInfo(dpInfo) - a.aapt.IDEInfo(dpInfo) +func (a *AndroidApp) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { + a.Library.IDEInfo(ctx, dpInfo) + a.aapt.IDEInfo(ctx, dpInfo) } func (a *AndroidApp) productCharacteristicsRROPackageName() string { diff --git a/java/base.go b/java/base.go index 910145785..4cd60215c 100644 --- a/java/base.go +++ b/java/base.go @@ -2049,7 +2049,7 @@ func (j *Module) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap { } // Collect information for opening IDE project files in java/jdeps.go. -func (j *Module) IDEInfo(dpInfo *android.IdeInfo) { +func (j *Module) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { // jarjar rules will repackage the sources. To prevent misleading results, IdeInfo should contain the // repackaged jar instead of the input sources. if j.expandJarjarRules != nil { diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index bce507a7d..bef3b58c8 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -836,7 +836,7 @@ func (b *BootclasspathFragmentModule) getProfilePath() android.Path { } // Collect information for opening IDE project files in java/jdeps.go. -func (b *BootclasspathFragmentModule) IDEInfo(dpInfo *android.IdeInfo) { +func (b *BootclasspathFragmentModule) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { dpInfo.Deps = append(dpInfo.Deps, b.properties.Contents...) } diff --git a/java/device_host_converter.go b/java/device_host_converter.go index 63b69d0a8..7cc06fc41 100644 --- a/java/device_host_converter.go +++ b/java/device_host_converter.go @@ -192,7 +192,7 @@ func (d *DeviceHostConverter) AndroidMk() android.AndroidMkData { // implement the following interface for IDE completion. var _ android.IDEInfo = (*DeviceHostConverter)(nil) -func (d *DeviceHostConverter) IDEInfo(ideInfo *android.IdeInfo) { +func (d *DeviceHostConverter) IDEInfo(ctx android.BaseModuleContext, ideInfo *android.IdeInfo) { ideInfo.Deps = append(ideInfo.Deps, d.properties.Libs...) ideInfo.Libs = append(ideInfo.Libs, d.properties.Libs...) } diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index a81ab8316..a2e473469 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -558,6 +558,10 @@ func addDependenciesOntoSelectedBootImageApexes(ctx android.BottomUpMutatorConte apexVariationOfSelected := append(ctx.Target().Variations(), blueprint.Variation{Mutator: "apex", Variation: apex}) if ctx.OtherModuleDependencyVariantExists(apexVariationOfSelected, selected) { ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, selected) + } else if ctx.OtherModuleDependencyVariantExists(apexVariationOfSelected, android.RemoveOptionalPrebuiltPrefix(selected)) { + // The prebuilt might have been renamed by prebuilt_rename mutator if the source module does not exist. + // Remove the prebuilt_ prefix. + ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, android.RemoveOptionalPrebuiltPrefix(selected)) } } } diff --git a/java/droidstubs.go b/java/droidstubs.go index d6229038f..137ec9254 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -970,6 +970,11 @@ func (d *Droidstubs) everythingOptionalCmd(ctx android.ModuleContext, cmd *andro d.apiLintReport = android.PathForModuleOut(ctx, Everything.String(), "api_lint_report.txt") cmd.FlagWithOutput("--report-even-if-suppressed ", d.apiLintReport) // TODO: Change to ":api-lint" + // Make sure that existing UnflaggedApi issues are reported as warnings but issues in + // new/changed code are treated as errors by the Build Warnings Aye Aye Analyzer in Gerrit. + // Once existing issues have been fixed this will be changed to error. + cmd.Flag("--error-when-new UnflaggedApi") + // TODO(b/154317059): Clean up this allowlist by baselining and/or checking in last-released. if d.Name() != "android.car-system-stubs-docs" && d.Name() != "android.car-stubs-docs" { diff --git a/java/java.go b/java/java.go index 46344c842..55c878eb3 100644 --- a/java/java.go +++ b/java/java.go @@ -2404,15 +2404,15 @@ func (al *ApiLibrary) TargetSdkVersion(ctx android.EarlyModuleContext) android.A return al.SdkVersion(ctx).ApiLevel } -func (al *ApiLibrary) IDEInfo(i *android.IdeInfo) { - i.Deps = append(i.Deps, al.ideDeps()...) +func (al *ApiLibrary) IDEInfo(ctx android.BaseModuleContext, i *android.IdeInfo) { + i.Deps = append(i.Deps, al.ideDeps(ctx)...) i.Libs = append(i.Libs, al.properties.Libs...) i.Static_libs = append(i.Static_libs, al.properties.Static_libs...) i.SrcJars = append(i.SrcJars, al.stubsSrcJar.String()) } // deps of java_api_library for module_bp_java_deps.json -func (al *ApiLibrary) ideDeps() []string { +func (al *ApiLibrary) ideDeps(ctx android.BaseModuleContext) []string { ret := []string{} ret = append(ret, al.properties.Libs...) ret = append(ret, al.properties.Static_libs...) @@ -2933,7 +2933,7 @@ var _ android.IDECustomizedModuleName = (*Import)(nil) // Collect information for opening IDE project files in java/jdeps.go. -func (j *Import) IDEInfo(dpInfo *android.IdeInfo) { +func (j *Import) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { dpInfo.Jars = append(dpInfo.Jars, j.combinedHeaderFile.String()) } diff --git a/java/jdeps.go b/java/jdeps.go index e856b37ee..c2ce50383 100644 --- a/java/jdeps.go +++ b/java/jdeps.go @@ -57,27 +57,19 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont return } - ideInfoProvider, ok := module.(android.IDEInfo) + ideInfoProvider, ok := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey) if !ok { return } - name := ideInfoProvider.BaseModuleName() + name := ideInfoProvider.BaseModuleName ideModuleNameProvider, ok := module.(android.IDECustomizedModuleName) if ok { name = ideModuleNameProvider.IDECustomizedModuleName() } dpInfo := moduleInfos[name] - ideInfoProvider.IDEInfo(&dpInfo) - dpInfo.Deps = android.FirstUniqueStrings(dpInfo.Deps) - dpInfo.Srcs = android.FirstUniqueStrings(dpInfo.Srcs) - dpInfo.Aidl_include_dirs = android.FirstUniqueStrings(dpInfo.Aidl_include_dirs) - dpInfo.Jarjar_rules = android.FirstUniqueStrings(dpInfo.Jarjar_rules) - dpInfo.Jars = android.FirstUniqueStrings(dpInfo.Jars) - dpInfo.SrcJars = android.FirstUniqueStrings(dpInfo.SrcJars) + dpInfo = dpInfo.Merge(ideInfoProvider) dpInfo.Paths = []string{ctx.ModuleDir(module)} - dpInfo.Static_libs = android.FirstUniqueStrings(dpInfo.Static_libs) - dpInfo.Libs = android.FirstUniqueStrings(dpInfo.Libs) moduleInfos[name] = dpInfo mkProvider, ok := module.(android.AndroidMkDataProvider) diff --git a/java/jdeps_test.go b/java/jdeps_test.go index ff54da92a..d282f1976 100644 --- a/java/jdeps_test.go +++ b/java/jdeps_test.go @@ -32,9 +32,7 @@ func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) { } `) module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library) - dpInfo := &android.IdeInfo{} - - module.IDEInfo(dpInfo) + dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey) for _, expected := range []string{"Foo", "Bar"} { if !android.InList(expected, dpInfo.Deps) { @@ -54,9 +52,7 @@ func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) { } `) module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library) - dpInfo := &android.IdeInfo{} - - module.IDEInfo(dpInfo) + dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey) for _, expected := range []string{"Foo", "Bar"} { if !android.InList(expected, dpInfo.Deps) { @@ -66,26 +62,36 @@ func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) { } func TestCollectJavaLibraryPropertiesAddScrs(t *testing.T) { - expected := []string{"Foo", "Bar"} - module := LibraryFactory().(*Library) - module.expandIDEInfoCompiledSrcs = append(module.expandIDEInfoCompiledSrcs, expected...) - dpInfo := &android.IdeInfo{} - - module.IDEInfo(dpInfo) + ctx, _ := testJava(t, + ` + java_library { + name: "javalib", + srcs: ["Foo.java", "Bar.java"], + } + `) + module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library) + dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey) + expected := []string{"Foo.java", "Bar.java"} if !reflect.DeepEqual(dpInfo.Srcs, expected) { t.Errorf("Library.IDEInfo() Srcs = %v, want %v", dpInfo.Srcs, expected) } } func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) { - expected := []string{"Foo", "Bar"} - module := LibraryFactory().(*Library) - module.deviceProperties.Aidl.Include_dirs = append(module.deviceProperties.Aidl.Include_dirs, expected...) - dpInfo := &android.IdeInfo{} - - module.IDEInfo(dpInfo) + ctx, _ := testJava(t, + ` + java_library { + name: "javalib", + aidl: { + include_dirs: ["Foo", "Bar"], + }, + } + `) + module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library) + dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey) + expected := []string{"Foo", "Bar"} if !reflect.DeepEqual(dpInfo.Aidl_include_dirs, expected) { t.Errorf("Library.IDEInfo() Aidl_include_dirs = %v, want %v", dpInfo.Aidl_include_dirs, expected) } @@ -101,9 +107,8 @@ func TestCollectJavaLibraryWithJarJarRules(t *testing.T) { } `) module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library) - dpInfo := &android.IdeInfo{} + dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey) - module.IDEInfo(dpInfo) android.AssertBoolEquals(t, "IdeInfo.Srcs of repackaged library should be empty", true, len(dpInfo.Srcs) == 0) android.AssertStringEquals(t, "IdeInfo.Jar_rules of repackaged library should not be empty", "jarjar_rules.txt", dpInfo.Jarjar_rules[0]) if !android.SubstringInList(dpInfo.Jars, "soong/.intermediates/javalib/android_common/jarjar/turbine/javalib.jar") { @@ -125,8 +130,7 @@ func TestCollectJavaLibraryLinkingAgainstVersionedSdk(t *testing.T) { } `) module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library) - dpInfo := &android.IdeInfo{} + dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey) - module.IDEInfo(dpInfo) android.AssertStringListContains(t, "IdeInfo.Deps should contain versioned sdk module", dpInfo.Deps, "sdk_public_29_android") } diff --git a/java/sdk_library.go b/java/sdk_library.go index 2fe629fb1..25317c50d 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -3599,8 +3599,8 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo } // TODO(b/358613520): This can be removed when modules are no longer allowed to depend on the top-level library. -func (s *SdkLibrary) IDEInfo(dpInfo *android.IdeInfo) { - s.Library.IDEInfo(dpInfo) +func (s *SdkLibrary) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { + s.Library.IDEInfo(ctx, dpInfo) if s.implLibraryModule != nil { dpInfo.Deps = append(dpInfo.Deps, s.implLibraryModule.Name()) } else { diff --git a/java/system_modules.go b/java/system_modules.go index 5b00079f7..f89bf9ea6 100644 --- a/java/system_modules.go +++ b/java/system_modules.go @@ -307,7 +307,7 @@ func (p *systemModulesInfoProperties) AddToPropertySet(ctx android.SdkMemberCont // implement the following interface for IDE completion. var _ android.IDEInfo = (*SystemModules)(nil) -func (s *SystemModules) IDEInfo(ideInfo *android.IdeInfo) { +func (s *SystemModules) IDEInfo(ctx android.BaseModuleContext, ideInfo *android.IdeInfo) { ideInfo.Deps = append(ideInfo.Deps, s.properties.Libs...) ideInfo.Libs = append(ideInfo.Libs, s.properties.Libs...) } diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index 3225a3a4d..924abd460 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -239,7 +239,7 @@ func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpM } // Collect information for opening IDE project files in java/jdeps.go. -func (s *SystemServerClasspathModule) IDEInfo(dpInfo *android.IdeInfo) { +func (s *SystemServerClasspathModule) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { dpInfo.Deps = append(dpInfo.Deps, s.properties.Contents...) dpInfo.Deps = append(dpInfo.Deps, s.properties.Standalone_contents...) } diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go index 533ec6258..05b99fd6d 100644 --- a/linkerconfig/linkerconfig.go +++ b/linkerconfig/linkerconfig.go @@ -98,6 +98,7 @@ func BuildLinkerConfig(ctx android.ModuleContext, builder *android.RuleBuilder, builder.Command(). BuiltTool("conv_linker_config"). Flag("proto"). + Flag("--force"). FlagWithInput("-s ", input). FlagWithOutput("-o ", interimOutput) |