Skip to content

Commit c6385ca

Browse files
committed
extract_utils: add support for virtual proprietary files
Change-Id: I0076884f325692b3679034db357a61d00b511914
1 parent 640c56e commit c6385ca

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

extract_utils/module.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class ProprietaryFileType(Enum):
7171
BLOBS = 0
7272
FIRMWARE = 1
7373
FACTORY = 2
74+
VIRTUAL = 3
7475

7576

7677
fix_file_list_fn_type = Callable[[FileList], None]
@@ -83,7 +84,7 @@ class ProprietaryFileType(Enum):
8384
class ProprietaryFile:
8485
def __init__(
8586
self,
86-
file_list_path: str,
87+
file_list_path: Optional[str],
8788
vendor_rel_sub_path: str = 'proprietary',
8889
fix_file_list: Optional[fix_file_list_fn_type] = None,
8990
pre_makefile_generation_fn: Optional[
@@ -100,6 +101,8 @@ def __init__(
100101
] = None,
101102
kind: ProprietaryFileType = ProprietaryFileType.BLOBS,
102103
):
104+
assert file_list_path is not None or kind == ProprietaryFileType.VIRTUAL
105+
103106
self.file_list_path = file_list_path
104107
self.vendor_rel_sub_path = vendor_rel_sub_path
105108
self.file_list = FileList()
@@ -239,6 +242,7 @@ def write_makefiles(self, module: ExtractUtilsModule, ctx: MakefilesCtx):
239242
self.run_post_makefile_generation_fns(ctx, packages_ctx)
240243

241244
def write_to_file(self):
245+
assert self.file_list_path is not None
242246
self.file_list.write_to_file(self.file_list_path)
243247

244248
def init_file_list(
@@ -252,6 +256,7 @@ def init_file_list(
252256
)
253257

254258
def parse(self):
259+
assert self.file_list_path is not None
255260
self.file_list.add_from_file(self.file_list_path)
256261

257262
def get_files(self) -> Iterable[File]:
@@ -261,6 +266,34 @@ def get_partitions(self) -> Set[str]:
261266
return self.file_list.partitions
262267

263268

269+
class VirtualPropertietaryFile(ProprietaryFile):
270+
def __init__(
271+
self,
272+
name: str,
273+
file_list_lines: List[str],
274+
vendor_rel_sub_path: str = 'proprietary',
275+
):
276+
super().__init__(
277+
None,
278+
vendor_rel_sub_path,
279+
None,
280+
kind=ProprietaryFileType.VIRTUAL,
281+
)
282+
283+
self.name = name
284+
self.file_list_lines = file_list_lines
285+
286+
@property
287+
def printable_path(self):
288+
return self.name
289+
290+
def write_to_file(self):
291+
pass
292+
293+
def parse(self):
294+
self.file_list.add_from_lines(self.file_list_lines)
295+
296+
264297
class FirmwareProprietaryFile(ProprietaryFile):
265298
def __init__(
266299
self,

0 commit comments

Comments
 (0)