From 9a24d909369ae20566c85dfbfe8b14054ed6dd5d Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Mon, 18 Mar 2024 15:38:12 -0700 Subject: Add more specific partition visibility rules //visibility:any_system_partition, //visibility:any_vendor_partition, etc. Then, if a partition visibility rule is not specificed, but the module is installed on a non-system partition via the `vendor: true` or other properties, the visibility rule for that partition will be added by default. This is so that "any_partition" doesn't imply that modules could be put on the vendor partition when they weren't designed for that, and so that modules that do need to go on the vendor partition don't need to specify both vendor: true and visibility:any_vendor_partition. Eventually, the partition properties should be deprecated, and replaced with just these visibility rules. Bug: 321000103 Test: go tests Change-Id: I24dba36bbc20921941f892480bf7c050e93827c6 --- filesystem/filesystem.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'filesystem/filesystem.go') diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 64a2e235f..efc889ccb 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -88,6 +88,10 @@ type filesystemProperties struct { // is ext4. Type *string + // Identifies which partition this is for //visibility:any_system_image (and others) visibility + // checks, and will be used in the future for API surface checks. + Partition_type *string + // file_contexts file to make image. Currently, only ext4 is supported. File_contexts *string `android:"path"` @@ -175,6 +179,9 @@ func (f *filesystem) installFileName() string { var pctx = android.NewPackageContext("android/soong/filesystem") func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { + if !android.InList(f.PartitionType(), validPartitions) { + ctx.PropertyErrorf("partition_type", "partition_type must be one of %s, found: %s", validPartitions, f.PartitionType()) + } switch f.fsType(ctx) { case ext4Type: f.output = f.buildImageUsingBuildImage(ctx) @@ -441,6 +448,10 @@ func (f *filesystem) addMakeBuiltFiles(ctx android.ModuleContext, builder *andro Text(android.PathForArbitraryOutput(ctx, stagingDir).String()) } +func (f *filesystem) PartitionType() string { + return proptools.StringDefault(f.properties.Partition_type, "system") +} + var _ android.AndroidMkEntriesProvider = (*filesystem)(nil) // Implements android.AndroidMkEntriesProvider -- cgit v1.2.3-59-g8ed1b