aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild/mainline_modules_sdks.py43
-rw-r--r--build/mainline_modules_sdks_test.py89
2 files changed, 130 insertions, 2 deletions
diff --git a/build/mainline_modules_sdks.py b/build/mainline_modules_sdks.py
index 169c515c..1707aa95 100755
--- a/build/mainline_modules_sdks.py
+++ b/build/mainline_modules_sdks.py
@@ -472,7 +472,8 @@ java_sdk_library_import {{
@staticmethod
def does_sdk_library_support_latest_api(sdk_library):
- if sdk_library == "conscrypt.module.platform.api":
+ if sdk_library == "conscrypt.module.platform.api" or \
+ sdk_library == "conscrypt.module.intra.core.api":
return False
return True
@@ -503,6 +504,10 @@ java_sdk_library_import {{
target_dict[sdk_library][scope][target] = scope_json[target]
target_paths.append(scope_json["latest_api"])
target_paths.append(scope_json["latest_removed_api"])
+ target_paths.append(scope_json["latest_api"]
+ .replace(".latest", ".latest.extension_version"))
+ target_paths.append(scope_json["latest_removed_api"]
+ .replace(".latest", ".latest.extension_version"))
return target_paths, target_dict
@@ -560,6 +565,7 @@ java_sdk_library_import {{
with open(
sdk_api_diff_file, "w",
encoding="utf8") as sdk_api_diff_file_object:
+ last_finalized_version_set = set()
for sdk_library in target_dict[sdk_info_file]:
for scope in target_dict[sdk_info_file][sdk_library]:
scope_json = target_dict[sdk_info_file][sdk_library][scope]
@@ -575,6 +581,33 @@ java_sdk_library_import {{
sdk_zip_file, removed_api,
latest_removed_api, snapshots_dir)
+ def read_extension_version(target):
+ extension_target = target.replace(
+ ".latest", ".latest.extension_version")
+ with open(
+ extension_target, "r", encoding="utf8") as file:
+ version = int(file.read())
+ # version equal to -1 means "not an extension version".
+ if version != -1:
+ last_finalized_version_set.add(version)
+
+ read_extension_version(scope_json["latest_api"])
+ read_extension_version(scope_json["latest_removed_api"])
+
+ if len(last_finalized_version_set) == 0:
+ # Either there is no java sdk library or all java sdk libraries
+ # have not been finalized in sdk extensions yet and hence have
+ # last finalized version set as -1.
+ gantry_metadata_dict["last_finalized_version"] = -1
+ elif len(last_finalized_version_set) == 1:
+ # All java sdk library extension version match.
+ gantry_metadata_dict["last_finalized_version"] =\
+ last_finalized_version_set.pop()
+ else:
+ # Fail the build
+ raise ValueError(
+ "Not all sdk libraries finalized with the same version.\n")
+
gantry_metadata_dict["api_diff_file"] = sdk_api_diff_file.rsplit(
"/", 1)[-1]
gantry_metadata_dict["api_diff_file_size"] = os.path.getsize(
@@ -1221,6 +1254,13 @@ class SdkDistProducer:
shutil.copy(sdk_gantry_metadata_json_path,
sdk_dist_gantry_metadata_json_path)
+ def dist_generate_sdk_supported_modules_file(self, modules):
+ sdk_modules_file = os.path.join(self.dist_dir, "sdk-modules.txt")
+ with open(sdk_modules_file, "w", encoding="utf8") as file:
+ for module in modules:
+ if module in MAINLINE_MODULES:
+ file.write(aosp_to_google_name(module.apex) + "\n")
+
def populate_unbundled_dist(self, build_release, modules, snapshots_dir):
build_release_dist_dir = os.path.join(self.mainline_sdks_dir,
build_release.sub_dir)
@@ -1484,6 +1524,7 @@ def main(args):
modules += PLATFORM_SDKS_FOR_MAINLINE
producer = create_producer(args.tool_path)
+ producer.dist_generate_sdk_supported_modules_file(modules)
producer.produce_dist(modules, build_releases)
diff --git a/build/mainline_modules_sdks_test.py b/build/mainline_modules_sdks_test.py
index 2131a602..c9e57764 100644
--- a/build/mainline_modules_sdks_test.py
+++ b/build/mainline_modules_sdks_test.py
@@ -130,7 +130,11 @@ class FakeSnapshotBuilder(mm.SnapshotBuilder):
for target_path in target_paths:
os.makedirs(os.path.split(target_path)[0])
- self.write_data_to_file(target_path, "")
+ if ".latest.extension_version" in target_path:
+ self.write_data_to_file(
+ target_path, str(self.get_module_extension_version()))
+ else:
+ self.write_data_to_file(target_path, "")
return target_dict
@@ -343,6 +347,11 @@ class TestProduceDist(unittest.TestCase):
5,
msg="The module extension version does not match the expected value."
)
+ self.assertEqual(
+ json_data["last_finalized_version"],
+ 5,
+ msg="The last finalized version does not match the expected value."
+ )
def create_build_number_file(self):
soong_dir = os.path.join(self.tmp_out_dir, "soong")
@@ -410,6 +419,84 @@ class TestProduceDist(unittest.TestCase):
),
], snapshot_builder.snapshots)
+ def test_generate_sdk_supported_modules_file(self):
+ subprocess_runner = mm.SubprocessRunner()
+ snapshot_builder = FakeSnapshotBuilder(
+ tool_path="path/to/mainline_modules_sdks.sh",
+ subprocess_runner=subprocess_runner,
+ out_dir=self.tmp_out_dir,
+ )
+ producer = mm.SdkDistProducer(
+ subprocess_runner=subprocess_runner,
+ snapshot_builder=snapshot_builder,
+ dist_dir=self.tmp_dist_dir,
+ )
+ producer = mm.SdkDistProducer(
+ subprocess_runner=subprocess_runner,
+ snapshot_builder=snapshot_builder,
+ dist_dir=self.tmp_dist_dir,
+ )
+
+ # Contains only sdk modules.
+ modules = [
+ MAINLINE_MODULES_BY_APEX["com.android.adservices"],
+ MAINLINE_MODULES_BY_APEX["com.android.art"],
+ MAINLINE_MODULES_BY_APEX["com.android.mediaprovider"],
+ ]
+ producer.dist_generate_sdk_supported_modules_file(modules)
+ with open(os.path.join(self.tmp_dist_dir, "sdk-modules.txt"), "r",
+ encoding="utf8") as sdk_modules_file:
+ sdk_modules = sdk_modules_file.readlines()
+
+ self.assertTrue("com.google.android.adservices\n" in sdk_modules)
+ self.assertTrue("com.google.android.art\n" in sdk_modules)
+ self.assertTrue("com.google.android.mediaprovider\n" in sdk_modules)
+
+ # Contains only non-sdk modules.
+ modules = [
+ mm.MainlineModule(
+ apex="com.android.adbd",
+ sdks=[],
+ first_release="",
+ ),
+ mm.MainlineModule(
+ apex="com.android.adbd",
+ sdks=[],
+ first_release="",
+ ),
+ ]
+ producer.dist_generate_sdk_supported_modules_file(modules)
+ with open(os.path.join(self.tmp_dist_dir, "sdk-modules.txt"), "r",
+ encoding="utf8") as sdk_modules_file:
+ sdk_modules = sdk_modules_file.readlines()
+
+ self.assertEqual(len(sdk_modules), 0)
+
+ # Contains mixture of sdk and non-sdk modules.
+ modules = [
+ MAINLINE_MODULES_BY_APEX["com.android.adservices"],
+ MAINLINE_MODULES_BY_APEX["com.android.mediaprovider"],
+ mm.MainlineModule(
+ apex="com.android.adbd",
+ sdks=[],
+ first_release="",
+ ),
+ mm.MainlineModule(
+ apex="com.android.adbd",
+ sdks=[],
+ first_release="",
+ ),
+ ]
+ producer.dist_generate_sdk_supported_modules_file(modules)
+ with open(os.path.join(self.tmp_dist_dir, "sdk-modules.txt"), "r",
+ encoding="utf8") as sdk_modules_file:
+ sdk_modules = sdk_modules_file.readlines()
+
+ self.assertTrue("com.google.android.adservices\n" in sdk_modules)
+ self.assertTrue("com.google.android.mediaprovider\n" in sdk_modules)
+ self.assertFalse("com.google.android.adbd\n" in sdk_modules)
+ self.assertFalse("com.google.android.extservices\n" in sdk_modules)
+
def path_to_test_data(relative_path):
"""Construct a path to a test data file.