aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorYifan Hong2018-11-21 19:48:10 -0600
committerYifan Hong2018-11-27 13:21:21 -0600
commit70fc029ab8f47383851c6effc7844727713b2ed5 (patch)
treeeae7a94746da0b3cd414318491fdf82f8ba7244a /tools
parent9b024fe5835bcecce6d9a9f0fc0c837723e50dab (diff)
downloadplatform-build-70fc029ab8f47383851c6effc7844727713b2ed5.tar.gz
platform-build-70fc029ab8f47383851c6effc7844727713b2ed5.tar.xz
platform-build-70fc029ab8f47383851c6effc7844727713b2ed5.zip
Infer prebuilt image size
Test: call script twice; the second time uses prebuilts Fixes: 119769527 Change-Id: Icd98a4dbfed91538cbc07aab957c7b042c05b330
Diffstat (limited to 'tools')
-rwxr-xr-xtools/releasetools/add_img_to_target_files.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index b0dd0f8de..2950fc26b 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -677,17 +677,25 @@ def AddSuperEmpty(output_zip):
677def AddSuperSplit(output_zip): 677def AddSuperSplit(output_zip):
678 """Create split super_*.img and store it in output_zip.""" 678 """Create split super_*.img and store it in output_zip."""
679 679
680 def GetPartitionSizeFromImage(img):
681 try:
682 simg = sparse_img.SparseImage(img)
683 return simg.blocksize * simg.total_blocks
684 except ValueError:
685 return os.path.getsize(img)
686
680 def TransformPartitionArg(arg): 687 def TransformPartitionArg(arg):
681 lst = arg.split(':') 688 lst = arg.split(':')
682 # Because --auto-slot-suffixing for A/B, there is no need to remove suffix. 689 # Because --auto-slot-suffixing for A/B, there is no need to remove suffix.
683 name = lst[0] 690 name = lst[0]
684 assert name + '_size' in OPTIONS.info_dict, ( 691 if name + '_size' in OPTIONS.info_dict:
685 "{} is a prebuilt. Dynamic partitions with prebuilt images " 692 size = str(OPTIONS.info_dict[name + '_size'])
686 "are not supported yet.".format(name)) 693 logger.info("Using %s_size = %s", name, size)
687 size = OPTIONS.info_dict[name + '_size'] 694 else:
688 assert size is not None, \ 695 size = str(GetPartitionSizeFromImage(
689 '{0}_size is not found; is {0} built?'.format(name) 696 os.path.join(OPTIONS.input_tmp, "IMAGES", '{}.img'.format(name))))
690 lst[2] = str(size) 697 logger.info("Using size of prebuilt %s = %s", name, size)
698 lst[2] = size
691 return ':'.join(lst) 699 return ':'.join(lst)
692 700
693 def GetLpmakeArgsWithSizes(): 701 def GetLpmakeArgsWithSizes():