Deprecate compressed reference dumps
create_reference_dumps.py no longer supports compressing dumps because they cannot be reviewed or merged. Bug: 227282691 Test: development/vndk/tools/header-checker/utils/create_reference_dumps.py Change-Id: If4adccb865e3dba1e8045a6850478e46c9eae5de
This commit is contained in:
@@ -7,10 +7,9 @@ import shutil
|
||||
import time
|
||||
|
||||
from utils import (
|
||||
AOSP_DIR, COMPRESSED_SOURCE_ABI_DUMP_EXT, SOURCE_ABI_DUMP_EXT,
|
||||
SOURCE_ABI_DUMP_EXT_END, SO_EXT, Target, copy_reference_dump,
|
||||
find_lib_lsdumps, get_build_vars_for_product, make_libraries, make_tree,
|
||||
read_lsdump_paths)
|
||||
AOSP_DIR, SOURCE_ABI_DUMP_EXT, SOURCE_ABI_DUMP_EXT_END, SO_EXT, Target,
|
||||
copy_reference_dump, find_lib_lsdumps, get_build_vars_for_product,
|
||||
make_libraries, make_tree, read_lsdump_paths)
|
||||
|
||||
|
||||
PRODUCTS_DEFAULT = ['aosp_arm', 'aosp_arm64', 'aosp_x86', 'aosp_x86_64']
|
||||
@@ -52,28 +51,18 @@ def make_libs_for_product(libs, product, variant, vndk_version, targets):
|
||||
make_tree(product, variant)
|
||||
|
||||
|
||||
def find_and_remove_path(root_path, file_name=None):
|
||||
if file_name is not None:
|
||||
root_path = os.path.join(root_path, 'source-based', file_name)
|
||||
|
||||
if os.path.exists(root_path):
|
||||
print('removing', root_path)
|
||||
if os.path.isfile(root_path):
|
||||
os.remove(root_path)
|
||||
else:
|
||||
shutil.rmtree(root_path)
|
||||
|
||||
|
||||
def remove_reference_dumps(ref_dump_dir_stems, libs):
|
||||
for ref_dump_dir_stem in ref_dump_dir_stems:
|
||||
if libs:
|
||||
for lib in libs:
|
||||
find_and_remove_path(ref_dump_dir_stem,
|
||||
lib + SOURCE_ABI_DUMP_EXT)
|
||||
find_and_remove_path(ref_dump_dir_stem,
|
||||
lib + COMPRESSED_SOURCE_ABI_DUMP_EXT)
|
||||
else:
|
||||
find_and_remove_path(ref_dump_dir_stem)
|
||||
file_path = os.path.join(ref_dump_dir_stem, 'source-based',
|
||||
lib + SOURCE_ABI_DUMP_EXT)
|
||||
if os.path.isfile(file_path):
|
||||
print('removing', file_path)
|
||||
os.remove(file_path)
|
||||
elif os.path.isdir(ref_dump_dir_stem):
|
||||
print('removing', ref_dump_dir_stem)
|
||||
shutil.rmtree(ref_dump_dir_stem)
|
||||
|
||||
|
||||
def tag_to_dir_name(tag):
|
||||
@@ -87,7 +76,7 @@ def tag_to_dir_name(tag):
|
||||
|
||||
|
||||
def find_and_copy_lib_lsdumps(get_ref_dump_dir_stem, target, libs,
|
||||
lsdump_paths, compress):
|
||||
lsdump_paths):
|
||||
arch_lsdump_paths = find_lib_lsdumps(lsdump_paths, libs, target)
|
||||
|
||||
num_created = 0
|
||||
@@ -95,7 +84,7 @@ def find_and_copy_lib_lsdumps(get_ref_dump_dir_stem, target, libs,
|
||||
ref_dump_dir_stem = get_ref_dump_dir_stem(tag_to_dir_name(tag),
|
||||
target.get_arch_str())
|
||||
copy_reference_dump(
|
||||
path, os.path.join(ref_dump_dir_stem, 'source-based'), compress)
|
||||
path, os.path.join(ref_dump_dir_stem, 'source-based'))
|
||||
num_created += 1
|
||||
return num_created
|
||||
|
||||
@@ -109,8 +98,7 @@ def create_source_abi_reference_dumps(args, get_ref_dump_dir_stem,
|
||||
f'primary arch: {target.primary_arch}')
|
||||
|
||||
num_libs_copied += find_and_copy_lib_lsdumps(
|
||||
get_ref_dump_dir_stem, target, args.libs, lsdump_paths,
|
||||
args.compress)
|
||||
get_ref_dump_dir_stem, target, args.libs, lsdump_paths)
|
||||
return num_libs_copied
|
||||
|
||||
|
||||
@@ -200,7 +188,7 @@ def _parse_args():
|
||||
parser.add_argument('--build-variant', default='userdebug',
|
||||
help='build variant to create references for')
|
||||
parser.add_argument('--compress', action='store_true',
|
||||
help='compress reference dump with gzip')
|
||||
help=argparse.SUPPRESS)
|
||||
parser.add_argument('-ref-dump-dir',
|
||||
help='directory to copy reference abi dumps into')
|
||||
|
||||
@@ -211,6 +199,9 @@ def _parse_args():
|
||||
'the reference dump directory path. e.g., '
|
||||
'-ref-dump-dir prebuilts/abi-dumps/platform/current/64')
|
||||
|
||||
if args.compress:
|
||||
parser.error("Compressed reference dumps are deprecated.")
|
||||
|
||||
if args.libs:
|
||||
if any(lib_name.endswith(SOURCE_ABI_DUMP_EXT_END) or
|
||||
lib_name.endswith(SO_EXT) for lib_name in args.libs):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import gzip
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
@@ -29,7 +28,6 @@ BUILTIN_HEADERS_DIR = (
|
||||
SO_EXT = '.so'
|
||||
SOURCE_ABI_DUMP_EXT_END = '.lsdump'
|
||||
SOURCE_ABI_DUMP_EXT = SO_EXT + SOURCE_ABI_DUMP_EXT_END
|
||||
COMPRESSED_SOURCE_ABI_DUMP_EXT = SOURCE_ABI_DUMP_EXT + '.gz'
|
||||
VENDOR_SUFFIX = '.vendor'
|
||||
|
||||
DEFAULT_CPPFLAGS = ['-x', 'c++', '-std=c++11']
|
||||
@@ -98,19 +96,12 @@ def _validate_dump_content(dump_path):
|
||||
start += len(AOSP_DIR)
|
||||
|
||||
|
||||
def copy_reference_dump(lib_path, reference_dump_dir, compress):
|
||||
def copy_reference_dump(lib_path, reference_dump_dir):
|
||||
reference_dump_path = os.path.join(
|
||||
reference_dump_dir, os.path.basename(lib_path))
|
||||
if compress:
|
||||
reference_dump_path += '.gz'
|
||||
os.makedirs(os.path.dirname(reference_dump_path), exist_ok=True)
|
||||
_validate_dump_content(lib_path)
|
||||
if compress:
|
||||
with open(lib_path, 'rb') as src_file:
|
||||
with gzip.open(reference_dump_path, 'wb') as dst_file:
|
||||
shutil.copyfileobj(src_file, dst_file)
|
||||
else:
|
||||
shutil.copyfile(lib_path, reference_dump_path)
|
||||
shutil.copyfile(lib_path, reference_dump_path)
|
||||
print('Created abi dump at', reference_dump_path)
|
||||
return reference_dump_path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user