def _CloneSizeInfo(self, use_output_directory=True, use_elf=True, use_apk=False, use_minimal_apks=False, use_pak=False): assert not use_elf or use_output_directory assert not (use_apk and use_pak) cache_key = ( use_output_directory, use_elf, use_apk, use_minimal_apks, use_pak) if cache_key not in IntegrationTest.cached_size_info: elf_path = _TEST_ELF_PATH if use_elf else None output_directory = _TEST_OUTPUT_DIR if use_output_directory else None knobs = archive.SectionSizeKnobs() opts = archive.ContainerArchiveOptions(self._CreateTestArgs()) # Override for testing. Lower the bar for compacting symbols, to allow # smaller test cases to be created. knobs.max_same_name_alias_count = 3 apk_path = None minimal_apks_path = None apk_so_path = None size_info_prefix = None extracted_minimal_apk_path = None if use_apk: apk_path = _TEST_APK_PATH elif use_minimal_apks: minimal_apks_path = _TEST_MINIMAL_APKS_PATH extracted_minimal_apk_path = _TEST_APK_PATH if use_apk or use_minimal_apks: apk_so_path = _TEST_APK_SO_PATH if output_directory: if use_apk: orig_path = _TEST_APK_PATH else: orig_path = _TEST_MINIMAL_APKS_PATH.replace('.minimal.apks', '.aab') size_info_prefix = os.path.join( output_directory, 'size-info', os.path.basename(orig_path)) pak_files = None pak_info_file = None if use_pak: pak_files = [_TEST_APK_LOCALE_PAK_PATH, _TEST_APK_PAK_PATH] pak_info_file = _TEST_PAK_INFO_PATH linker_name = 'gold' with _AddMocksToPath(): metadata = archive.CreateMetadata(_TEST_MAP_PATH, elf_path, apk_path, minimal_apks_path, _TEST_TOOL_PREFIX, output_directory, linker_name) section_sizes, raw_symbols = archive.CreateSectionSizesAndSymbols( knobs=knobs, opts=opts, map_path=_TEST_MAP_PATH, tool_prefix=_TEST_TOOL_PREFIX, elf_path=elf_path, output_directory=output_directory, apk_path=apk_path or extracted_minimal_apk_path, apk_so_path=apk_so_path, metadata=metadata, pak_files=pak_files, pak_info_file=pak_info_file, linker_name=linker_name, size_info_prefix=size_info_prefix) IntegrationTest.cached_size_info[cache_key] = archive.CreateSizeInfo( [section_sizes], [raw_symbols], [metadata]) return copy.deepcopy(IntegrationTest.cached_size_info[cache_key])
def _CloneSizeInfo(self, use_output_directory=True, use_elf=False, use_apk=False, use_minimal_apks=False, use_pak=False, use_aux_elf=False): assert not use_elf or use_output_directory assert not (use_apk and use_pak) cache_key = (use_output_directory, use_elf, use_apk, use_minimal_apks, use_pak, use_aux_elf) if cache_key not in IntegrationTest.cached_size_info: knobs = archive.SectionSizeKnobs() # Override for testing. Lower the bar for compacting symbols, to allow # smaller test cases to be created. knobs.max_same_name_alias_count = 3 args = self._CreateTestArgs() args.elf_file = _TEST_ELF_PATH if use_elf or use_aux_elf else None args.map_file = _TEST_MAP_PATH args.output_directory = _TEST_OUTPUT_DIR if use_output_directory else None args.source_directory = _TEST_SOURCE_DIR args.tool_prefix = _TEST_TOOL_PREFIX apk_so_path = None size_info_prefix = None extracted_minimal_apk_path = None container_name = '' if use_apk: args.apk_file = _TEST_APK_PATH elif use_minimal_apks: args.minimal_apks_file = _TEST_MINIMAL_APKS_PATH extracted_minimal_apk_path = _TEST_APK_PATH container_name = 'Bundle.minimal.apks' if use_apk or use_minimal_apks: apk_so_path = _TEST_APK_SO_PATH if args.output_directory: if use_apk: orig_path = _TEST_APK_PATH else: orig_path = _TEST_MINIMAL_APKS_PATH.replace('.minimal.apks', '.aab') size_info_prefix = os.path.join(args.output_directory, 'size-info', os.path.basename(orig_path)) pak_files = None pak_info_file = None if use_pak: pak_files = [_TEST_APK_LOCALE_PAK_PATH, _TEST_APK_PAK_PATH] pak_info_file = _TEST_PAK_INFO_PATH linker_name = 'gold' # For simplicity, using |args| for both params. This is okay since # |args.ssargs_file| is unassigned. opts = archive.ContainerArchiveOptions(args, args) with _AddMocksToPath(): build_config = {} metadata = archive.CreateMetadata(args, linker_name, build_config) container_list = [] raw_symbols_list = [] container, raw_symbols = archive.CreateContainerAndSymbols( knobs=knobs, opts=opts, container_name='{}/base.apk'.format(container_name) if container_name else '', metadata=metadata, map_path=args.map_file, tool_prefix=args.tool_prefix, output_directory=args.output_directory, source_directory=args.source_directory, elf_path=args.elf_file, apk_path=args.apk_file or extracted_minimal_apk_path, apk_so_path=apk_so_path, pak_files=pak_files, pak_info_file=pak_info_file, linker_name=linker_name, size_info_prefix=size_info_prefix) container_list.append(container) raw_symbols_list.append(raw_symbols) if use_minimal_apks: opts.analyze_native = False args.split_name = 'not_on_demand' args.apk_file = _TEST_NOT_ON_DEMAND_SPLIT_APK_PATH args.elf_file = None args.map_file = None metadata = archive.CreateMetadata(args, None, build_config) container, raw_symbols = archive.CreateContainerAndSymbols( knobs=knobs, opts=opts, container_name='{}/not_on_demand.apk'.format(container_name), metadata=metadata, tool_prefix=args.tool_prefix, output_directory=args.output_directory, source_directory=args.source_directory, apk_path=_TEST_NOT_ON_DEMAND_SPLIT_APK_PATH, size_info_prefix=size_info_prefix) container_list.append(container) raw_symbols_list.append(raw_symbols) args.split_name = 'on_demand' args.apk_file = _TEST_ON_DEMAND_SPLIT_APK_PATH metadata = archive.CreateMetadata(args, None, build_config) container, raw_symbols = archive.CreateContainerAndSymbols( knobs=knobs, opts=opts, container_name='{}/on_demand.apk'.format(container_name), metadata=metadata, tool_prefix=args.tool_prefix, output_directory=args.output_directory, source_directory=args.source_directory, apk_path=_TEST_ON_DEMAND_SPLIT_APK_PATH, size_info_prefix=size_info_prefix) container_list.append(container) raw_symbols_list.append(raw_symbols) IntegrationTest.cached_size_info[cache_key] = archive.CreateSizeInfo( build_config, container_list, raw_symbols_list) return copy.deepcopy(IntegrationTest.cached_size_info[cache_key])