Add sources, fix blank line issue
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
import argparse
|
||||
from typing import List
|
||||
from typing import List, Tuple
|
||||
import pathlib
|
||||
|
||||
|
||||
@@ -21,7 +21,19 @@ def rtl_manifest_main():
|
||||
pass
|
||||
|
||||
def read_sources(source_file: str) -> List[str]:
|
||||
sources, incdirs = parse(source_file)
|
||||
|
||||
return sources
|
||||
|
||||
def read_incdirs(source_file: str) -> List[str]:
|
||||
sources, incdirs = parse(source_file)
|
||||
|
||||
return incdirs
|
||||
|
||||
def parse(source_file: str) -> Tuple[List[str], List[str]]:
|
||||
files = []
|
||||
incdirs = []
|
||||
|
||||
base_dir = pathlib.Path(source_file).parent
|
||||
|
||||
|
||||
@@ -30,12 +42,18 @@ def read_sources(source_file: str) -> List[str]:
|
||||
path = line.strip()
|
||||
if path.startswith("#"):
|
||||
continue
|
||||
if path == "":
|
||||
continue
|
||||
if path.startswith("`include "):
|
||||
abs_path = pathlib.Path(base_dir / path.split()[1]).absolute()
|
||||
incdirs.append(abs_path)
|
||||
continue
|
||||
if (path.endswith("sources.list")):
|
||||
new_path = pathlib.Path(base_dir) / path
|
||||
for recursive_path in read_sources(new_path):
|
||||
for recursive_path in parse(new_path):
|
||||
files.append(recursive_path)
|
||||
else:
|
||||
abs_path = pathlib.Path(base_dir / path).absolute()
|
||||
files.append(str(abs_path))
|
||||
|
||||
return files
|
||||
return files, incdirs
|
||||
|
||||
Reference in New Issue
Block a user