def _CompileDeps(aapt2_path, dep_subdirs, temp_dir, exclusion_rules): partials_dir = os.path.join(temp_dir, 'partials') build_utils.MakeDirectory(partials_dir) job_params = [(i, dep_subdir, _CreateValuesKeepPredicate(exclusion_rules, dep_subdir)) for i, dep_subdir in enumerate(dep_subdirs)] # Filtering is slow, so ensure jobs with keep_predicate are started first. job_params.sort(key=lambda x: not x[2]) return list( parallel.BulkForkAndCall(_CompileSingleDep, job_params, aapt2_path=aapt2_path, partials_dir=partials_dir))
def _ConvertToWebP(cwebp_binary, png_paths, path_info, webp_cache_dir): cwebp_version = subprocess.check_output([cwebp_binary, '-version']).rstrip() shard_args = [(f, ) for f in png_paths if not _PNG_WEBP_EXCLUSION_PATTERN.match(f)] build_utils.MakeDirectory(webp_cache_dir) results = parallel.BulkForkAndCall(_ConvertToWebPSingle, shard_args, cwebp_binary=cwebp_binary, cwebp_version=cwebp_version, webp_cache_dir=webp_cache_dir) total_cache_hits = 0 for rename_tuple, cache_hit in results: path_info.RegisterRename(*rename_tuple) total_cache_hits += int(cache_hit) logging.debug('png->webp cache: %d/%d', total_cache_hits, len(shard_args))