diff options
Diffstat (limited to 'lib/python/qmk/makefile.py')
| -rw-r--r-- | lib/python/qmk/makefile.py | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/lib/python/qmk/makefile.py b/lib/python/qmk/makefile.py index 8645056d2..02c2e7005 100644 --- a/lib/python/qmk/makefile.py +++ b/lib/python/qmk/makefile.py | |||
| @@ -2,8 +2,6 @@ | |||
| 2 | """ | 2 | """ |
| 3 | from pathlib import Path | 3 | from pathlib import Path |
| 4 | 4 | ||
| 5 | from qmk.errors import NoSuchKeyboardError | ||
| 6 | |||
| 7 | 5 | ||
| 8 | def parse_rules_mk_file(file, rules_mk=None): | 6 | def parse_rules_mk_file(file, rules_mk=None): |
| 9 | """Turn a rules.mk file into a dictionary. | 7 | """Turn a rules.mk file into a dictionary. |
| @@ -51,33 +49,3 @@ def parse_rules_mk_file(file, rules_mk=None): | |||
| 51 | rules_mk[key.strip()] = value.strip() | 49 | rules_mk[key.strip()] = value.strip() |
| 52 | 50 | ||
| 53 | return rules_mk | 51 | return rules_mk |
| 54 | |||
| 55 | |||
| 56 | def get_rules_mk(keyboard): | ||
| 57 | """ Get a rules.mk for a keyboard | ||
| 58 | |||
| 59 | Args: | ||
| 60 | keyboard: name of the keyboard | ||
| 61 | |||
| 62 | Raises: | ||
| 63 | NoSuchKeyboardError: when the keyboard does not exists | ||
| 64 | |||
| 65 | Returns: | ||
| 66 | a dictionary with the content of the rules.mk file | ||
| 67 | """ | ||
| 68 | # Start with qmk_firmware/keyboards | ||
| 69 | kb_path = Path.cwd() / "keyboards" | ||
| 70 | # walk down the directory tree | ||
| 71 | # and collect all rules.mk files | ||
| 72 | kb_dir = kb_path / keyboard | ||
| 73 | if kb_dir.exists(): | ||
| 74 | rules_mk = dict() | ||
| 75 | for directory in Path(keyboard).parts: | ||
| 76 | kb_path = kb_path / directory | ||
| 77 | rules_mk_path = kb_path / "rules.mk" | ||
| 78 | if rules_mk_path.exists(): | ||
| 79 | rules_mk = parse_rules_mk_file(rules_mk_path, rules_mk) | ||
| 80 | else: | ||
| 81 | raise NoSuchKeyboardError("The requested keyboard and/or revision does not exist.") | ||
| 82 | |||
| 83 | return rules_mk | ||
