Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e74b9608 authored by Jared Duke's avatar Jared Duke
Browse files

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
parent 2a9533b2
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -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",
    ],
+1 −1
Original line number Diff line number Diff line
@@ -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)
            }
        }
    }