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]+)}")
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)