Build scope targets corresponding to each module sdk.
In order to detect the addition of any new APIs in any mainline module, an API diff file (current module sdk vs the last finalized module sdk) needs to be generated correpsonding to each module sdk. To obtain the list of APIs in the last finalized module sdk, the latest build targets correpsonding to each scope of each module sdk are obtained and needs to be built. This CL is fetching all the module sdk scope targets from the .info file corresponding to each module sdk file and then building all those targets. This CL is also adding changes to the test file mainline_modules_sdks_test.py to mock the generation of module sdk snapshot info files and the latest api text files for module sdk scope targets. The follow up CLs will generate the API diff files corresponding to each module sdk and copy that to the out/dist directory. And will also contain the tests to verify the generation of api diff files. Bug: 230609867 Test: build packages/modules/common/build/mainline_modules_sdks.py successfully and builds all the scope targets for each module sdk. "atest mainline_modules_sdks_test" passes Change-Id: I9e0c08d3a8bbf60e9b5cb61389c155948c4c171e
This commit is contained in:
@@ -74,6 +74,59 @@ class FakeSnapshotBuilder(mm.SnapshotBuilder):
|
||||
module.for_r_build)
|
||||
return sdks_out_dir
|
||||
|
||||
def get_art_module_info_file_data(self):
|
||||
info_file_data = f"""[
|
||||
{{
|
||||
"@type": "java_sdk_library",
|
||||
"@name": "art.module.public.api",
|
||||
"@deps": [
|
||||
"libcore_license"
|
||||
],
|
||||
"dist_stem": "art",
|
||||
"scopes": {{
|
||||
"public": {{
|
||||
"current_api": "sdk_library/public/art.module.public.api.txt",
|
||||
"latest_api": "{Path(self.mainline_sdks_dir).joinpath("test")}/prebuilts/sdk/art.api.public.latest/gen/art.api.public.latest",
|
||||
"latest_removed_api": "{Path(self.mainline_sdks_dir).joinpath("test")}/prebuilts/sdk/art-removed.api.public.latest/gen/art-removed.api.public.latest",
|
||||
"removed_api": "sdk_library/public/art.module.public.api-removed.txt"
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
]
|
||||
"""
|
||||
return info_file_data
|
||||
|
||||
@staticmethod
|
||||
def write_data_to_file(file, data):
|
||||
with open(file, "w") as file:
|
||||
file.write(data)
|
||||
|
||||
def create_snapshot_info_file(self, module, sdk_info_file):
|
||||
if module == MAINLINE_MODULES_BY_APEX["com.android.art"]:
|
||||
self.write_data_to_file(sdk_info_file,
|
||||
self.get_art_module_info_file_data())
|
||||
else:
|
||||
# For rest of the modules, generate an empty .info file.
|
||||
self.write_data_to_file(sdk_info_file, "[]")
|
||||
|
||||
def build_sdk_scope_targets(self, build_release, sdk_version, modules):
|
||||
target_paths = []
|
||||
for module in modules:
|
||||
for sdk in module.sdks:
|
||||
if "host-exports" in sdk or "test-exports" in sdk:
|
||||
continue
|
||||
|
||||
sdk_info_file = mm.sdk_snapshot_info_file(
|
||||
Path(self.mainline_sdks_dir).joinpath("test"), sdk,
|
||||
sdk_version)
|
||||
self.create_snapshot_info_file(module, sdk_info_file)
|
||||
target_paths.extend(self.latest_api_file_targets(sdk_info_file))
|
||||
|
||||
for target_path in target_paths:
|
||||
os.makedirs(os.path.split(target_path)[0])
|
||||
self.write_data_to_file(target_path, "")
|
||||
# TODO(b/230609867): Add test to verify api diff file generation.
|
||||
|
||||
|
||||
class TestProduceDist(unittest.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user