diff options
author | Nick Brassel <nick@tzarc.org> | 2023-02-19 13:04:50 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-18 18:04:50 -0800 |
commit | 1283863c0e423eabfc01a4d3906cefbbf94a512c (patch) | |
tree | 3233b4f68fb91a5d6562463abb5de6b8424571be /lib/python/qmk | |
parent | 48a79b08ccbcd0af5269e2e9334042c8347d18f8 (diff) |
Add `mass-compile` ability to filter by key existence. (#19885)
Diffstat (limited to 'lib/python/qmk')
-rwxr-xr-x | lib/python/qmk/cli/mass_compile.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/python/qmk/cli/mass_compile.py b/lib/python/qmk/cli/mass_compile.py index d8dda0cac3..2821a60c87 100755 --- a/lib/python/qmk/cli/mass_compile.py +++ b/lib/python/qmk/cli/mass_compile.py @@ -60,7 +60,7 @@ def _load_keymap_info(keyboard, keymap): action='append', default=[], help= # noqa: `format-python` and `pytest` don't agree here. - "Filter the list of keyboards based on the supplied value in rules.mk. Matches info.json structure, and accepts the format 'features.rgblight=true'. May be passed multiple times, all filters need to match. Value may include wildcards such as '*' and '?'." # noqa: `format-python` and `pytest` don't agree here. + "Filter the list of keyboards based on the supplied value in rules.mk. Matches info.json structure, and accepts the formats 'features.rgblight=true' or 'exists(matrix_pins.direct)'. May be passed multiple times, all filters need to match. Value may include wildcards such as '*' and '?'." # noqa: `format-python` and `pytest` don't agree here. ) @cli.argument('-km', '--keymap', type=str, default='default', help="The keymap name to build. Default is 'default'.") @cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.") @@ -95,9 +95,10 @@ def mass_compile(cli): cli.log.info('Parsing data for all matching keyboard/keymap combinations...') valid_keymaps = [(e[0], e[1], dotty(e[2])) for e in pool.starmap(_load_keymap_info, target_list)] - filter_re = re.compile(r'^(?P<key>[a-zA-Z0-9_\.]+)\s*=\s*(?P<value>[^#]+)$') + equals_re = re.compile(r'^(?P<key>[a-zA-Z0-9_\.]+)\s*=\s*(?P<value>[^#]+)$') + exists_re = re.compile(r'^exists\((?P<key>[a-zA-Z0-9_\.]+)\)$') for filter_txt in cli.args.filter: - f = filter_re.match(filter_txt) + f = equals_re.match(filter_txt) if f is not None: key = f.group('key') value = f.group('value') @@ -116,6 +117,12 @@ def mass_compile(cli): valid_keymaps = filter(_make_filter(key, value), valid_keymaps) + f = exists_re.match(filter_txt) + if f is not None: + key = f.group('key') + cli.log.info(f'Filtering on condition (exists: "{key}")...') + valid_keymaps = filter(lambda e: e[2].get(key) is not None, valid_keymaps) + targets = [(e[0], e[1]) for e in valid_keymaps] if len(targets) == 0: |