diff options
| author | George Zacharia <george.zcharia@gmail.com> | 2023-07-02 15:03:51 +0530 |
|---|---|---|
| committer | George Zacharia <george.zcharia@gmail.com> | 2023-07-02 15:04:08 +0530 |
| commit | a13ad89d65a9983883a17271c534e1a33a22a99a (patch) | |
| tree | aefcb6703acd0387d702cd71624aada2228733b6 | |
| parent | d3488f05bf956a8fde5e788620eaa179323fd3c7 (diff) | |
| parent | cef786fa78457bc0907650cc791d8f9fd1980504 (diff) | |
Merge tag 'android-13.0.0_r52' of https://android.googlesource.com/platform/build/soong into HEAD
Android 13.0.0 Release 52 (TQ3A.230605.012)
Change-Id: Ic8795275eadc84f6c9eae9ef9455e63fc4a55853
| -rw-r--r-- | android/config.go | 4 | ||||
| -rw-r--r-- | android/register.go | 1 | ||||
| -rw-r--r-- | android/variable.go | 2 | ||||
| -rw-r--r-- | apex/apex_test.go | 24 | ||||
| -rw-r--r-- | apex/prebuilt.go | 5 | ||||
| -rw-r--r-- | cmd/extract_apks/main.go | 100 | ||||
| -rw-r--r-- | cmd/extract_apks/main_test.go | 6 | ||||
| -rw-r--r-- | cmd/soong_build/main.go | 1 | ||||
| -rw-r--r-- | java/app_set.go | 7 | ||||
| -rw-r--r-- | ui/build/config.go | 10 | ||||
| -rw-r--r-- | ui/build/dumpvars.go | 2 | ||||
| -rw-r--r-- | ui/build/soong.go | 1 |
12 files changed, 116 insertions, 47 deletions
diff --git a/android/config.go b/android/config.go index 9301df8cb..966312103 100644 --- a/android/config.go +++ b/android/config.go @@ -1093,6 +1093,10 @@ func (c *config) ExportedNamespaces() []string { return append([]string(nil), c.productVariables.NamespacesToExport...) } +func (c *config) IncludeTags() []string { + return c.productVariables.IncludeTags +} + func (c *config) HostStaticBinaries() bool { return Bool(c.productVariables.HostStaticBinaries) } diff --git a/android/register.go b/android/register.go index c50583322..a29cfeaf1 100644 --- a/android/register.go +++ b/android/register.go @@ -160,6 +160,7 @@ type Context struct { func NewContext(config Config) *Context { ctx := &Context{blueprint.NewContext(), config} ctx.SetSrcDir(absSrcDir) + ctx.AddIncludeTags(config.IncludeTags()...) return ctx } diff --git a/android/variable.go b/android/variable.go index 074808684..e56fd777e 100644 --- a/android/variable.go +++ b/android/variable.go @@ -456,6 +456,8 @@ type productVariables struct { GenerateAidlNdkPlatformBackend bool `json:",omitempty"` ForceMultilibFirstOnDevice bool `json:",omitempty"` + + IncludeTags []string `json:",omitempty"` } func boolPtr(v bool) *bool { diff --git a/apex/apex_test.go b/apex/apex_test.go index 63a7efe01..36d53064f 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -8276,6 +8276,30 @@ func TestApexSet(t *testing.T) { } } +func TestApexSet_NativeBridge(t *testing.T) { + ctx := testApex(t, ` + apex_set { + name: "myapex", + set: "myapex.apks", + filename: "foo_v2.apex", + overrides: ["foo"], + } + `, + android.FixtureModifyConfig(func(config android.Config) { + config.Targets[android.Android] = []android.Target{ + {Os: android.Android, Arch: android.Arch{ArchType: android.X86_64, ArchVariant: "", Abi: []string{"x86_64"}}}, + {Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridge: android.NativeBridgeEnabled}, + } + }), + ) + + m := ctx.ModuleForTests("myapex.apex.extractor", "android_common") + + // Check extract_apks tool parameters. No native bridge arch expected + extractedApex := m.Output("extracted/myapex.apks") + android.AssertStringEquals(t, "abis", "X86_64", extractedApex.Args["abis"]) +} + func TestNoStaticLinkingToStubsLib(t *testing.T) { testApexError(t, `.*required by "mylib" is a native library providing stub.*`, ` apex { diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 4f69ce8ec..e9261c0f3 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -24,6 +24,7 @@ import ( "android/soong/android" "android/soong/java" "android/soong/provenance" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -817,6 +818,8 @@ func (p *prebuiltApexExtractorModule) GenerateAndroidBuildActions(ctx android.Mo } apexSet := android.SingleSourcePathFromSupplier(ctx, srcsSupplier, "set") p.extractedApex = android.PathForModuleOut(ctx, "extracted", apexSet.Base()) + // Filter out NativeBridge archs (b/260115309) + abis := java.SupportedAbis(ctx, true) ctx.Build(pctx, android.BuildParams{ Rule: extractMatchingApex, @@ -824,7 +827,7 @@ func (p *prebuiltApexExtractorModule) GenerateAndroidBuildActions(ctx android.Mo Inputs: android.Paths{apexSet}, Output: p.extractedApex, Args: map[string]string{ - "abis": strings.Join(java.SupportedAbis(ctx), ","), + "abis": strings.Join(abis, ","), "allow-prereleased": strconv.FormatBool(proptools.Bool(p.properties.Prerelease)), "sdk-version": ctx.Config().PlatformSdkVersion().String(), }, diff --git a/cmd/extract_apks/main.go b/cmd/extract_apks/main.go index e39f8d765..c5ec9f72e 100644 --- a/cmd/extract_apks/main.go +++ b/cmd/extract_apks/main.go @@ -132,21 +132,21 @@ type apkDescriptionMatcher struct { *android_bundle_proto.ApkDescription } -func (m apkDescriptionMatcher) matches(config TargetConfig) bool { - return m.ApkDescription == nil || (apkTargetingMatcher{m.Targeting}).matches(config) +func (m apkDescriptionMatcher) matches(config TargetConfig, allAbisMustMatch bool) bool { + return m.ApkDescription == nil || (apkTargetingMatcher{m.Targeting}).matches(config, allAbisMustMatch) } type apkTargetingMatcher struct { *android_bundle_proto.ApkTargeting } -func (m apkTargetingMatcher) matches(config TargetConfig) bool { +func (m apkTargetingMatcher) matches(config TargetConfig, allAbisMustMatch bool) bool { return m.ApkTargeting == nil || (abiTargetingMatcher{m.AbiTargeting}.matches(config) && languageTargetingMatcher{m.LanguageTargeting}.matches(config) && screenDensityTargetingMatcher{m.ScreenDensityTargeting}.matches(config) && sdkVersionTargetingMatcher{m.SdkVersionTargeting}.matches(config) && - multiAbiTargetingMatcher{m.MultiAbiTargeting}.matches(config)) + multiAbiTargetingMatcher{m.MultiAbiTargeting}.matches(config, allAbisMustMatch)) } type languageTargetingMatcher struct { @@ -215,33 +215,27 @@ func (m multiAbiValue) compare(other multiAbiValue) int { } } - m = append(multiAbiValue{}, m...) - sort.Slice(m, sortAbis(m)) - other = append(multiAbiValue{}, other...) - sort.Slice(other, sortAbis(other)) + sortedM := append(multiAbiValue{}, m...) + sort.Slice(sortedM, sortAbis(sortedM)) + sortedOther := append(multiAbiValue{}, other...) + sort.Slice(sortedOther, sortAbis(sortedOther)) - for i := 0; i < min(len(m), len(other)); i++ { - if multiAbiPriorities[m[i].Alias] > multiAbiPriorities[other[i].Alias] { + for i := 0; i < min(len(sortedM), len(sortedOther)); i++ { + if multiAbiPriorities[sortedM[i].Alias] > multiAbiPriorities[sortedOther[i].Alias] { return 1 } - if multiAbiPriorities[m[i].Alias] < multiAbiPriorities[other[i].Alias] { + if multiAbiPriorities[sortedM[i].Alias] < multiAbiPriorities[sortedOther[i].Alias] { return -1 } } - if len(m) == len(other) { - return 0 - } - if len(m) > len(other) { - return 1 - } - return -1 + return len(sortedM) - len(sortedOther) } // this logic should match the logic in bundletool at // https://github.com/google/bundletool/blob/ae0fc0162fd80d92ef8f4ef4527c066f0106942f/src/main/java/com/android/tools/build/bundletool/device/MultiAbiMatcher.java#L43 // (note link is the commit at time of writing; but logic should always match the latest) -func (t multiAbiTargetingMatcher) matches(config TargetConfig) bool { +func (t multiAbiTargetingMatcher) matches(config TargetConfig, allAbisMustMatch bool) bool { if t.MultiAbiTargeting == nil { return true } @@ -250,12 +244,19 @@ func (t multiAbiTargetingMatcher) matches(config TargetConfig) bool { } multiAbiIsValid := func(m multiAbiValue) bool { + numValid := 0 for _, abi := range m { - if _, ok := config.abis[abi.Alias]; !ok { - return false + if _, ok := config.abis[abi.Alias]; ok { + numValid += 1 } } - return true + if numValid == 0 { + return false + } else if numValid > 0 && !allAbisMustMatch { + return true + } else { + return numValid == len(m) + } } // ensure that the current value is valid for our config @@ -264,6 +265,7 @@ func (t multiAbiTargetingMatcher) matches(config TargetConfig) bool { for _, multiAbi := range multiAbiSet { if multiAbiIsValid(multiAbi.GetAbi()) { valueSetContainsViableAbi = true + break } } @@ -362,13 +364,13 @@ type variantTargetingMatcher struct { *android_bundle_proto.VariantTargeting } -func (m variantTargetingMatcher) matches(config TargetConfig) bool { +func (m variantTargetingMatcher) matches(config TargetConfig, allAbisMustMatch bool) bool { if m.VariantTargeting == nil { return true } return sdkVersionTargetingMatcher{m.SdkVersionTargeting}.matches(config) && abiTargetingMatcher{m.AbiTargeting}.matches(config) && - multiAbiTargetingMatcher{m.MultiAbiTargeting}.matches(config) && + multiAbiTargetingMatcher{m.MultiAbiTargeting}.matches(config, allAbisMustMatch) && screenDensityTargetingMatcher{m.ScreenDensityTargeting}.matches(config) && textureCompressionFormatTargetingMatcher{m.TextureCompressionFormatTargeting}.matches(config) } @@ -380,30 +382,42 @@ type SelectionResult struct { // Return all entries matching target configuration func selectApks(toc Toc, targetConfig TargetConfig) SelectionResult { - var result SelectionResult - for _, variant := range (*toc).GetVariant() { - if !(variantTargetingMatcher{variant.GetTargeting()}.matches(targetConfig)) { - continue - } - for _, as := range variant.GetApkSet() { - if !(moduleMetadataMatcher{as.ModuleMetadata}.matches(targetConfig)) { + checkMatching := func(allAbisMustMatch bool) SelectionResult { + var result SelectionResult + for _, variant := range (*toc).GetVariant() { + if !(variantTargetingMatcher{variant.GetTargeting()}.matches(targetConfig, allAbisMustMatch)) { continue } - for _, apkdesc := range as.GetApkDescription() { - if (apkDescriptionMatcher{apkdesc}).matches(targetConfig) { - result.entries = append(result.entries, apkdesc.GetPath()) - // TODO(asmundak): As it turns out, moduleName which we get from - // the ModuleMetadata matches the module names of the generated - // entry paths just by coincidence, only for the split APKs. We - // need to discuss this with bundletool folks. - result.moduleName = as.GetModuleMetadata().GetName() + for _, as := range variant.GetApkSet() { + if !(moduleMetadataMatcher{as.ModuleMetadata}.matches(targetConfig)) { + continue + } + for _, apkdesc := range as.GetApkDescription() { + if (apkDescriptionMatcher{apkdesc}).matches(targetConfig, allAbisMustMatch) { + result.entries = append(result.entries, apkdesc.GetPath()) + // TODO(asmundak): As it turns out, moduleName which we get from + // the ModuleMetadata matches the module names of the generated + // entry paths just by coincidence, only for the split APKs. We + // need to discuss this with bundletool folks. + result.moduleName = as.GetModuleMetadata().GetName() + } + } + // we allow only a single module, so bail out here if we found one + if result.moduleName != "" { + return result } - } - // we allow only a single module, so bail out here if we found one - if result.moduleName != "" { - return result } } + return result + } + result := checkMatching(true) + if result.moduleName == "" { + // if there are no matches where all of the ABIs are available in the + // TargetConfig, then search again with a looser requirement of at + // least one matching ABI + // NOTE(b/260130686): this logic diverges from the logic in bundletool + // https://github.com/google/bundletool/blob/ae0fc0162fd80d92ef8f4ef4527c066f0106942f/src/main/java/com/android/tools/build/bundletool/device/MultiAbiMatcher.java#L43 + result = checkMatching(false) } return result } diff --git a/cmd/extract_apks/main_test.go b/cmd/extract_apks/main_test.go index c1d712df4..9f52877c9 100644 --- a/cmd/extract_apks/main_test.go +++ b/cmd/extract_apks/main_test.go @@ -744,7 +744,11 @@ variant { bp.Abi_X86_64: 0, }, }, - expected: SelectionResult{}, + expected: SelectionResult{ + "base", + []string{ + "standalones/standalone-x86.x86_64.apex", + }}, }, { name: "multi-variant multi-target cross-target", diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 4b3161b33..f1884a795 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -117,6 +117,7 @@ func newContext(configuration android.Config) *android.Context { ctx.Register() ctx.SetNameInterface(newNameResolver(configuration)) ctx.SetAllowMissingDependencies(configuration.AllowMissingDependencies()) + ctx.AddIncludeTags(configuration.IncludeTags()...) return ctx } diff --git a/java/app_set.go b/java/app_set.go index 694b1670e..defb4cbf7 100644 --- a/java/app_set.go +++ b/java/app_set.go @@ -96,7 +96,7 @@ var TargetCpuAbi = map[string]string{ "x86_64": "X86_64", } -func SupportedAbis(ctx android.ModuleContext) []string { +func SupportedAbis(ctx android.ModuleContext, excludeNativeBridgeAbis bool) []string { abiName := func(targetIdx int, deviceArch string) string { if abi, found := TargetCpuAbi[deviceArch]; found { return abi @@ -107,6 +107,9 @@ func SupportedAbis(ctx android.ModuleContext) []string { var result []string for i, target := range ctx.Config().Targets[android.Android] { + if target.NativeBridge == android.NativeBridgeEnabled && excludeNativeBridgeAbis { + continue + } result = append(result, abiName(i, target.Arch.ArchType.String())) } return result @@ -133,7 +136,7 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext) ImplicitOutputs: android.WritablePaths{as.packedOutput, as.apkcertsFile}, Inputs: android.Paths{as.prebuilt.SingleSourcePath(ctx)}, Args: map[string]string{ - "abis": strings.Join(SupportedAbis(ctx), ","), + "abis": strings.Join(SupportedAbis(ctx, false), ","), "allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)), "screen-densities": screenDensities, "sdk-version": ctx.Config().PlatformSdkVersion().String(), diff --git a/ui/build/config.go b/ui/build/config.go index e271bfca2..a6763214f 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -98,6 +98,8 @@ type configImpl struct { emptyNinjaFile bool metricsUploader string + + includeTags []string } const srcDirFileCheck = "build/soong/root.bp" @@ -1038,6 +1040,14 @@ func (c *configImpl) Parallel() int { return c.parallel } +func (c *configImpl) GetIncludeTags() []string { + return c.includeTags +} + +func (c *configImpl) SetIncludeTags(i []string) { + c.includeTags = i +} + func (c *configImpl) HighmemParallel() int { if i, ok := c.environ.GetInt("NINJA_HIGHMEM_NUM_JOBS"); ok { return i diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go index 0f4a249a3..177ac28a5 100644 --- a/ui/build/dumpvars.go +++ b/ui/build/dumpvars.go @@ -140,6 +140,7 @@ var BannerVars = []string{ "PLATFORM_VERSION_CODENAME", "PLATFORM_VERSION", "AICP_VERSION", + "PRODUCT_INCLUDE_TAGS", "TARGET_PRODUCT", "TARGET_BUILD_VARIANT", "TARGET_BUILD_TYPE", @@ -306,4 +307,5 @@ func runMakeProductConfig(ctx Context, config Config) { config.SetBuildBrokenDupRules(makeVars["BUILD_BROKEN_DUP_RULES"] == "true") config.SetBuildBrokenUsesNetwork(makeVars["BUILD_BROKEN_USES_NETWORK"] == "true") config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(makeVars["BUILD_BROKEN_NINJA_USES_ENV_VARS"])) + config.SetIncludeTags(strings.Fields(makeVars["PRODUCT_INCLUDE_TAGS"])) } diff --git a/ui/build/soong.go b/ui/build/soong.go index c7f22f946..a0ab1cc10 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -332,6 +332,7 @@ func bootstrapBlueprint(ctx Context, config Config) { blueprintArgs.EmptyNinjaFile = false blueprintCtx := blueprint.NewContext() + blueprintCtx.AddIncludeTags(config.GetIncludeTags()...) blueprintCtx.SetIgnoreUnknownModuleTypes(true) blueprintConfig := BlueprintConfig{ soongOutDir: config.SoongOutDir(), |
