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()))