Modify modify_pc.py script to ignore comments 21/319921/1
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 4 Nov 2024 08:57:11 +0000 (17:57 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Mon, 4 Nov 2024 08:57:11 +0000 (17:57 +0900)
Previously, some line which starts with '#' was not ignored.
Consequently, the resulting hal-rootstrap.pc file was modified
incorrectly.

To solve this issue, modify_pc.py script is modified to ignore lines
which start with '#'.

Change-Id: I9d71a889412cc64902c853f009c74f12b09f9b52
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
modify_pc.py

index adea07c4c4c4f82392f7a3bfcd2b3c89b6420e01..b6594563378b67b20b26c594a273c202ad1e8a7c 100755 (executable)
@@ -6,6 +6,7 @@ from re import compile as regex_compile
 
 include_dir_root_path = "hal_rootstrap_dir"
 
+regex_comment = regex_compile("([^#]*)(#.*)?")
 regex_assignment = regex_compile("\\s*([-_a-zA-Z0-9]+)\\s*=\\s*([^\\s]*)")
 regex_declaration = regex_compile("\\s*([-_a-zA-Z0-9]+)\\s*:\\s*(.+)\\s*")
 regex_substitution = regex_compile("\\${([-_a-zA-Z0-9]+)}")
@@ -14,11 +15,17 @@ libs = { "-L${" + include_dir_root_path + "}" }
 cflags = { "-I${" + include_dir_root_path + "}" }
 cxxflags = { "-I${" + include_dir_root_path + "}" }
 
+def remove_comment(line):
+       matches = regex_comment.findall(line)
+       line, _ = matches[0][0], matches[0][1]
+       return line
+
 def parse_pc(fname):
        variables = dict()
 
        f = open(fname, "r")
        for line in f:
+               line = remove_comment(line)
                if matches := regex_assignment.findall(line):
                        symbol, value = matches[0][0], matches[0][1]
                        matched_symbols = regex_substitution.findall(value)