Merge "Handle installation rules for co-existing prebuilts" into main
diff --git a/aconfig/Android.bp b/aconfig/Android.bp
index 3c79f19..402cf16 100644
--- a/aconfig/Android.bp
+++ b/aconfig/Android.bp
@@ -25,6 +25,7 @@
"aconfig_declarations_test.go",
"aconfig_values_test.go",
"aconfig_value_set_test.go",
+ "all_aconfig_declarations_test.go",
],
pluginFor: ["soong_build"],
}
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go
index b55d7bf..78f506a 100644
--- a/aconfig/aconfig_declarations.go
+++ b/aconfig/aconfig_declarations.go
@@ -164,18 +164,3 @@
})
}
-
-func SetAconfigFileMkEntries(m *android.ModuleBase, entries *android.AndroidMkEntries, aconfigFiles map[string]android.Paths) {
- // TODO(b/311155208): The default container here should be system.
- container := ""
-
- if m.SocSpecific() {
- container = "vendor"
- } else if m.ProductSpecific() {
- container = "product"
- } else if m.SystemExtSpecific() {
- container = "system_ext"
- }
-
- entries.SetPaths("LOCAL_ACONFIG_FILES", aconfigFiles[container])
-}
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go
index 36bea0e..b6c9023 100644
--- a/aconfig/all_aconfig_declarations.go
+++ b/aconfig/all_aconfig_declarations.go
@@ -16,6 +16,7 @@
import (
"android/soong/android"
+ "fmt"
)
// A singleton module that collects all of the aconfig flags declared in the
@@ -35,6 +36,7 @@
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) {
decl, ok := android.SingletonModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey)
@@ -42,8 +44,21 @@
return
}
cacheFiles = append(cacheFiles, decl.IntermediateCacheOutputPath)
+ packages[decl.Package]++
})
+ 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
this.intermediatePath = android.PathForIntermediates(ctx, "all_aconfig_declarations.pb")
ctx.Build(pctx, android.BuildParams{
diff --git a/aconfig/all_aconfig_declarations_test.go b/aconfig/all_aconfig_declarations_test.go
new file mode 100644
index 0000000..0b2021e
--- /dev/null
+++ b/aconfig/all_aconfig_declarations_test.go
@@ -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)
+}
diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go
index 8df353d..50cd4de 100644
--- a/aconfig/codegen/cc_aconfig_library.go
+++ b/aconfig/codegen/cc_aconfig_library.go
@@ -77,8 +77,12 @@
ctx.AddDependency(ctx.Module(), ccDeclarationsTag, declarations)
}
- // Add a dependency for the aconfig flags base library
- deps.SharedLibs = append(deps.SharedLibs, baseLibDep)
+ mode := proptools.StringDefault(this.properties.Mode, "production")
+
+ // Add a dependency for the aconfig flags base library if it is not forced read only
+ if mode != "force-read-only" {
+ deps.SharedLibs = append(deps.SharedLibs, baseLibDep)
+ }
// TODO: It'd be really nice if we could reexport this library and not make everyone do it.
return deps
diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go
index d762e9b..ef92cc8 100644
--- a/aconfig/codegen/cc_aconfig_library_test.go
+++ b/aconfig/codegen/cc_aconfig_library_test.go
@@ -20,6 +20,8 @@
"android/soong/android"
"android/soong/cc"
+
+ "github.com/google/blueprint"
)
var ccCodegenModeTestData = []struct {
@@ -164,3 +166,34 @@
android.AssertIntEquals(t, "len(LOCAL_ACONFIG_FILES)", 1, len(makeVar))
android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_foo/intermediate.pb")
}
+
+func TestForceReadOnly(t *testing.T) {
+ t.Helper()
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithAconfigBuildComponents,
+ cc.PrepareForTestWithCcDefaultModules).
+ ExtendWithErrorHandler(android.FixtureExpectsNoErrors).
+ RunTestWithBp(t, fmt.Sprintf(`
+ aconfig_declarations {
+ name: "my_aconfig_declarations",
+ package: "com.example.package",
+ srcs: ["foo.aconfig"],
+ }
+
+ cc_aconfig_library {
+ name: "my_cc_aconfig_library",
+ aconfig_declarations: "my_aconfig_declarations",
+ mode: "force-read-only",
+ }
+ `))
+
+ module := result.ModuleForTests("my_cc_aconfig_library", "android_arm64_armv8-a_shared").Module()
+ dependOnBaseLib := false
+ result.VisitDirectDeps(module, func(dep blueprint.Module) {
+ if dep.Name() == baseLibDep {
+ dependOnBaseLib = true
+ }
+ })
+ android.AssertBoolEquals(t, "should not have dependency on server_configuriable_flags",
+ dependOnBaseLib, false)
+}
diff --git a/aconfig/codegen/java_aconfig_library_test.go b/aconfig/codegen/java_aconfig_library_test.go
index 8d54b5b..7361d44 100644
--- a/aconfig/codegen/java_aconfig_library_test.go
+++ b/aconfig/codegen/java_aconfig_library_test.go
@@ -34,7 +34,7 @@
RunTestWithBp(t, bp+`
aconfig_declarations {
name: "my_aconfig_declarations_foo",
- package: "com.example.package",
+ package: "com.example.package.foo",
srcs: ["foo.aconfig"],
}
@@ -45,7 +45,7 @@
aconfig_declarations {
name: "my_aconfig_declarations_bar",
- package: "com.example.package",
+ package: "com.example.package.bar",
srcs: ["bar.aconfig"],
}
diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go
index ddebec3..4ba1a88 100644
--- a/android/aconfig_providers.go
+++ b/android/aconfig_providers.go
@@ -49,7 +49,13 @@
if *mergedAconfigFiles == nil {
*mergedAconfigFiles = make(map[string]Paths)
}
- ctx.VisitDirectDeps(func(module Module) {
+ ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
+ // Walk our direct dependencies, ignoring blueprint Modules and disabled Android Modules.
+ aModule, _ := module.(Module)
+ if aModule == nil || !aModule.Enabled() {
+ return
+ }
+
if dep, _ := OtherModuleProvider(ctx, module, AconfigDeclarationsProviderKey); dep.IntermediateCacheOutputPath != nil {
(*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath)
return
@@ -62,7 +68,7 @@
})
for container, aconfigFiles := range *mergedAconfigFiles {
- (*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, aconfigFiles)
+ (*mergedAconfigFiles)[container] = mergeAconfigFiles(ctx, container, aconfigFiles)
}
SetProvider(ctx, AconfigTransitiveDeclarationsInfoProvider, AconfigTransitiveDeclarationsInfo{
@@ -70,13 +76,13 @@
})
}
-func mergeAconfigFiles(ctx ModuleContext, inputs Paths) Paths {
+func mergeAconfigFiles(ctx ModuleContext, container string, inputs Paths) Paths {
inputs = LastUniquePaths(inputs)
if len(inputs) == 1 {
return Paths{inputs[0]}
}
- output := PathForModuleOut(ctx, "aconfig_merged.pb")
+ output := PathForModuleOut(ctx, container, "aconfig_merged.pb")
ctx.Build(pctx, BuildParams{
Rule: mergeAconfigFilesRule,
@@ -90,3 +96,18 @@
return Paths{output}
}
+
+func SetAconfigFileMkEntries(m *ModuleBase, entries *AndroidMkEntries, aconfigFiles map[string]Paths) {
+ // TODO(b/311155208): The default container here should be system.
+ container := ""
+
+ if m.SocSpecific() {
+ container = "vendor"
+ } else if m.ProductSpecific() {
+ container = "product"
+ } else if m.SystemExtSpecific() {
+ container = "system_ext"
+ }
+
+ entries.SetPaths("LOCAL_ACONFIG_FILES", aconfigFiles[container])
+}
diff --git a/android/filegroup.go b/android/filegroup.go
index 0aabb68..bc881ed 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -55,6 +55,9 @@
DefaultableModuleBase
properties fileGroupProperties
srcs Paths
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]Paths
}
var _ SourceFileProducer = (*fileGroup)(nil)
@@ -93,6 +96,7 @@
fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
}
SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: fg.srcs.Strings()})
+ CollectDependencyAconfigFiles(ctx, &fg.mergedAconfigFiles)
}
func (fg *fileGroup) Srcs() Paths {
diff --git a/androidmk/androidmk/android.go b/androidmk/androidmk/android.go
index 276b9ab..6564911 100644
--- a/androidmk/androidmk/android.go
+++ b/androidmk/androidmk/android.go
@@ -86,6 +86,7 @@
"LOCAL_ANNOTATION_PROCESSOR_CLASSES": skip, // Soong gets the processor classes from the plugin
"LOCAL_CTS_TEST_PACKAGE": skip, // Obsolete
+ "LOCAL_XTS_TEST_PACKAGE": skip, // Obsolete
"LOCAL_JACK_ENABLED": skip, // Obselete
"LOCAL_JACK_FLAGS": skip, // Obselete
}
diff --git a/androidmk/androidmk/androidmk_test.go b/androidmk/androidmk/androidmk_test.go
index 0580ae5..08bbb39 100644
--- a/androidmk/androidmk/androidmk_test.go
+++ b/androidmk/androidmk/androidmk_test.go
@@ -823,6 +823,26 @@
`,
},
{
+ desc: "IGNORE_LOCAL_XTS_TEST_PACKAGE",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_PACKAGE_NAME := FooTest
+LOCAL_COMPATIBILITY_SUITE := cts
+LOCAL_XTS_TEST_PACKAGE := foo.bar
+LOCAL_COMPATIBILITY_SUPPORT_FILES := file1
+include $(BUILD_CTS_PACKAGE)
+`,
+ expected: `
+android_test {
+ name: "FooTest",
+ defaults: ["cts_defaults"],
+ test_suites: ["cts"],
+
+ data: ["file1"],
+}
+`,
+ },
+ {
desc: "BUILD_CTS_*_JAVA_LIBRARY",
in: `
include $(CLEAR_VARS)
diff --git a/apex/apex.go b/apex/apex.go
index 4dd7728..b37c495 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -235,6 +235,9 @@
// List of filesystem images that are embedded inside this APEX bundle.
Filesystems []string
+ // List of prebuilt_etcs that are embedded inside this APEX bundle.
+ Prebuilts []string
+
// List of native libraries to exclude from this APEX.
Exclude_native_shared_libs []string
@@ -252,6 +255,9 @@
// List of filesystem images to exclude from this APEX bundle.
Exclude_filesystems []string
+
+ // List of prebuilt_etcs to exclude from this APEX bundle.
+ Exclude_prebuilts []string
}
// Merge combines another ApexNativeDependencies into this one
@@ -262,6 +268,7 @@
a.Binaries = append(a.Binaries, b.Binaries...)
a.Tests = append(a.Tests, b.Tests...)
a.Filesystems = append(a.Filesystems, b.Filesystems...)
+ a.Prebuilts = append(a.Prebuilts, b.Prebuilts...)
a.Exclude_native_shared_libs = append(a.Exclude_native_shared_libs, b.Exclude_native_shared_libs...)
a.Exclude_jni_libs = append(a.Exclude_jni_libs, b.Exclude_jni_libs...)
@@ -269,6 +276,7 @@
a.Exclude_binaries = append(a.Exclude_binaries, b.Exclude_binaries...)
a.Exclude_tests = append(a.Exclude_tests, b.Exclude_tests...)
a.Exclude_filesystems = append(a.Exclude_filesystems, b.Exclude_filesystems...)
+ a.Exclude_prebuilts = append(a.Exclude_prebuilts, b.Exclude_prebuilts...)
}
type apexMultilibProperties struct {
@@ -480,6 +488,9 @@
javaApisUsedByModuleFile android.ModuleOutPath
aconfigFiles []android.Path
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
// apexFileClass represents a type of file that can be included in APEX.
@@ -711,6 +722,8 @@
android.RemoveListFromList(nativeModules.Rust_dyn_libs, nativeModules.Exclude_rust_dyn_libs)...)
ctx.AddFarVariationDependencies(target.Variations(), fsTag,
android.RemoveListFromList(nativeModules.Filesystems, nativeModules.Exclude_filesystems)...)
+ ctx.AddFarVariationDependencies(target.Variations(), prebuiltTag,
+ android.RemoveListFromList(nativeModules.Prebuilts, nativeModules.Exclude_prebuilts)...)
}
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
@@ -2146,7 +2159,7 @@
}
//TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
- if ch.UseVndk() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
+ if ch.InVendorOrProduct() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
return false
}
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
@@ -2356,6 +2369,7 @@
return
}
}
+ android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
////////////////////////////////////////////////////////////////////////////////////////////
// 3) some fields in apexBundle struct are configured
@@ -2515,6 +2529,9 @@
type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
// apex_defaults provides defaultable properties to other apex modules.
@@ -2537,6 +2554,10 @@
android.OverrideModuleBase
}
+func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
+}
+
func (o *OverrideApex) GenerateAndroidBuildActions(_ android.ModuleContext) {
// All the overrides happen in the base module.
}
@@ -2874,32 +2895,6 @@
"libz",
"libziparchive",
}
- //
- // Module separator
- //
- m["com.android.wifi"] = []string{
- "PlatformProperties",
- "android.hardware.wifi-V1.0-java",
- "android.hardware.wifi-V1.0-java-constants",
- "android.hardware.wifi-V1.1-java",
- "android.hardware.wifi-V1.2-java",
- "android.hardware.wifi-V1.3-java",
- "android.hardware.wifi-V1.4-java",
- "android.hardware.wifi.hostapd-V1.0-java",
- "android.hardware.wifi.hostapd-V1.1-java",
- "android.hardware.wifi.hostapd-V1.2-java",
- "android.hardware.wifi.supplicant-V1.0-java",
- "android.hardware.wifi.supplicant-V1.1-java",
- "android.hardware.wifi.supplicant-V1.2-java",
- "android.hardware.wifi.supplicant-V1.3-java",
- "bouncycastle-unbundled",
- "framework-wifi-util-lib",
- "ksoap2",
- "libnanohttpd",
- "wifi-lite-protos",
- "wifi-nano-protos",
- "wifi-service-pre-jarjar",
- }
return m
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 72bafe6..7081f57 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -11106,7 +11106,7 @@
t.Fatalf("Expected 3 commands, got %d in:\n%s", len(aconfigArgs), s)
}
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/aconfig_merged.pb")
+ android.EnsureListContainsSuffix(t, aconfigArgs, "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/myapex/aconfig_merged.pb")
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_baz/intermediate.pb")
buildParams := combineAconfigRule.BuildParams
@@ -11114,7 +11114,7 @@
t.Fatalf("Expected 3 input, got %d", len(buildParams.Inputs))
}
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/aconfig_merged.pb")
+ android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_cc_library_bar/android_arm64_armv8-a_shared_apex10000/myapex/aconfig_merged.pb")
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_baz/intermediate.pb")
ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
}
@@ -11253,14 +11253,14 @@
t.Fatalf("Expected 2 commands, got %d in:\n%s", len(aconfigArgs), s)
}
android.EnsureListContainsSuffix(t, aconfigArgs, "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, aconfigArgs, "my_rust_binary/android_arm64_armv8-a_apex10000/aconfig_merged.pb")
+ android.EnsureListContainsSuffix(t, aconfigArgs, "my_rust_binary/android_arm64_armv8-a_apex10000/myapex/aconfig_merged.pb")
buildParams := combineAconfigRule.BuildParams
if len(buildParams.Inputs) != 2 {
t.Fatalf("Expected 3 input, got %d", len(buildParams.Inputs))
}
android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_aconfig_declarations_foo/intermediate.pb")
- android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_rust_binary/android_arm64_armv8-a_apex10000/aconfig_merged.pb")
+ android.EnsureListContainsSuffix(t, buildParams.Inputs.Strings(), "my_rust_binary/android_arm64_armv8-a_apex10000/myapex/aconfig_merged.pb")
ensureContains(t, buildParams.Output.String(), "android_common_myapex/aconfig_flags.pb")
}
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 9db3b7a..1ec38eb 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -494,6 +494,9 @@
inputApex android.Path
provenanceMetaDataFile android.OutputPath
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
type ApexFileProperties struct {
@@ -846,6 +849,8 @@
p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks...)
p.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, p.inputApex, p.installedFile)
}
+
+ android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
func (p *Prebuilt) ProvenanceMetaDataFile() android.OutputPath {
diff --git a/cc/androidmk.go b/cc/androidmk.go
index bde096b..7723dc3 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -15,7 +15,6 @@
package cc
import (
- "android/soong/aconfig"
"github.com/google/blueprint/proptools"
"fmt"
@@ -51,6 +50,7 @@
InVendorRamdisk() bool
InRecovery() bool
NotInPlatform() bool
+ InVendorOrProduct() bool
}
type subAndroidMkProvider interface {
@@ -125,7 +125,7 @@
entries.SetString("SOONG_SDK_VARIANT_MODULES",
"$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
}
- aconfig.SetAconfigFileMkEntries(c.AndroidModuleBase(), entries, c.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(c.AndroidModuleBase(), entries, c.mergedAconfigFiles)
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{
@@ -294,7 +294,7 @@
// they can be exceptionally used directly when APEXes are not available (e.g. during the
// very early stage in the boot process).
if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.NotInPlatform() &&
- !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() {
+ !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.InVendorOrProduct() && !ctx.static() {
if library.buildStubs() && library.isLatestStubVersion() {
entries.SubName = ""
}
diff --git a/cc/cc.go b/cc/cc.go
index c6e21c2..fd7a38a 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -525,6 +525,7 @@
inRamdisk() bool
inVendorRamdisk() bool
inRecovery() bool
+ InVendorOrProduct() bool
selectedStl() string
baseModuleName() string
getVndkExtendsModuleName() string
@@ -1285,7 +1286,7 @@
func (c *Module) canUseSdk() bool {
return c.Os() == android.Android && c.Target().NativeBridge == android.NativeBridgeDisabled &&
- !c.UseVndk() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
+ !c.InVendorOrProduct() && !c.InRamdisk() && !c.InRecovery() && !c.InVendorRamdisk()
}
func (c *Module) UseSdk() bool {
@@ -1667,6 +1668,10 @@
return ctx.mod.UseVndk()
}
+func (ctx *moduleContextImpl) InVendorOrProduct() bool {
+ return ctx.mod.InVendorOrProduct()
+}
+
func (ctx *moduleContextImpl) isNdk(config android.Config) bool {
return ctx.mod.IsNdk(config)
}
@@ -1896,7 +1901,7 @@
}
llndk := c.IsLlndk()
- if llndk || (c.UseVndk() && c.HasNonSystemVariants()) {
+ if llndk || (c.InVendorOrProduct() && c.HasNonSystemVariants()) {
// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
// added for product variant only when we have vendor and product variants with core
// variant. The suffix is not added for vendor-only or product-only module.
@@ -1989,6 +1994,10 @@
return false
}
+func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
+}
+
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
// Handle the case of a test module split by `test_per_src` mutator.
//
@@ -2192,7 +2201,7 @@
// is explicitly referenced via .bootstrap suffix or the module is marked with
// 'bootstrap: true').
if c.HasStubsVariants() && c.NotInPlatform() && !c.InRamdisk() &&
- !c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
+ !c.InRecovery() && !c.InVendorOrProduct() && !c.static() && !c.isCoverageVariant() &&
c.IsStubs() && !c.InVendorRamdisk() {
c.Properties.HideFromMake = false // unhide
// Note: this is still non-installable
@@ -3434,12 +3443,12 @@
panic(fmt.Errorf("Not an APEX module: %q", ctx.ModuleName()))
}
- useVndk := false
+ inVendorOrProduct := false
bootstrap := false
if linkable, ok := ctx.Module().(LinkableInterface); !ok {
panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName()))
} else {
- useVndk = linkable.UseVndk()
+ inVendorOrProduct = linkable.InVendorOrProduct()
bootstrap = linkable.Bootstrap()
}
@@ -3447,7 +3456,7 @@
useStubs := false
- if lib := moduleLibraryInterface(dep); lib.buildStubs() && useVndk { // LLNDK
+ if lib := moduleLibraryInterface(dep); lib.buildStubs() && inVendorOrProduct { // LLNDK
if !apexInfo.IsForPlatform() {
// For platform libraries, use current version of LLNDK
// If this is for use_vendor apex we will apply the same rules
@@ -3599,7 +3608,7 @@
// The vendor module is a no-vendor-variant VNDK library. Depend on the
// core module instead.
return libName
- } else if ccDep.UseVndk() && nonSystemVariantsExist {
+ } else if ccDep.InVendorOrProduct() && nonSystemVariantsExist {
// The vendor and product modules in Make will have been renamed to not conflict with the
// core module, so update the dependency name here accordingly.
return libName + ccDep.SubName()
@@ -4070,6 +4079,9 @@
android.ModuleBase
android.DefaultsModuleBase
android.ApexModuleBase
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]android.Paths
}
// cc_defaults provides a set of properties that can be inherited by other cc
diff --git a/cc/compiler.go b/cc/compiler.go
index c9de1b0..c57b72c 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -385,7 +385,7 @@
flags.Local.YasmFlags = append(flags.Local.YasmFlags, "-I"+modulePath)
}
- if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() {
+ if !(ctx.useSdk() || ctx.InVendorOrProduct()) || ctx.Host() {
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
"${config.CommonGlobalIncludes}",
tc.IncludeFlags())
@@ -402,7 +402,7 @@
"-isystem "+getCurrentIncludePath(ctx).Join(ctx, config.NDKTriple(tc)).String())
}
- if ctx.useVndk() {
+ if ctx.InVendorOrProduct() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__")
if ctx.inVendor() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VENDOR__")
@@ -720,7 +720,7 @@
// Compile files listed in c.Properties.Srcs into objects
objs := compileObjs(ctx, buildFlags, "", srcs,
- android.PathsForModuleSrc(ctx, compiler.Properties.Tidy_disabled_srcs),
+ append(android.PathsForModuleSrc(ctx, compiler.Properties.Tidy_disabled_srcs), compiler.generatedSources...),
android.PathsForModuleSrc(ctx, compiler.Properties.Tidy_timeout_srcs),
pathDeps, compiler.cFlagsDeps)
diff --git a/cc/gen.go b/cc/gen.go
index 2e72e30..e351fdd 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -225,6 +225,10 @@
// The files that can be used as order only dependencies in order to ensure that the sysprop
// header files are up to date.
syspropOrderOnlyDeps android.Paths
+
+ // List of generated code path.
+ // ex) '*.cpp' files generated from '*.ll / *.yy'.
+ generatedSources android.Paths
}
func genSources(
@@ -254,30 +258,37 @@
return yaccRule_
}
+ var generatedSources android.Paths = nil
+
for i, srcFile := range srcFiles {
switch srcFile.Ext() {
case ".y":
cFile := android.GenPathWithExt(ctx, "yacc", srcFile, "c")
srcFiles[i] = cFile
deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cFile, buildFlags.yacc)...)
+ generatedSources = append(generatedSources, cFile)
case ".yy":
cppFile := android.GenPathWithExt(ctx, "yacc", srcFile, "cpp")
srcFiles[i] = cppFile
deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cppFile, buildFlags.yacc)...)
+ generatedSources = append(generatedSources, cppFile)
case ".l":
cFile := android.GenPathWithExt(ctx, "lex", srcFile, "c")
srcFiles[i] = cFile
genLex(ctx, srcFile, cFile, buildFlags.lex)
+ generatedSources = append(generatedSources, cFile)
case ".ll":
cppFile := android.GenPathWithExt(ctx, "lex", srcFile, "cpp")
srcFiles[i] = cppFile
genLex(ctx, srcFile, cppFile, buildFlags.lex)
+ generatedSources = append(generatedSources, cppFile)
case ".proto":
ccFile, headerFile := genProto(ctx, srcFile, buildFlags)
srcFiles[i] = ccFile
info.protoHeaders = append(info.protoHeaders, headerFile)
// Use the generated header as an order only dep to ensure that it is up to date when needed.
info.protoOrderOnlyDeps = append(info.protoOrderOnlyDeps, headerFile)
+ generatedSources = append(generatedSources, ccFile)
case ".aidl":
if aidlRule == nil {
aidlRule = android.NewRuleBuilder(pctx, ctx).Sbox(android.PathForModuleGen(ctx, "aidl"),
@@ -299,10 +310,12 @@
// needed.
// TODO: Reduce the size of the ninja file by using one order only dep for the whole rule
info.aidlOrderOnlyDeps = append(info.aidlOrderOnlyDeps, aidlHeaders...)
+ generatedSources = append(generatedSources, cppFile)
case ".rscript", ".fs":
cppFile := rsGeneratedCppFile(ctx, srcFile)
rsFiles = append(rsFiles, srcFiles[i])
srcFiles[i] = cppFile
+ generatedSources = append(generatedSources, cppFile)
case ".sysprop":
cppFile, headerFiles := genSysprop(ctx, srcFile)
srcFiles[i] = cppFile
@@ -310,9 +323,12 @@
// Use the generated headers as order only deps to ensure that they are up to date when
// needed.
info.syspropOrderOnlyDeps = append(info.syspropOrderOnlyDeps, headerFiles...)
+ generatedSources = append(generatedSources, cppFile)
}
}
+ info.generatedSources = generatedSources
+
for _, aidlLibraryInfo := range aidlLibraryInfos {
if aidlLibraryRule == nil {
aidlLibraryRule = android.NewRuleBuilder(pctx, ctx).Sbox(
diff --git a/cc/genrule.go b/cc/genrule.go
index 0c06ae6..0fb3e2d 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -79,15 +79,7 @@
func (g *GenruleExtraProperties) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
- if ctx.DeviceConfig().VndkVersion() == "" {
- return true
- }
-
- if ctx.ProductSpecific() {
- return false
- }
-
- return !(ctx.SocSpecific() || ctx.DeviceSpecific())
+ return !(ctx.SocSpecific() || ctx.DeviceSpecific() || ctx.ProductSpecific())
}
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
@@ -115,26 +107,33 @@
}
func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {
- if ctx.DeviceConfig().VndkVersion() == "" {
- return nil
- }
-
var variants []string
- if Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific() {
- vndkVersion := ctx.DeviceConfig().VndkVersion()
- // If vndkVersion is current, we can always use PlatformVndkVersion.
- // If not, we assume modules under proprietary paths are compatible for
- // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
- // PLATFORM_VNDK_VERSION.
- if vndkVersion == "current" || !snapshot.IsVendorProprietaryModule(ctx) {
- variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
- } else {
- variants = append(variants, VendorVariationPrefix+vndkVersion)
- }
- }
+ vndkVersion := ctx.DeviceConfig().VndkVersion()
+ vendorVariantRequired := Bool(g.Vendor_available) || Bool(g.Odm_available) || ctx.SocSpecific() || ctx.DeviceSpecific()
+ productVariantRequired := Bool(g.Product_available) || ctx.ProductSpecific()
- if Bool(g.Product_available) || ctx.ProductSpecific() {
- variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
+ if vndkVersion == "" {
+ if vendorVariantRequired {
+ variants = append(variants, VendorVariation)
+ }
+ if productVariantRequired {
+ variants = append(variants, ProductVariation)
+ }
+ } else {
+ if vendorVariantRequired {
+ // If vndkVersion is current, we can always use PlatformVndkVersion.
+ // If not, we assume modules under proprietary paths are compatible for
+ // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, that is
+ // PLATFORM_VNDK_VERSION.
+ if vndkVersion == "current" || !snapshot.IsVendorProprietaryModule(ctx) {
+ variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
+ } else {
+ variants = append(variants, VendorVariationPrefix+vndkVersion)
+ }
+ }
+ if productVariantRequired {
+ variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
+ }
}
return variants
diff --git a/cc/genrule_test.go b/cc/genrule_test.go
index 9295244..05c644f 100644
--- a/cc/genrule_test.go
+++ b/cc/genrule_test.go
@@ -16,6 +16,7 @@
import (
"reflect"
+ "slices"
"testing"
"android/soong/android"
@@ -186,3 +187,26 @@
})
}
}
+
+func TestVendorProductVariantGenrule(t *testing.T) {
+ bp := `
+ cc_genrule {
+ name: "gen",
+ tool_files: ["tool"],
+ cmd: "$(location tool) $(in) $(out)",
+ out: ["out"],
+ vendor_available: true,
+ product_available: true,
+ }
+ `
+ t.Helper()
+ ctx := PrepareForTestWithCcIncludeVndk.RunTestWithBp(t, bp)
+
+ variants := ctx.ModuleVariantsForTests("gen")
+ if !slices.Contains(variants, "android_vendor_arm64_armv8-a") {
+ t.Errorf(`expected vendor variant, but does not exist in %v`, variants)
+ }
+ if !slices.Contains(variants, "android_product_arm64_armv8-a") {
+ t.Errorf(`expected product variant, but does not exist in %v`, variants)
+ }
+}
diff --git a/cc/image.go b/cc/image.go
index 9eec255..d02a2f3 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -128,6 +128,12 @@
return c.Properties.ImageVariation == VendorVariation
}
+// Returns true if the module is "vendor" or "product" variant. This replaces previous UseVndk usages
+// which were misused to check if the module variant is vendor or product.
+func (c *Module) InVendorOrProduct() bool {
+ return c.InVendor() || c.InProduct()
+}
+
func (c *Module) InRamdisk() bool {
return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
}
diff --git a/cc/installer.go b/cc/installer.go
index a0b6295..30f9612 100644
--- a/cc/installer.go
+++ b/cc/installer.go
@@ -87,7 +87,7 @@
} else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
}
- if installer.location == InstallInData && ctx.useVndk() {
+ if installer.location == InstallInData && ctx.InVendorOrProduct() {
if ctx.inProduct() {
dir = filepath.Join(dir, "product")
} else {
diff --git a/cc/library.go b/cc/library.go
index ebfec35..28eb80b 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -24,6 +24,7 @@
"sync"
"android/soong/android"
+
"github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools"
@@ -1342,12 +1343,10 @@
fileName+".lsdump")
}
-func getRefAbiDumpDir(isNdk, isVndk bool) string {
+func getRefAbiDumpDir(isNdk bool) string {
var dirName string
if isNdk {
dirName = "ndk"
- } else if isVndk {
- dirName = "vndk"
} else {
dirName = "platform"
}
@@ -1373,11 +1372,8 @@
}
}
-func currRefAbiDumpVersion(ctx ModuleContext, isVndk bool) string {
- if isVndk {
- // Each version of VNDK is independent, so follow the VNDK version which is the codename or PLATFORM_SDK_VERSION.
- return ctx.Module().(*Module).VndkVersion()
- } else if ctx.Config().PlatformSdkFinal() {
+func currRefAbiDumpVersion(ctx ModuleContext) string {
+ if ctx.Config().PlatformSdkFinal() {
// After sdk finalization, the ABI of the latest API level must be consistent with the source code,
// so choose PLATFORM_SDK_VERSION as the current version.
return ctx.Config().PlatformSdkVersion().String()
@@ -1426,13 +1422,13 @@
}
func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
- baseName string, isLlndkOrNdk, allowExtensions bool) {
+ baseName string, isLlndkOrNdk bool) {
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName
library.sourceAbiDiff(ctx, referenceDump, baseName, "",
- isLlndkOrNdk, allowExtensions, "current", errorMessage)
+ isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage)
}
func (library *libraryDecorator) optInAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
@@ -1462,10 +1458,9 @@
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
headerAbiChecker := library.getHeaderAbiCheckerProperties(ctx)
// The logic must be consistent with classifySourceAbiDump.
- isVndk := ctx.useVndk() && ctx.isVndk()
isNdk := ctx.isNdk(ctx.Config())
isLlndk := ctx.isImplementationForLLNDKPublic()
- currVersion := currRefAbiDumpVersion(ctx, isVndk)
+ currVersion := currRefAbiDumpVersion(ctx)
library.sAbiOutputFile = transformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags,
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
headerAbiChecker.Exclude_symbol_versions,
@@ -1474,26 +1469,24 @@
addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String())
- dumpDir := getRefAbiDumpDir(isNdk, isVndk)
+ dumpDir := getRefAbiDumpDir(isNdk)
binderBitness := ctx.DeviceConfig().BinderBitness()
- // If NDK or PLATFORM library, check against previous version ABI.
- if !isVndk {
- prevVersionInt := prevRefAbiDumpVersion(ctx, dumpDir)
- prevVersion := strconv.Itoa(prevVersionInt)
- prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness)
- prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName)
- if prevDumpFile.Valid() {
- library.crossVersionAbiDiff(ctx, prevDumpFile.Path(),
- fileName, isLlndk || isNdk,
- strconv.Itoa(prevVersionInt+1), prevVersion)
- }
+ // Check against the previous version.
+ prevVersionInt := prevRefAbiDumpVersion(ctx, dumpDir)
+ prevVersion := strconv.Itoa(prevVersionInt)
+ prevDumpDir := filepath.Join(dumpDir, prevVersion, binderBitness)
+ prevDumpFile := getRefAbiDumpFile(ctx, prevDumpDir, fileName)
+ if prevDumpFile.Valid() {
+ library.crossVersionAbiDiff(ctx, prevDumpFile.Path(),
+ fileName, isLlndk || isNdk,
+ strconv.Itoa(prevVersionInt+1), prevVersion)
}
// Check against the current version.
currDumpDir := filepath.Join(dumpDir, currVersion, binderBitness)
currDumpFile := getRefAbiDumpFile(ctx, currDumpDir, fileName)
if currDumpFile.Valid() {
library.sameVersionAbiDiff(ctx, currDumpFile.Path(),
- fileName, isLlndk || isNdk, ctx.IsVndkExt())
+ fileName, isLlndk || isNdk)
}
// Check against the opt-in reference dumps.
for i, optInDumpDir := range headerAbiChecker.Ref_dump_dirs {
@@ -1777,7 +1770,7 @@
}
if Bool(library.Properties.Static_ndk_lib) && library.static() &&
- !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && ctx.Device() &&
+ !ctx.InVendorOrProduct() && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && ctx.Device() &&
library.baseLinker.sanitize.isUnsanitizedVariant() &&
ctx.isForPlatform() && !ctx.isPreventInstall() {
installPath := getUnversionedLibraryInstallPath(ctx).Join(ctx, file.Base())
@@ -1897,7 +1890,7 @@
return nil
}
- if library.hasLLNDKStubs() && ctx.Module().(*Module).UseVndk() {
+ if library.hasLLNDKStubs() && ctx.Module().(*Module).InVendorOrProduct() {
// LLNDK libraries only need a single stubs variant.
return []string{android.FutureApiLevel.String()}
}
diff --git a/cc/library_stub.go b/cc/library_stub.go
index 1183b29..aab6664 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -48,7 +48,7 @@
return
}
- if m.UseVndk() && apiLibrary.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && apiLibrary.hasLLNDKStubs() {
// Add LLNDK variant dependency
if inList("llndk", apiLibrary.properties.Variants) {
variantName := BuildApiVariantName(m.BaseModuleName(), "llndk", "")
@@ -193,7 +193,7 @@
}
}
- if m.UseVndk() && d.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && d.hasLLNDKStubs() {
// LLNDK variant
load_cc_variant(BuildApiVariantName(m.BaseModuleName(), "llndk", ""))
} else if m.IsSdkVariant() {
@@ -312,7 +312,7 @@
}
}
- if d.hasLLNDKStubs() && m.UseVndk() {
+ if d.hasLLNDKStubs() && m.InVendorOrProduct() {
// LLNDK libraries only need a single stubs variant.
return []string{android.FutureApiLevel.String()}
}
diff --git a/cc/linkable.go b/cc/linkable.go
index a009c6c..6f22091 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -218,6 +218,7 @@
ProductSpecific() bool
InProduct() bool
SdkAndPlatformVariantVisibleToMake() bool
+ InVendorOrProduct() bool
// SubName returns the modules SubName, used for image and NDK/SDK variations.
SubName() string
diff --git a/cc/sabi.go b/cc/sabi.go
index 1310685..9f5781f 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -105,30 +105,17 @@
if headerAbiChecker.explicitlyDisabled() {
return ""
}
- // Return NDK if the library is both NDK and LLNDK.
- if m.IsNdk(ctx.Config()) {
- return "NDK"
- }
- if m.isImplementationForLLNDKPublic() {
- return "LLNDK"
- }
- if m.UseVndk() && m.IsVndk() && !m.IsVndkPrivate() {
- if m.IsVndkSp() {
- if m.IsVndkExt() {
- return "VNDK-SP-ext"
- } else {
- return "VNDK-SP"
- }
- } else {
- if m.IsVndkExt() {
- return "VNDK-ext"
- } else {
- return "VNDK-core"
- }
+ if !m.InProduct() && !m.InVendor() {
+ // Return NDK if the library is both NDK and LLNDK.
+ if m.IsNdk(ctx.Config()) {
+ return "NDK"
}
- }
- if m.library.hasStubsVariants() && !m.InProduct() && !m.InVendor() {
- return "PLATFORM"
+ if m.isImplementationForLLNDKPublic() {
+ return "LLNDK"
+ }
+ if m.library.hasStubsVariants() {
+ return "PLATFORM"
+ }
}
if headerAbiChecker.enabled() {
if m.InProduct() {
diff --git a/cc/test.go b/cc/test.go
index 347d7c9..3a1a3af 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -430,8 +430,7 @@
}
})
- useVendor := ctx.inVendor() || ctx.useVndk()
- testInstallBase := getTestInstallBase(useVendor)
+ testInstallBase := getTestInstallBase(ctx.InVendorOrProduct())
configs := getTradefedConfigOptions(ctx, &test.Properties, test.isolated(ctx), ctx.Device())
test.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
diff --git a/cc/testing.go b/cc/testing.go
index b1583f1..bac41e7 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -571,6 +571,7 @@
android.MockFS{
"defaults/cc/common/libc.map.txt": nil,
"defaults/cc/common/libdl.map.txt": nil,
+ "defaults/cc/common/libft2.map.txt": nil,
"defaults/cc/common/libm.map.txt": nil,
"defaults/cc/common/ndk_libc++_shared": nil,
"defaults/cc/common/crtbegin_so.c": nil,
diff --git a/cc/tidy_test.go b/cc/tidy_test.go
index 7036ecb..9481778 100644
--- a/cc/tidy_test.go
+++ b/cc/tidy_test.go
@@ -244,3 +244,30 @@
})
}
}
+
+func TestWithGeneratedCode(t *testing.T) {
+ bp := `
+ cc_library_shared {
+ name: "libfoo",
+ srcs: ["foo_1.y", "foo_2.yy", "foo_3.l", "foo_4.ll", "foo_5.proto",
+ "foo_6.aidl", "foo_7.rscript", "foo_8.fs", "foo_9.sysprop",
+ "foo_src.cpp"],
+ tidy: true,
+ }`
+ variant := "android_arm64_armv8-a_shared"
+
+ testEnv := map[string]string{}
+ testEnv["ALLOW_LOCAL_TIDY_TRUE"] = "1"
+
+ ctx := android.GroupFixturePreparers(prepareForCcTest, android.FixtureMergeEnv(testEnv)).RunTestWithBp(t, bp)
+
+ t.Run("tidy should be only run for source code, not for generated code", func(t *testing.T) {
+ depFiles := ctx.ModuleForTests("libfoo", variant).Rule("ld").Validations.Strings()
+
+ tidyFileForCpp := "out/soong/.intermediates/libfoo/" + variant + "/obj/foo_src.tidy"
+
+ android.AssertArrayString(t,
+ "only one .tidy file for source code should exist for libfoo",
+ []string{tidyFileForCpp}, depFiles)
+ })
+}
diff --git a/cc/vndk.go b/cc/vndk.go
index b2c6e0d..0e0dba9 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -418,11 +418,11 @@
lib, isLib := m.linker.(*libraryDecorator)
prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
- if m.UseVndk() && isLib && lib.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() {
m.VendorProperties.IsLLNDK = true
m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private)
}
- if m.UseVndk() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
+ if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
m.VendorProperties.IsLLNDK = true
m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private)
}
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 66df101..7642378 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -155,6 +155,9 @@
additionalDependencies *android.Paths
makeClass string
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]android.Paths
}
type Defaults struct {
@@ -365,6 +368,7 @@
symlinks: p.properties.Symlinks,
}
p.addInstallRules(ctx, ip)
+ android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
type installProperties struct {
@@ -433,11 +437,16 @@
if p.additionalDependencies != nil {
entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", p.additionalDependencies.Strings()...)
}
+ android.SetAconfigFileMkEntries(p.AndroidModuleBase(), entries, p.mergedAconfigFiles)
},
},
}}
}
+func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
+ return &p.ModuleBase
+}
+
func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
p.installDirBase = dirBase
p.AddProperties(&p.properties)
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 87f6392..fbda074 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -184,6 +184,9 @@
subName string
subDir string
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]android.Paths
}
type taskFunc func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) []generateTask
@@ -610,6 +613,24 @@
})
g.outputDeps = android.Paths{phonyFile}
}
+ android.CollectDependencyAconfigFiles(ctx, &g.mergedAconfigFiles)
+}
+
+func (g *Module) AndroidMkEntries() []android.AndroidMkEntries {
+ ret := android.AndroidMkEntries{
+ OutputFile: android.OptionalPathForPath(g.outputFiles[0]),
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
+ android.SetAconfigFileMkEntries(g.AndroidModuleBase(), entries, g.mergedAconfigFiles)
+ },
+ },
+ }
+
+ return []android.AndroidMkEntries{ret}
+}
+
+func (g *Module) AndroidModuleBase() *android.ModuleBase {
+ return &g.ModuleBase
}
// Collect information for opening IDE project files in java/jdeps.go.
diff --git a/java/aar.go b/java/aar.go
index 15a542e..7fc39b6 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -980,6 +980,9 @@
sdkVersion android.SdkSpec
minSdkVersion android.ApiLevel
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
var _ android.OutputFileProducer = (*AARImport)(nil)
@@ -1274,6 +1277,7 @@
android.SetProvider(ctx, JniPackageProvider, JniPackageInfo{
JniPackages: a.jniPackages,
})
+ android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
}
func (a *AARImport) HeaderJars() android.Paths {
diff --git a/java/androidmk.go b/java/androidmk.go
index cbf9abb..cc0efe9 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -19,7 +19,6 @@
"io"
"strings"
- "android/soong/aconfig"
"android/soong/android"
"github.com/google/blueprint/proptools"
@@ -129,7 +128,7 @@
if library.dexpreopter.configPath != nil {
entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
}
- aconfig.SetAconfigFileMkEntries(&library.ModuleBase, entries, library.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(&library.ModuleBase, entries, library.mergedAconfigFiles)
},
},
})
@@ -302,7 +301,7 @@
if len(binary.dexpreopter.builtInstalled) > 0 {
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
}
- aconfig.SetAconfigFileMkEntries(&binary.ModuleBase, entries, binary.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(&binary.ModuleBase, entries, binary.mergedAconfigFiles)
},
},
ExtraFooters: []android.AndroidMkExtraFootersFunc{
@@ -455,7 +454,7 @@
entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
if app.Name() != "framework-res" {
- aconfig.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles)
}
},
},
@@ -533,7 +532,7 @@
entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
- aconfig.SetAconfigFileMkEntries(&a.ModuleBase, entries, a.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(&a.ModuleBase, entries, a.mergedAconfigFiles)
})
return entriesList
diff --git a/java/app_import.go b/java/app_import.go
index ff0f5fe..997274c 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -86,6 +86,9 @@
hideApexVariantFromMake bool
provenanceMetaDataFile android.OutputPath
+
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
}
type AndroidAppImportProperties struct {
@@ -377,6 +380,7 @@
artifactPath := android.PathForModuleSrc(ctx, *a.properties.Apk)
a.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, artifactPath, a.installPath)
}
+ android.CollectDependencyAconfigFiles(ctx, &a.mergedAconfigFiles)
// TODO: androidmk converter jni libs
}
diff --git a/java/app_test.go b/java/app_test.go
index 3ee94d5..362bef9 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -4347,14 +4347,14 @@
}
aconfig_declarations {
name: "bar",
- package: "com.example.package",
+ package: "com.example.package.bar",
srcs: [
"bar.aconfig",
],
}
aconfig_declarations {
name: "baz",
- package: "com.example.package",
+ package: "com.example.package.baz",
srcs: [
"baz.aconfig",
],
diff --git a/java/builder.go b/java/builder.go
index e9218a7..085e7a1 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -277,7 +277,7 @@
gatherReleasedFlaggedApisRule = pctx.AndroidStaticRule("gatherReleasedFlaggedApisRule",
blueprint.RuleParams{
- Command: `${aconfig} dump --format bool ` +
+ Command: `${aconfig} dump-cache --format='{fully_qualified_name}={state:bool}' ` +
`--out ${out} ` +
`${flags_path} ` +
`${filter_args} `,
diff --git a/java/droidstubs.go b/java/droidstubs.go
index bdbaf92..04e6be8 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -89,6 +89,9 @@
metadataZip android.WritablePath
metadataDir android.WritablePath
+ // Single aconfig "cache file" merged from this module and all dependencies.
+ mergedAconfigFiles map[string]android.Paths
+
exportableApiFile android.WritablePath
exportableRemovedApiFile android.WritablePath
exportableNullabilityWarningsFile android.WritablePath
@@ -1255,6 +1258,7 @@
rule.Build("nullabilityWarningsCheck", "nullability warnings check")
}
+ android.CollectDependencyAconfigFiles(ctx, &d.mergedAconfigFiles)
}
func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) {
diff --git a/python/binary.go b/python/binary.go
index 85084a4..d6750c6 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -71,6 +71,9 @@
installedDest android.Path
androidMkSharedLibs []string
+
+ // Aconfig files for all transitive deps. Also exposed via TransitiveDeclarationsInfo
+ mergedAconfigFiles map[string]android.Paths
}
var _ android.AndroidMkEntriesProvider = (*PythonBinaryModule)(nil)
@@ -103,6 +106,7 @@
p.buildBinary(ctx)
p.installedDest = ctx.InstallFile(installDir(ctx, "bin", "", ""),
p.installSource.Base(), p.installSource)
+ android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
}
func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
@@ -166,6 +170,7 @@
entries.SetString("LOCAL_MODULE_STEM", stem)
entries.AddStrings("LOCAL_SHARED_LIBRARIES", p.androidMkSharedLibs...)
entries.SetBool("LOCAL_CHECK_ELF_FILES", false)
+ android.SetAconfigFileMkEntries(&p.ModuleBase, entries, p.mergedAconfigFiles)
})
return []android.AndroidMkEntries{entries}
diff --git a/python/test.go b/python/test.go
index 782f39f..7eb9136 100644
--- a/python/test.go
+++ b/python/test.go
@@ -149,6 +149,7 @@
// just use buildBinary() so that the binary is not installed into the location
// it would be for regular binaries.
p.PythonLibraryModule.GenerateAndroidBuildActions(ctx)
+ android.CollectDependencyAconfigFiles(ctx, &p.mergedAconfigFiles)
p.buildBinary(ctx)
var configs []tradefed.Option
@@ -228,6 +229,7 @@
}
entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(p.binaryProperties.Auto_gen_config, true))
+ android.SetAconfigFileMkEntries(&p.ModuleBase, entries, p.mergedAconfigFiles)
p.testProperties.Test_options.SetAndroidMkEntries(entries)
})
diff --git a/rust/androidmk.go b/rust/androidmk.go
index c355a56..17fd2d8 100644
--- a/rust/androidmk.go
+++ b/rust/androidmk.go
@@ -17,7 +17,6 @@
import (
"path/filepath"
- "android/soong/aconfig"
"android/soong/android"
)
@@ -67,7 +66,7 @@
if mod.UseVndk() {
entries.SetBool("LOCAL_USE_VNDK", true)
}
- aconfig.SetAconfigFileMkEntries(mod.AndroidModuleBase(), entries, mod.mergedAconfigFiles)
+ android.SetAconfigFileMkEntries(mod.AndroidModuleBase(), entries, mod.mergedAconfigFiles)
},
},
}
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 1cc1574..77ba277 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -170,7 +170,7 @@
cflags = append(cflags, strings.ReplaceAll(ccToolchain.Cflags(), "${config.", "${cc_config."))
cflags = append(cflags, strings.ReplaceAll(ccToolchain.ToolchainCflags(), "${config.", "${cc_config."))
- if ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
cflags = append(cflags, "-D__ANDROID_VNDK__")
if ctx.RustModule().InVendor() {
cflags = append(cflags, "-D__ANDROID_VENDOR__")
diff --git a/rust/compiler.go b/rust/compiler.go
index a8c5473..c1bdbeb 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -332,7 +332,7 @@
}
func (compiler *baseCompiler) cfgFlags(ctx ModuleContext, flags Flags) Flags {
- if ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vndk")
if ctx.RustModule().InVendor() {
compiler.Properties.Cfgs = append(compiler.Properties.Cfgs, "android_vendor")
@@ -520,7 +520,7 @@
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
}
- if compiler.location == InstallInData && ctx.RustModule().UseVndk() {
+ if compiler.location == InstallInData && ctx.RustModule().InVendorOrProduct() {
if ctx.RustModule().InProduct() {
dir = filepath.Join(dir, "product")
} else if ctx.RustModule().InVendor() {
diff --git a/rust/image.go b/rust/image.go
index 7adf234..530c56e 100644
--- a/rust/image.go
+++ b/rust/image.go
@@ -192,6 +192,11 @@
return mod.Properties.ImageVariation == cc.VendorVariation
}
+// Returns true if the module is "vendor" or "product" variant.
+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)
if variant == android.VendorRamdiskVariation {
diff --git a/rust/test.go b/rust/test.go
index 6619af6..2583893 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -117,7 +117,7 @@
func (test *testDecorator) install(ctx ModuleContext) {
testInstallBase := "/data/local/tests/unrestricted"
- if ctx.RustModule().InVendor() || ctx.RustModule().UseVndk() {
+ if ctx.RustModule().InVendorOrProduct() {
testInstallBase = "/data/local/tests/vendor"
}
diff --git a/ui/build/ninja.go b/ui/build/ninja.go
index b69e938..551b8ab 100644
--- a/ui/build/ninja.go
+++ b/ui/build/ninja.go
@@ -271,11 +271,13 @@
// The Ninja file hasn't been modified since the last time it was
// checked, so Ninja could be stuck. Output some diagnostics.
ctx.Verbosef("ninja may be stuck; last update to %v was %v. dumping process tree...", c.logPath, newModTime)
+ ctx.Printf("ninja may be stuck, check %v for list of running processes.",
+ filepath.Join(config.LogsDir(), config.logsPrefix+"soong.log"))
// The "pstree" command doesn't exist on Mac, but "pstree" on Linux
// gives more convenient output than "ps" So, we try pstree first, and
// ps second
- commandText := fmt.Sprintf("pstree -pal %v || ps -ef", os.Getpid())
+ commandText := fmt.Sprintf("pstree -palT %v || ps -ef", os.Getpid())
cmd := Command(ctx, config, "dump process tree", "bash", "-c", commandText)
output := cmd.CombinedOutputOrFatal()