Merge "Make Contents and Standalone_contents configurable" into main
diff --git a/android/module.go b/android/module.go
index 58ae885..3b30c11 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1382,6 +1382,8 @@
if config.SystemExtPath() == "system_ext" {
partition = "system_ext"
}
+ } else if m.InstallInRamdisk() {
+ partition = "ramdisk"
}
return partition
}
diff --git a/android/variable.go b/android/variable.go
index c6a1b0a..2d43c6d 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -606,10 +606,20 @@
BoardExt4ShareDupBlocks string `json:",omitempty"`
BoardFlashLogicalBlockSize string `json:",omitempty"`
BoardFlashEraseBlockSize string `json:",omitempty"`
- BoardUsesRecoveryAsBoot bool `json:",omitempty"`
ProductUseDynamicPartitionSize bool `json:",omitempty"`
CopyImagesForTargetFilesZip bool `json:",omitempty"`
+ // Boot image stuff
+ ProductBuildBootImage bool `json:",omitempty"`
+ ProductBuildInitBootImage bool `json:",omitempty"`
+ BoardUsesRecoveryAsBoot bool `json:",omitempty"`
+ BoardPrebuiltBootimage string `json:",omitempty"`
+ BoardPrebuiltInitBootimage string `json:",omitempty"`
+ BoardBootimagePartitionSize string `json:",omitempty"`
+ BoardInitBootimagePartitionSize string `json:",omitempty"`
+ BoardBootHeaderVersion string `json:",omitempty"`
+
+ // Avb (android verified boot) stuff
BoardAvbEnable bool `json:",omitempty"`
BoardAvbAlgorithm string `json:",omitempty"`
BoardAvbKeyPath string `json:",omitempty"`
@@ -625,7 +635,7 @@
BoardInfoFiles []string `json:",omitempty"`
BootLoaderBoardName string `json:",omitempty"`
- ProductCopyFiles map[string]string `json:",omitempty"`
+ ProductCopyFiles []string `json:",omitempty"`
BuildingSystemDlkmImage bool `json:",omitempty"`
SystemKernelModules []string `json:",omitempty"`
diff --git a/apex/apex.go b/apex/apex.go
index a1879f5..04b5a07 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -105,11 +105,10 @@
Rros []string
// List of bootclasspath fragments that are embedded inside this APEX bundle.
- Bootclasspath_fragments []string
+ Bootclasspath_fragments proptools.Configurable[[]string]
// List of systemserverclasspath fragments that are embedded inside this APEX bundle.
- Systemserverclasspath_fragments proptools.Configurable[[]string]
- ResolvedSystemserverclasspathFragments []string `blueprint:"mutated"`
+ Systemserverclasspath_fragments proptools.Configurable[[]string]
// List of java libraries that are embedded inside this APEX bundle.
Java_libs []string
@@ -891,13 +890,11 @@
}
}
- a.properties.ResolvedSystemserverclasspathFragments = a.properties.Systemserverclasspath_fragments.GetOrDefault(ctx, nil)
-
// Common-arch dependencies come next
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
ctx.AddFarVariationDependencies(commonVariation, rroTag, a.properties.Rros...)
- ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...)
- ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.ResolvedSystemserverclasspathFragments...)
+ ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments.GetOrDefault(ctx, nil)...)
+ ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments.GetOrDefault(ctx, nil)...)
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...)
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...)
@@ -2776,8 +2773,8 @@
// Collect information for opening IDE project files in java/jdeps.go.
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...)
+ dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments.GetOrDefault(ctx, nil)...)
+ dpInfo.Deps = append(dpInfo.Deps, a.properties.Systemserverclasspath_fragments.GetOrDefault(ctx, nil)...)
}
func init() {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 9e9efd6..17cea5e 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -10187,7 +10187,7 @@
deps: [
"libfoo",
],
- linkerconfig: {
+ linker_config: {
gen_linker_config: true,
linker_config_srcs: ["linker.config.json"],
},
diff --git a/cc/cc.go b/cc/cc.go
index 60cf011..08a93cb9 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1560,12 +1560,11 @@
}
if ctx.ctx.Device() {
- config := ctx.ctx.Config()
- if ctx.inVendor() {
- // If building for vendor with final API, then use the latest _stable_ API as "current".
- if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") {
- ver = config.PlatformSdkVersion().String()
- }
+ // When building for vendor/product, use the latest _stable_ API as "current".
+ // This is passed to clang/aidl compilers so that compiled/generated code works
+ // with the system.
+ if (ctx.inVendor() || ctx.inProduct()) && (ver == "" || ver == "current") {
+ ver = ctx.ctx.Config().PlatformSdkVersion().String()
}
}
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 989b043..144b90b 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -1008,7 +1008,7 @@
android.AssertArrayString(t, "variants for llndk stubs", expected, actual)
params := result.ModuleForTests("libllndk", "android_vendor_arm_armv7-a-neon_shared").Description("generate stub")
- android.AssertSame(t, "use Vendor API level for default stubs", "202404", params.Args["apiLevel"])
+ android.AssertSame(t, "use Vendor API level for default stubs", "999999", params.Args["apiLevel"])
checkExportedIncludeDirs := func(module, variant string, expectedSystemDirs []string, expectedDirs ...string) {
t.Helper()
@@ -3153,7 +3153,7 @@
testDepWithVariant("product")
}
-func TestVendorSdkVersion(t *testing.T) {
+func TestVendorOrProductVariantUsesPlatformSdkVersionAsDefault(t *testing.T) {
t.Parallel()
bp := `
@@ -3161,31 +3161,29 @@
name: "libfoo",
srcs: ["libfoo.cc"],
vendor_available: true,
+ product_available: true,
}
cc_library {
name: "libbar",
srcs: ["libbar.cc"],
vendor_available: true,
+ product_available: true,
min_sdk_version: "29",
}
`
ctx := prepareForCcTest.RunTestWithBp(t, bp)
- testSdkVersionFlag := func(module, version string) {
- flags := ctx.ModuleForTests(module, "android_vendor_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
- android.AssertStringDoesContain(t, "min sdk version", flags, "-target aarch64-linux-android"+version)
+ testSdkVersionFlag := func(module, variant, version string) {
+ flags := ctx.ModuleForTests(module, "android_"+variant+"_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
+ android.AssertStringDoesContain(t, "target SDK version", flags, "-target aarch64-linux-android"+version)
}
- testSdkVersionFlag("libfoo", "10000")
- testSdkVersionFlag("libbar", "29")
-
- ctx = android.GroupFixturePreparers(
- prepareForCcTest,
- android.PrepareForTestWithBuildFlag("RELEASE_BOARD_API_LEVEL_FROZEN", "true"),
- ).RunTestWithBp(t, bp)
- testSdkVersionFlag("libfoo", "30")
- testSdkVersionFlag("libbar", "29")
+ testSdkVersionFlag("libfoo", "vendor", "30")
+ testSdkVersionFlag("libfoo", "product", "30")
+ // target SDK version can be set explicitly with min_sdk_version
+ testSdkVersionFlag("libbar", "vendor", "29")
+ testSdkVersionFlag("libbar", "product", "29")
}
func TestClangVerify(t *testing.T) {
diff --git a/cc/compdb.go b/cc/compdb.go
index b33f490..4132e09 100644
--- a/cc/compdb.go
+++ b/cc/compdb.go
@@ -146,6 +146,8 @@
isAsm = false
isCpp = true
clangPath = cxxPath
+ case ".o":
+ return nil
default:
log.Print("Unknown file extension " + src.Ext() + " on file " + src.String())
isAsm = true
@@ -185,6 +187,10 @@
}
for _, src := range srcs {
if _, ok := builds[src.String()]; !ok {
+ args := getArguments(src, ctx, ccModule, ccPath, cxxPath)
+ if args == nil {
+ continue
+ }
builds[src.String()] = compDbEntry{
Directory: android.AbsSrcDirForExistingUseCases(),
Arguments: getArguments(src, ctx, ccModule, ccPath, cxxPath),
diff --git a/cc/library.go b/cc/library.go
index 7dffa72..4ce506e 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -566,16 +566,10 @@
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
if ctx.IsLlndk() {
- vendorApiLevel := ctx.Config().VendorApiLevel()
- if vendorApiLevel == "" {
- // TODO(b/321892570): Some tests relying on old fixtures which
- // doesn't set vendorApiLevel. Needs to fix them.
- vendorApiLevel = ctx.Config().PlatformSdkVersion().String()
- }
- // This is the vendor variant of an LLNDK library, build the LLNDK stubs.
+ futureVendorApiLevel := android.ApiLevelOrPanic(ctx, "999999")
nativeAbiResult := parseNativeAbiDefinition(ctx,
String(library.Properties.Llndk.Symbol_file),
- android.ApiLevelOrPanic(ctx, vendorApiLevel), "--llndk")
+ futureVendorApiLevel, "--llndk")
objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
if !Bool(library.Properties.Llndk.Unversioned) {
library.versionScriptPath = android.OptionalPathForPath(
diff --git a/cmd/symbols_map/symbols_map_proto/symbols_map.proto b/cmd/symbols_map/symbols_map_proto/symbols_map.proto
index 693fe3e..a76d171 100644
--- a/cmd/symbols_map/symbols_map_proto/symbols_map.proto
+++ b/cmd/symbols_map/symbols_map_proto/symbols_map.proto
@@ -37,6 +37,21 @@
// type is the type of the mapping, either ELF or R8.
optional Type type = 3;
+
+ // LocationType is the place where to look for the file with the given
+ // identifier.
+ Enum LocationType {
+ // ZIP denotes the file with the given identifier is in the distribuited
+ // symbols.zip or proguard_dict.zip files, or the local disc.
+ ZIP = 0;
+ // AB denotes the file with the given identifier is in the AB artifacts but
+ // not in a symbols.zip or proguard_dict.zip.
+ AB = 1;
+ }
+
+ // location_type is the Location Type that dictates where to search for the
+ // file with the given identifier. Defaults to ZIP if not present.
+ optional LocationType location_type = 4;
}
message Mappings {
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index f72cf17..78e24e2 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -153,7 +153,7 @@
F2fs F2fsProperties
- Linkerconfig LinkerConfigProperties
+ Linker_config LinkerConfigProperties
// Determines if the module is auto-generated from Soong or not. If the module is
// auto-generated, its deps are exempted from visibility enforcement.
@@ -292,10 +292,14 @@
func (f *filesystem) FilterPackagingSpec(ps android.PackagingSpec) bool {
// Filesystem module respects the installation semantic. A PackagingSpec from a module with
// IsSkipInstall() is skipped.
- if proptools.Bool(f.properties.Is_auto_generated) { // TODO (spandandas): Remove this.
- return !ps.SkipInstall() && (ps.Partition() == f.PartitionType())
+ if ps.SkipInstall() {
+ return false
}
- return !ps.SkipInstall()
+ if proptools.Bool(f.properties.Is_auto_generated) { // TODO (spandandas): Remove this.
+ pt := f.PartitionType()
+ return pt == "ramdisk" || ps.Partition() == pt
+ }
+ return true
}
var pctx = android.NewPackageContext("android/soong/filesystem")
@@ -664,6 +668,7 @@
"vendor_dlkm",
"odm_dlkm",
"system_dlkm",
+ "ramdisk",
}
func (f *filesystem) addMakeBuiltFiles(ctx android.ModuleContext, builder *android.RuleBuilder, rootDir android.Path) {
@@ -721,13 +726,13 @@
}
func (f *filesystem) BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
- if !proptools.Bool(f.properties.Linkerconfig.Gen_linker_config) {
+ if !proptools.Bool(f.properties.Linker_config.Gen_linker_config) {
return
}
provideModules, _ := f.getLibsForLinkerConfig(ctx)
output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
- linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, f.properties.Linkerconfig.Linker_config_srcs), provideModules, nil, output)
+ linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, f.properties.Linker_config.Linker_config_srcs), provideModules, nil, output)
f.appendToEntry(ctx, output)
}
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index f284161..f325d96 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -161,7 +161,7 @@
"libfoo",
"libbar",
],
- linkerconfig: {
+ linker_config: {
gen_linker_config: true,
linker_config_srcs: ["linker.config.json"],
},
@@ -227,7 +227,7 @@
deps: ["foo"],
},
},
- linkerconfig: {
+ linker_config: {
gen_linker_config: true,
linker_config_srcs: ["linker.config.json"],
},
@@ -325,7 +325,7 @@
deps: [
"libfoo",
],
- linkerconfig: {
+ linker_config: {
gen_linker_config: true,
linker_config_srcs: ["linker.config.json"],
},
@@ -709,7 +709,7 @@
android_filesystem {
name: "myfilesystem",
deps: ["libfoo_has_no_stubs", "libfoo_has_stubs"],
- linkerconfig: {
+ linker_config: {
gen_linker_config: true,
linker_config_srcs: ["linker.config.json"],
},
diff --git a/filesystem/system_image.go b/filesystem/system_image.go
index 0d54ff5..672458c 100644
--- a/filesystem/system_image.go
+++ b/filesystem/system_image.go
@@ -42,13 +42,13 @@
}
func (s *systemImage) BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
- if !proptools.Bool(s.filesystem.properties.Linkerconfig.Gen_linker_config) {
+ if !proptools.Bool(s.filesystem.properties.Linker_config.Gen_linker_config) {
return
}
provideModules, requireModules := s.getLibsForLinkerConfig(ctx)
output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
- linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, s.filesystem.properties.Linkerconfig.Linker_config_srcs), provideModules, requireModules, output)
+ linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, s.filesystem.properties.Linker_config.Linker_config_srcs), provideModules, requireModules, output)
s.appendToEntry(ctx, output)
}
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 9cada0b..0a65c6c 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -230,8 +230,8 @@
}
if partitionType == "vendor" || partitionType == "product" {
- fsProps.Linkerconfig.Gen_linker_config = proptools.BoolPtr(true)
- fsProps.Linkerconfig.Linker_config_srcs = f.createLinkerConfigSourceFilegroups(ctx, partitionType)
+ fsProps.Linker_config.Gen_linker_config = proptools.BoolPtr(true)
+ fsProps.Linker_config.Linker_config_srcs = f.createLinkerConfigSourceFilegroups(ctx, partitionType)
}
if android.InList(partitionType, dlkmPartitions) {
@@ -267,6 +267,7 @@
Vendor_dlkm_specific *bool
Odm_dlkm_specific *bool
Load_by_default *bool
+ Blocklist_file *string
}{
Name: proptools.StringPtr(name),
}
@@ -279,15 +280,24 @@
// https://source.corp.google.com/h/googleplex-android/platform/build/+/ef55daac9954896161b26db4f3ef1781b5a5694c:core/Makefile;l=695-700;drc=549fe2a5162548bd8b47867d35f907eb22332023;bpv=1;bpt=0
props.Load_by_default = proptools.BoolPtr(false)
}
+ if blocklistFile := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.SystemKernelBlocklistFile; blocklistFile != "" {
+ props.Blocklist_file = proptools.StringPtr(blocklistFile)
+ }
case "vendor_dlkm":
props.Srcs = ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.VendorKernelModules
if len(ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.SystemKernelModules) > 0 {
props.System_deps = []string{":" + generatedModuleName(ctx.Config(), "system_dlkm-kernel-modules") + "{.modules}"}
}
props.Vendor_dlkm_specific = proptools.BoolPtr(true)
+ if blocklistFile := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.VendorKernelBlocklistFile; blocklistFile != "" {
+ props.Blocklist_file = proptools.StringPtr(blocklistFile)
+ }
case "odm_dlkm":
props.Srcs = ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.OdmKernelModules
props.Odm_dlkm_specific = proptools.BoolPtr(true)
+ if blocklistFile := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.OdmKernelBlocklistFile; blocklistFile != "" {
+ props.Blocklist_file = proptools.StringPtr(blocklistFile)
+ }
default:
ctx.ModuleErrorf("DLKM is not supported for %s\n", partitionType)
}
@@ -411,13 +421,20 @@
fsProps := &filesystem.FilesystemProperties{}
partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
- specificPartitionVars := partitionVars.PartitionQualifiedVariables[partitionType]
-
- // BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE
- fsType := specificPartitionVars.BoardFileSystemType
+ var specificPartitionVars android.PartitionQualifiedVariablesType
+ var boardAvbEnable bool
+ var fsType string
+ if strings.Contains(partitionType, "ramdisk") {
+ fsType = "compressed_cpio"
+ } else {
+ specificPartitionVars = partitionVars.PartitionQualifiedVariables[partitionType]
+ boardAvbEnable = partitionVars.BoardAvbEnable
+ fsType = specificPartitionVars.BoardFileSystemType
+ }
if fsType == "" {
fsType = "ext4" //default
}
+
fsProps.Type = proptools.StringPtr(fsType)
if filesystem.GetFsTypeFromString(ctx, *fsProps.Type).IsUnknown() {
// Currently the android_filesystem module type only supports a handful of FS types like ext4, erofs
@@ -429,7 +446,7 @@
fsProps.Unchecked_module = proptools.BoolPtr(true)
// BOARD_AVB_ENABLE
- fsProps.Use_avb = proptools.BoolPtr(partitionVars.BoardAvbEnable)
+ fsProps.Use_avb = proptools.BoolPtr(boardAvbEnable)
// BOARD_AVB_KEY_PATH
fsProps.Avb_private_key = proptools.StringPtr(specificPartitionVars.BoardAvbKeyPath)
// BOARD_AVB_ALGORITHM
diff --git a/fsgen/fsgen_mutators.go b/fsgen/fsgen_mutators.go
index 4440c63..e9fd513 100644
--- a/fsgen/fsgen_mutators.go
+++ b/fsgen/fsgen_mutators.go
@@ -17,6 +17,7 @@
import (
"fmt"
"slices"
+ "strings"
"sync"
"android/soong/android"
@@ -80,7 +81,7 @@
}
func generatedPartitions(ctx android.LoadHookContext) []string {
- generatedPartitions := []string{"system"}
+ generatedPartitions := []string{"system", "ramdisk"}
if ctx.DeviceConfig().SystemExtPath() == "system_ext" {
generatedPartitions = append(generatedPartitions, "system_ext")
}
@@ -171,6 +172,7 @@
"fs_config_files_odm_dlkm": defaultDepCandidateProps(ctx.Config()),
"odm_dlkm-build.prop": defaultDepCandidateProps(ctx.Config()),
},
+ "ramdisk": {},
},
fsDepsMutex: sync.Mutex{},
moduleToInstallationProps: map[string]installationProperties{},
@@ -205,29 +207,31 @@
}
func collectDepsMutator(mctx android.BottomUpMutatorContext) {
+ m := mctx.Module()
+ if m.Target().Os.Class != android.Device {
+ return
+ }
fsGenState := mctx.Config().Get(fsGenStateOnceKey).(*FsGenState)
- m := mctx.Module()
- if m.Target().Os.Class == android.Device && slices.Contains(fsGenState.depCandidates, mctx.ModuleName()) {
+ fsGenState.fsDepsMutex.Lock()
+ defer fsGenState.fsDepsMutex.Unlock()
+
+ if slices.Contains(fsGenState.depCandidates, mctx.ModuleName()) {
installPartition := m.PartitionTag(mctx.DeviceConfig())
- fsGenState.fsDepsMutex.Lock()
// Only add the module as dependency when:
// - its enabled
// - its namespace is included in PRODUCT_SOONG_NAMESPACES
if m.Enabled(mctx) && m.ExportedToMake() {
appendDepIfAppropriate(mctx, fsGenState.fsDeps[installPartition], installPartition)
}
- fsGenState.fsDepsMutex.Unlock()
}
// store the map of module to (required,overrides) even if the module is not in PRODUCT_PACKAGES.
// the module might be installed transitively.
- if m.Target().Os.Class == android.Device && m.Enabled(mctx) && m.ExportedToMake() {
- fsGenState.fsDepsMutex.Lock()
+ if m.Enabled(mctx) && m.ExportedToMake() {
fsGenState.moduleToInstallationProps[m.Name()] = installationProperties{
Required: m.RequiredModuleNames(mctx),
Overrides: m.Overrides(),
}
- fsGenState.fsDepsMutex.Unlock()
}
}
@@ -324,12 +328,21 @@
var HighPriorityDeps = []string{}
+func isHighPriorityDep(depName string) bool {
+ for _, highPriorityDeps := range HighPriorityDeps {
+ if strings.HasPrefix(depName, highPriorityDeps) {
+ return true
+ }
+ }
+ return false
+}
+
func generateDepStruct(deps map[string]*depCandidateProps) *packagingPropsStruct {
depsStruct := packagingPropsStruct{}
for depName, depProps := range deps {
bitness := getBitness(depProps.Arch)
fullyQualifiedDepName := fullyQualifiedModuleName(depName, depProps.Namespace)
- if android.InList(depName, HighPriorityDeps) {
+ if isHighPriorityDep(depName) {
depsStruct.High_priority_deps = append(depsStruct.High_priority_deps, fullyQualifiedDepName)
} else if android.InList("32", bitness) && android.InList("64", bitness) {
// If both 32 and 64 bit variants are enabled for this module
diff --git a/fsgen/prebuilt_etc_modules_gen.go b/fsgen/prebuilt_etc_modules_gen.go
index 362ac31..cbcd4a1 100644
--- a/fsgen/prebuilt_etc_modules_gen.go
+++ b/fsgen/prebuilt_etc_modules_gen.go
@@ -85,15 +85,25 @@
}
}
-func uniqueExistingProductCopyFileMap(ctx android.LoadHookContext) map[string]string {
+// Create a map of source files to the list of destination files from PRODUCT_COPY_FILES entries.
+// Note that the value of the map is a list of string, given that a single source file can be
+// copied to multiple files.
+// This function also checks the existence of the source files, and validates that there is no
+// multiple source files copying to the same dest file.
+func uniqueExistingProductCopyFileMap(ctx android.LoadHookContext) map[string][]string {
seen := make(map[string]bool)
- filtered := make(map[string]string)
+ filtered := make(map[string][]string)
- for src, dest := range ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.ProductCopyFiles {
+ for _, copyFilePair := range ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.ProductCopyFiles {
+ srcDestList := strings.Split(copyFilePair, ":")
+ if len(srcDestList) < 2 {
+ ctx.ModuleErrorf("PRODUCT_COPY_FILES must follow the format \"src:dest\", got: %s", copyFilePair)
+ }
+ src, dest := srcDestList[0], srcDestList[1]
if _, ok := seen[dest]; !ok {
if optionalPath := android.ExistentPathForSource(ctx, src); optionalPath.Valid() {
seen[dest] = true
- filtered[src] = dest
+ filtered[src] = append(filtered[src], dest)
}
}
}
@@ -121,12 +131,14 @@
groupedSources := map[string]*prebuiltSrcGroupByInstallPartition{}
for _, src := range android.SortedKeys(productCopyFileMap) {
- dest := productCopyFileMap[src]
+ destFiles := productCopyFileMap[src]
srcFileDir := filepath.Dir(src)
if _, ok := groupedSources[srcFileDir]; !ok {
groupedSources[srcFileDir] = newPrebuiltSrcGroupByInstallPartition()
}
- appendIfCorrectInstallPartition(partitionToInstallPathList, dest, filepath.Base(src), groupedSources[srcFileDir])
+ for _, dest := range destFiles {
+ appendIfCorrectInstallPartition(partitionToInstallPathList, dest, filepath.Base(src), groupedSources[srcFileDir])
+ }
}
return groupedSources
@@ -195,12 +207,9 @@
}
)
-func createPrebuiltEtcModule(ctx android.LoadHookContext, partition, srcDir, destDir string, destFiles []srcBaseFileInstallBaseFileTuple) string {
- moduleProps := &prebuiltModuleProperties{}
- propsList := []interface{}{moduleProps}
-
+func generatedPrebuiltEtcModuleName(partition, srcDir, destDir string, count int) string {
// generated module name follows the pattern:
- // <install partition>-<src file path>-<relative install path from partition root>-<install file extension>
+ // <install partition>-<src file path>-<relative install path from partition root>-<number>
// Note that all path separators are replaced with "_" in the name
moduleName := partition
if !android.InList(srcDir, []string{"", "."}) {
@@ -209,33 +218,27 @@
if !android.InList(destDir, []string{"", "."}) {
moduleName += fmt.Sprintf("-%s", strings.ReplaceAll(destDir, string(filepath.Separator), "_"))
}
- if len(destFiles) > 0 {
- if ext := filepath.Ext(destFiles[0].srcBaseFile); ext != "" {
- moduleName += fmt.Sprintf("-%s", strings.TrimPrefix(ext, "."))
- }
- }
- moduleProps.Name = proptools.StringPtr(moduleName)
+ moduleName += fmt.Sprintf("-%d", count)
- allCopyFileNamesUnchanged := true
- var srcBaseFiles, installBaseFiles []string
+ return moduleName
+}
+
+func groupDestFilesBySrc(destFiles []srcBaseFileInstallBaseFileTuple) (ret map[string][]srcBaseFileInstallBaseFileTuple, maxLen int) {
+ ret = map[string][]srcBaseFileInstallBaseFileTuple{}
+ maxLen = 0
for _, tuple := range destFiles {
- if tuple.srcBaseFile != tuple.installBaseFile {
- allCopyFileNamesUnchanged = false
+ if _, ok := ret[tuple.srcBaseFile]; !ok {
+ ret[tuple.srcBaseFile] = []srcBaseFileInstallBaseFileTuple{}
}
- srcBaseFiles = append(srcBaseFiles, tuple.srcBaseFile)
- installBaseFiles = append(installBaseFiles, tuple.installBaseFile)
+ ret[tuple.srcBaseFile] = append(ret[tuple.srcBaseFile], tuple)
+ maxLen = max(maxLen, len(ret[tuple.srcBaseFile]))
}
+ return ret, maxLen
+}
- // Find out the most appropriate module type to generate
- var etcInstallPathKey string
- for _, etcInstallPath := range android.SortedKeys(etcInstallPathToFactoryList) {
- // Do not break when found but iterate until the end to find a module with more
- // specific install path
- if strings.HasPrefix(destDir, etcInstallPath) {
- etcInstallPathKey = etcInstallPath
- }
- }
- destDir, _ = filepath.Rel(etcInstallPathKey, destDir)
+func prebuiltEtcModuleProps(moduleName, partition string) prebuiltModuleProperties {
+ moduleProps := prebuiltModuleProperties{}
+ moduleProps.Name = proptools.StringPtr(moduleName)
// Set partition specific properties
switch partition {
@@ -247,39 +250,81 @@
moduleProps.Soc_specific = proptools.BoolPtr(true)
}
- // Set appropriate srcs, dsts, and releative_install_path based on
- // the source and install file names
- if allCopyFileNamesUnchanged {
- moduleProps.Srcs = srcBaseFiles
-
- // Specify relative_install_path if it is not installed in the root directory of the
- // partition
- if !android.InList(destDir, []string{"", "."}) {
- propsList = append(propsList, &prebuiltSubdirProperties{
- Relative_install_path: proptools.StringPtr(destDir),
- })
- }
- } else {
- moduleProps.Srcs = srcBaseFiles
- dsts := []string{}
- for _, installBaseFile := range installBaseFiles {
- dsts = append(dsts, filepath.Join(destDir, installBaseFile))
- }
- moduleProps.Dsts = dsts
- }
-
moduleProps.No_full_install = proptools.BoolPtr(true)
moduleProps.NamespaceExportedToMake = true
moduleProps.Visibility = []string{"//visibility:public"}
- ctx.CreateModuleInDirectory(etcInstallPathToFactoryList[etcInstallPathKey], srcDir, propsList...)
+ return moduleProps
+}
- return moduleName
+func createPrebuiltEtcModulesInDirectory(ctx android.LoadHookContext, partition, srcDir, destDir string, destFiles []srcBaseFileInstallBaseFileTuple) (moduleNames []string) {
+ groupedDestFiles, maxLen := groupDestFilesBySrc(destFiles)
+
+ // Find out the most appropriate module type to generate
+ var etcInstallPathKey string
+ for _, etcInstallPath := range android.SortedKeys(etcInstallPathToFactoryList) {
+ // Do not break when found but iterate until the end to find a module with more
+ // specific install path
+ if strings.HasPrefix(destDir, etcInstallPath) {
+ etcInstallPathKey = etcInstallPath
+ }
+ }
+ relDestDirFromInstallDirBase, _ := filepath.Rel(etcInstallPathKey, destDir)
+
+ for fileIndex := range maxLen {
+ srcTuple := []srcBaseFileInstallBaseFileTuple{}
+ for _, groupedDestFile := range groupedDestFiles {
+ if len(groupedDestFile) > fileIndex {
+ srcTuple = append(srcTuple, groupedDestFile[fileIndex])
+ }
+ }
+
+ moduleName := generatedPrebuiltEtcModuleName(partition, srcDir, destDir, fileIndex)
+ moduleProps := prebuiltEtcModuleProps(moduleName, partition)
+ modulePropsPtr := &moduleProps
+ propsList := []interface{}{modulePropsPtr}
+
+ allCopyFileNamesUnchanged := true
+ var srcBaseFiles, installBaseFiles []string
+ for _, tuple := range srcTuple {
+ if tuple.srcBaseFile != tuple.installBaseFile {
+ allCopyFileNamesUnchanged = false
+ }
+ srcBaseFiles = append(srcBaseFiles, tuple.srcBaseFile)
+ installBaseFiles = append(installBaseFiles, tuple.installBaseFile)
+ }
+
+ // Set appropriate srcs, dsts, and releative_install_path based on
+ // the source and install file names
+ if allCopyFileNamesUnchanged {
+ modulePropsPtr.Srcs = srcBaseFiles
+
+ // Specify relative_install_path if it is not installed in the root directory of the
+ // partition
+ if !android.InList(relDestDirFromInstallDirBase, []string{"", "."}) {
+ propsList = append(propsList, &prebuiltSubdirProperties{
+ Relative_install_path: proptools.StringPtr(relDestDirFromInstallDirBase),
+ })
+ }
+ } else {
+ modulePropsPtr.Srcs = srcBaseFiles
+ dsts := []string{}
+ for _, installBaseFile := range installBaseFiles {
+ dsts = append(dsts, filepath.Join(relDestDirFromInstallDirBase, installBaseFile))
+ }
+ modulePropsPtr.Dsts = dsts
+ }
+
+ ctx.CreateModuleInDirectory(etcInstallPathToFactoryList[etcInstallPathKey], srcDir, propsList...)
+ moduleNames = append(moduleNames, moduleName)
+ }
+
+ return moduleNames
}
func createPrebuiltEtcModulesForPartition(ctx android.LoadHookContext, partition, srcDir string, destDirFilesMap map[string][]srcBaseFileInstallBaseFileTuple) (ret []string) {
for _, destDir := range android.SortedKeys(destDirFilesMap) {
- ret = append(ret, createPrebuiltEtcModule(ctx, partition, srcDir, destDir, destDirFilesMap[destDir]))
+ ret = append(ret, createPrebuiltEtcModulesInDirectory(ctx, partition, srcDir, destDir, destDirFilesMap[destDir])...)
}
return ret
}
diff --git a/fsgen/vbmeta_partitions.go b/fsgen/vbmeta_partitions.go
index 280e405..f7b4638 100644
--- a/fsgen/vbmeta_partitions.go
+++ b/fsgen/vbmeta_partitions.go
@@ -156,6 +156,10 @@
// Already handled by a chained vbmeta partition
continue
}
+ if partitionType == "ramdisk" {
+ // ramdisk is never signed with avb information
+ continue
+ }
partitionModules = append(partitionModules, generatedModuleNameForPartition(ctx.Config(), partitionType))
}
diff --git a/kernel/prebuilt_kernel_modules.go b/kernel/prebuilt_kernel_modules.go
index 78a463f..13d6482 100644
--- a/kernel/prebuilt_kernel_modules.go
+++ b/kernel/prebuilt_kernel_modules.go
@@ -56,6 +56,8 @@
// This feature is used by system_dlkm
Load_by_default *bool
+ Blocklist_file *string `android:"path"`
+
// Kernel version that these modules are for. Kernel modules are installed to
// /lib/modules/<kernel_version> directory in the corresponding partition. Default is "".
Kernel_version *string
@@ -109,10 +111,25 @@
ctx.InstallFile(installDir, "modules.dep", depmodOut.modulesDep)
ctx.InstallFile(installDir, "modules.softdep", depmodOut.modulesSoftdep)
ctx.InstallFile(installDir, "modules.alias", depmodOut.modulesAlias)
+ pkm.installBlocklistFile(ctx, installDir)
ctx.SetOutputFiles(modules, ".modules")
}
+func (pkm *prebuiltKernelModules) installBlocklistFile(ctx android.ModuleContext, installDir android.InstallPath) {
+ if pkm.properties.Blocklist_file == nil {
+ return
+ }
+ blocklistOut := android.PathForModuleOut(ctx, "modules.blocklist")
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: processBlocklistFile,
+ Input: android.PathForModuleSrc(ctx, proptools.String(pkm.properties.Blocklist_file)),
+ Output: blocklistOut,
+ })
+ ctx.InstallFile(installDir, "modules.blocklist", blocklistOut)
+}
+
var (
pctx = android.NewPackageContext("android/soong/kernel")
@@ -159,6 +176,19 @@
Command: `sed -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $in > $out`,
},
)
+ // Remove empty lines. Raise an exception if line is _not_ formatted as `blocklist $name.ko`
+ processBlocklistFile = pctx.AndroidStaticRule("process_blocklist_file",
+ blueprint.RuleParams{
+ Command: `rm -rf $out && awk <$in > $out` +
+ ` '/^#/ { print; next }` +
+ ` NF == 0 { next }` +
+ ` NF != 2 || $$1 != "blocklist"` +
+ ` { print "Invalid blocklist line " FNR ": " $$0 >"/dev/stderr";` +
+ ` exit_status = 1; next }` +
+ ` { $$1 = $$1; print }` +
+ ` END { exit exit_status }'`,
+ },
+ )
)
// This is the path in soong intermediates where the .ko files will be copied.