summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jared Duke <jdduke@google.com> 2024-10-25 23:02:31 +0000
committer Jared Duke <jdduke@google.com> 2024-11-07 23:00:58 +0000
commite74b960858b25d00f1dc0e50ccbc820e4c9909dd (patch)
tree91455735c3f0fd28bc6136a01882b9523d86154d
parent2a9533b2c6ecb9ad89dbdffb6acce4c3f019436b (diff)
Pipe system feature build flags into codegen
Route build flag values for currently defined features into the systemfeature codegen tool. Their impact on codegen is still conditioned on the RELEASE_USE_SYSTEM_FEATURE_BUILD_FLAGS flag. A follow-up change will simplify this by aggregating all such flags in a native soong module that feeds directly into the codegen tool. For now, we have a relatively small list of build-time defined features, but additions will remain tedious until we do automatic aggregation. Flag: build.RELEASE_USE_SYSTEM_FEATURE_BUILD_FLAGS Bug: 203143243 Test: m framework Change-Id: Iffc607fdcbe99216829b4b01b6c922d8d66ef1ea
-rw-r--r--core/java/Android.bp25
-rw-r--r--tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt2
2 files changed, 21 insertions, 6 deletions
diff --git a/core/java/Android.bp b/core/java/Android.bp
index 7e8a3091ff2a..3f6e65b95c93 100644
--- a/core/java/Android.bp
+++ b/core/java/Android.bp
@@ -649,16 +649,31 @@ gen_readonly_feature_apis = select(release_flag("RELEASE_USE_SYSTEM_FEATURE_BUIL
// Generates com.android.internal.pm.RoSystemFeatures, optionally compiling in
// details about fixed system features defined by build flags. When disabled,
// the APIs are simply passthrough stubs with no meaningful side effects.
+// TODO(b/203143243): Implement the `--feature=` aggregation directly with a native soong module.
genrule {
name: "systemfeatures-gen-srcs",
cmd: "$(location systemfeatures-gen-tool) com.android.internal.pm.RoSystemFeatures " +
// --readonly=false (default) makes the codegen an effective no-op passthrough API.
" --readonly=" + gen_readonly_feature_apis +
- // For now, only export "android.hardware.type.*" system features APIs.
- // TODO(b/203143243): Use an intermediate soong var that aggregates all declared
- // RELEASE_SYSTEM_FEATURE_* declarations into a single arg.
- " --feature-apis=AUTOMOTIVE,WATCH,TELEVISION,EMBEDDED,PC" +
- " > $(out)",
+ " --feature=AUTOMOTIVE:" + select(release_flag("RELEASE_SYSTEM_FEATURE_AUTOMOTIVE"), {
+ any @ value: value,
+ default: "",
+ }) + " --feature=EMBEDDED:" + select(release_flag("RELEASE_SYSTEM_FEATURE_EMBEDDED"), {
+ any @ value: value,
+ default: "",
+ }) + " --feature=LEANBACK:" + select(release_flag("RELEASE_SYSTEM_FEATURE_LEANBACK"), {
+ any @ value: value,
+ default: "",
+ }) + " --feature=PC:" + select(release_flag("RELEASE_SYSTEM_FEATURE_PC"), {
+ any @ value: value,
+ default: "",
+ }) + " --feature=TELEVISION:" + select(release_flag("RELEASE_SYSTEM_FEATURE_TELEVISION"), {
+ any @ value: value,
+ default: "",
+ }) + " --feature=WATCH:" + select(release_flag("RELEASE_SYSTEM_FEATURE_WATCH"), {
+ any @ value: value,
+ default: "",
+ }) + " > $(out)",
out: [
"RoSystemFeatures.java",
],
diff --git a/tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt b/tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt
index 1abe77fd3ceb..f260e2733843 100644
--- a/tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt
+++ b/tools/systemfeatures/src/com/android/systemfeatures/SystemFeaturesGenerator.kt
@@ -188,7 +188,7 @@ object SystemFeaturesGenerator {
?: throw IllegalArgumentException(
"Invalid feature version input for $name: ${featureArgs[1]}"
)
- FeatureInfo(name, featureArgs[1].toInt(), readonly = true)
+ FeatureInfo(name, featureVersion, readonly = true)
}
}
}