Add a simple metadata class option for system feature codegen

Add a `metadata_only` arg to the java_system_features_srcs rule
to optionally generate a very slimmed down output that maps
feature names to their new method names in the generated API surface.

This is useful for tooling like errorprone/lint to ensure any fixes
are correct, without pulling in the full codegen API surface.

Bug: 203143243
Test: m
Flag: build.RELEASE_USE_SYSTEM_FEATURE_BUILD_FLAGS
Change-Id: Ic9ec70d09cf2cfb11f9de939305dfa67ee4e28ae
diff --git a/systemfeatures/system_features.go b/systemfeatures/system_features.go
index 0c1a566..b8dacfb 100644
--- a/systemfeatures/system_features.go
+++ b/systemfeatures/system_features.go
@@ -20,6 +20,8 @@
 
 	"android/soong/android"
 	"android/soong/genrule"
+
+	"github.com/google/blueprint/proptools"
 )
 
 var (
@@ -39,6 +41,11 @@
 	properties struct {
 		// The fully qualified class name for the generated code, e.g., com.android.Foo
 		Full_class_name string
+		// Whether to generate only a simple metadata class with details about the full API surface.
+		// This is useful for tools that rely on the mapping from feature names to their generated
+		// method names, but don't want the fully generated API class (e.g., for linting).
+
+		Metadata_only *bool
 	}
 	outputFiles android.WritablePaths
 }
@@ -72,6 +79,7 @@
 		Flag(m.properties.Full_class_name).
 		FlagForEachArg("--feature=", features).
 		FlagWithArg("--readonly=", fmt.Sprint(ctx.Config().ReleaseUseSystemFeatureBuildFlags())).
+		FlagWithArg("--metadata-only=", fmt.Sprint(proptools.Bool(m.properties.Metadata_only))).
 		FlagWithOutput(" > ", outputFile)
 	rule.Build(ctx.ModuleName(), "Generating systemfeatures srcs filegroup")
 
@@ -97,6 +105,7 @@
 func JavaSystemFeaturesSrcsFactory() android.Module {
 	module := &javaSystemFeaturesSrcs{}
 	module.AddProperties(&module.properties)
+	module.properties.Metadata_only = proptools.BoolPtr(false)
 	android.InitAndroidModule(module)
 	return module
 }