Adding additional_transformations

Add additional_transformations for module sdk build. This feature is
only supported by S+ releases.

Bug: 254111089
Test: atest mainline_modules_sdks_test --host
Ignore-AOSP-First: Check into internal branch first to make sure all
testing works.

Change-Id: I94989519011e31c7db33656c6730c4f8fd5e0a4f
This commit is contained in:
Zhi Dou
2023-03-17 16:20:59 +00:00
parent 3f18d87e1a
commit c04c32fec1
3 changed files with 121 additions and 4 deletions

View File

@@ -117,10 +117,6 @@ class SoongConfigBoilerplateInserter(SoongConfigVarTransformation):
def config_module_type(self, module_type):
return self.configModuleTypePrefix + module_type
def apply(self, producer, path, build_release):
with open(path, "r+", encoding="utf8") as file:
self._apply_transformation(producer, file, build_release)
def _apply_transformation(self, producer, file, build_release):
# TODO(b/174997203): Remove this when we have a proper way to control
# prefer flags in Mainline modules.
@@ -857,6 +853,9 @@ class MainlineModule:
# Defaults to the last part of the apex name.
short_name: str = ""
# Additional transformations
additional_transformations: list[FileTransformation] = None
def __post_init__(self):
# If short_name is not set then set it to the last component of the apex
# name.
@@ -898,6 +897,9 @@ class MainlineModule:
"Android.bp", configVar=config_var)
transformations.append(transformation)
if self.additional_transformations and build_release > R:
transformations.extend(self.additional_transformations)
return transformations
def is_required_for(self, target_build_release):