summaryrefslogtreecommitdiff
path: root/cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc')
-rw-r--r--cc/androidmk.go4
-rw-r--r--cc/cc.go7
-rw-r--r--cc/genrule.go53
-rw-r--r--cc/genrule_test.go24
-rw-r--r--cc/library.go42
-rw-r--r--cc/sabi.go33
6 files changed, 85 insertions, 78 deletions
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 786d2bca2..7723dc38f 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -15,8 +15,6 @@
package cc
import (
- "android/soong/aconfig"
-
"github.com/google/blueprint/proptools"
"fmt"
@@ -127,7 +125,7 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
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{
diff --git a/cc/cc.go b/cc/cc.go
index d34daec9e..fd7a38a12 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1994,6 +1994,10 @@ func (c *Module) stubLibraryMultipleApexViolation(ctx android.ModuleContext) boo
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.
//
@@ -4075,6 +4079,9 @@ type Defaults struct {
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/genrule.go b/cc/genrule.go
index 0c06ae6dd..0fb3e2d1f 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -79,15 +79,7 @@ var _ android.ImageInterface = (*GenruleExtraProperties)(nil)
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) RecoveryVariantNeeded(ctx android.BaseModuleCon
}
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 929524480..05c644f1e 100644
--- a/cc/genrule_test.go
+++ b/cc/genrule_test.go
@@ -16,6 +16,7 @@ package cc
import (
"reflect"
+ "slices"
"testing"
"android/soong/android"
@@ -186,3 +187,26 @@ func TestCmdPrefix(t *testing.T) {
})
}
}
+
+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/library.go b/cc/library.go
index 52fa254f3..28eb80bb1 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1343,12 +1343,10 @@ func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
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"
}
@@ -1374,11 +1372,8 @@ func prevRefAbiDumpVersion(ctx ModuleContext, dumpDir string) int {
}
}
-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()
@@ -1427,13 +1422,13 @@ func (library *libraryDecorator) crossVersionAbiDiff(ctx android.ModuleContext,
}
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,
@@ -1463,10 +1458,9 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
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,
@@ -1475,26 +1469,24 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
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 {
diff --git a/cc/sabi.go b/cc/sabi.go
index 13106859f..9f5781fa9 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -105,30 +105,17 @@ func classifySourceAbiDump(ctx android.BaseModuleContext) string {
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.isImplementationForLLNDKPublic() {
+ return "LLNDK"
+ }
+ if m.library.hasStubsVariants() {
+ return "PLATFORM"
}
- }
- if m.library.hasStubsVariants() && !m.InProduct() && !m.InVendor() {
- return "PLATFORM"
}
if headerAbiChecker.enabled() {
if m.InProduct() {