diff options
Diffstat (limited to 'lib/python')
-rw-r--r-- | lib/python/qmk/makefile.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/python/qmk/makefile.py b/lib/python/qmk/makefile.py index ce64431f9..dc498adc8 100644 --- a/lib/python/qmk/makefile.py +++ b/lib/python/qmk/makefile.py | |||
@@ -16,20 +16,15 @@ def parse_rules_mk(file_path): | |||
16 | Returns: | 16 | Returns: |
17 | a dictionary with the file's content | 17 | a dictionary with the file's content |
18 | """ | 18 | """ |
19 | # regex to match lines with comment at the end | 19 | # regex to match lines uncommented lines and get the data |
20 | # group(1) = option's name | 20 | # group(1) = option's name |
21 | # group(2) = operator (eg.: '=', '+=') | 21 | # group(2) = operator (eg.: '=', '+=') |
22 | # group(3) = value(s) | 22 | # group(3) = value(s) |
23 | commented_regex = re.compile(r"^\s*(\w+)\s*([\:\+\-]?=)\s*(.*?)(?=\s*\#)") | 23 | rules_mk_regex = re.compile(r"^\s*(\w+)\s*([\?\:\+\-]?=)\s*(\S.*?)(?=\s*(\#|$))") |
24 | # regex to match lines without comment at the end | ||
25 | # group(1) = option's name | ||
26 | # group(2) = operator (eg.: '=', '+=') | ||
27 | # group(3) = value(s) | ||
28 | uncommented_regex = re.compile(r"^\s*(\w+)\s*([\:\+\-]?=)\s*(.*?)(?=\s*$)") | ||
29 | mk_content = qmk.path.unicode_lines(file_path) | 24 | mk_content = qmk.path.unicode_lines(file_path) |
30 | parsed_file = dict() | 25 | parsed_file = dict() |
31 | for line in mk_content: | 26 | for line in mk_content: |
32 | found = commented_regex.search(line) if "#" in line else uncommented_regex.search(line) | 27 | found = rules_mk_regex.search(line) |
33 | if found: | 28 | if found: |
34 | parsed_file[found.group(1)] = dict(operator = found.group(2), value = found.group(3)) | 29 | parsed_file[found.group(1)] = dict(operator = found.group(2), value = found.group(3)) |
35 | return parsed_file | 30 | return parsed_file |