From 593ce4d22aaf342a53400725efe2da84c4e61407 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Wed, 21 Sep 2022 16:18:28 +0000 Subject: [PATCH] Deal with inconsistent module names Conscrypt and ART have some history of using dist_stem names in prebuilts/sdk that are different from the module names of their java_sdk_library, leading to same naming inconsistensies. Update the finalize script to reconcile these inconsistensies during import. Note that the build has already been updated to throw an error when inconsistensies are discovered, so this update to the script is to make sure the next import of conscrypt/art goes smoothly. Test: finalize_sdk.py with conscrypt/art Change-Id: If82fadf73d508d4807aef11b960e0860d54874b7 --- tools/finalize_sdk.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/finalize_sdk.py b/tools/finalize_sdk.py index 32b2fb7..583db02 100755 --- a/tools/finalize_sdk.py +++ b/tools/finalize_sdk.py @@ -76,6 +76,21 @@ def dir_for_sdk(filename, version): return os.path.join(base, 'host-exports') return base +def is_txt_ignored(txt_file): + # Conscrypt has some legacy API tracking files that we don't consider for extensions. + bad_stem_prefixes = ['conscrypt.module.intra.core.api', 'conscrypt.module.platform.api'] + return any([txt_file.stem.startswith(p) for p in bad_stem_prefixes]) + + +def maybe_tweak_compat_txt_stem(txt_file): + # For legacy reasons, art and conscrypt txt file names in the SDKs (*.module.public.api) + # do not match their expected filename in prebuilts/sdk (art, conscrypt). So rename them + # to match. + new_stem = txt_file.stem + new_stem = new_stem.replace('art.module.public.api', 'art') + new_stem = new_stem.replace('conscrypt.module.public.api', 'conscrypt') + return txt_file.with_stem(new_stem) + if not os.path.isdir('build/soong'): fail("This script must be run from the top of an Android source tree.") @@ -121,10 +136,13 @@ for m in module_names: # Copy api txt files to compat tracking dir txt_files = [Path(p) for p in glob.glob(os.path.join(target_dir, 'sdk_library/*/*.txt'))] for txt_file in txt_files: + if is_txt_ignored(txt_file): + continue api_type = txt_file.parts[-2] dest_dir = compat_dir.joinpath(api_type, 'api') + dest_file = maybe_tweak_compat_txt_stem(dest_dir.joinpath(txt_file.name)) os.makedirs(dest_dir, exist_ok = True) - shutil.copy(txt_file, dest_dir) + shutil.copy(txt_file, dest_file) created_dirs[COMPAT_REPO].add(dest_dir.relative_to(COMPAT_REPO)) subprocess.check_output(['repo', 'start', branch_name] + list(created_dirs.keys()))