diff options
| author | Joel Challis <git@zvecr.com> | 2021-05-09 11:57:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-09 12:57:49 +0200 |
| commit | 7725d813c9cf1a47863e325457b13a4542984eda (patch) | |
| tree | 4b51c7e3b6c10328467207bfe4683c3bcff78526 /lib/python/qmk/commands.py | |
| parent | 60a39f4f5d192625ea03daf8cd26bc89aa1a91c2 (diff) | |
| download | qmk_firmware-7725d813c9cf1a47863e325457b13a4542984eda.tar.gz qmk_firmware-7725d813c9cf1a47863e325457b13a4542984eda.zip | |
Allow MAKE environment override for 'qmk clean' (#12473)
Diffstat (limited to 'lib/python/qmk/commands.py')
| -rw-r--r-- | lib/python/qmk/commands.py | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index d742f6756..97774001a 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py | |||
| @@ -29,6 +29,33 @@ def _find_make(): | |||
| 29 | return make_cmd | 29 | return make_cmd |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | def create_make_target(target, parallel=1, **env_vars): | ||
| 33 | """Create a make command | ||
| 34 | |||
| 35 | Args: | ||
| 36 | |||
| 37 | target | ||
| 38 | Usually a make rule, such as 'clean' or 'all'. | ||
| 39 | |||
| 40 | parallel | ||
| 41 | The number of make jobs to run in parallel | ||
| 42 | |||
| 43 | **env_vars | ||
| 44 | Environment variables to be passed to make. | ||
| 45 | |||
| 46 | Returns: | ||
| 47 | |||
| 48 | A command that can be run to make the specified keyboard and keymap | ||
| 49 | """ | ||
| 50 | env = [] | ||
| 51 | make_cmd = _find_make() | ||
| 52 | |||
| 53 | for key, value in env_vars.items(): | ||
| 54 | env.append(f'{key}={value}') | ||
| 55 | |||
| 56 | return [make_cmd, '-j', str(parallel), *env, target] | ||
| 57 | |||
| 58 | |||
| 32 | def create_make_command(keyboard, keymap, target=None, parallel=1, **env_vars): | 59 | def create_make_command(keyboard, keymap, target=None, parallel=1, **env_vars): |
| 33 | """Create a make compile command | 60 | """Create a make compile command |
| 34 | 61 | ||
| @@ -53,17 +80,12 @@ def create_make_command(keyboard, keymap, target=None, parallel=1, **env_vars): | |||
| 53 | 80 | ||
| 54 | A command that can be run to make the specified keyboard and keymap | 81 | A command that can be run to make the specified keyboard and keymap |
| 55 | """ | 82 | """ |
| 56 | env = [] | ||
| 57 | make_args = [keyboard, keymap] | 83 | make_args = [keyboard, keymap] |
| 58 | make_cmd = _find_make() | ||
| 59 | 84 | ||
| 60 | if target: | 85 | if target: |
| 61 | make_args.append(target) | 86 | make_args.append(target) |
| 62 | 87 | ||
| 63 | for key, value in env_vars.items(): | 88 | return create_make_target(':'.join(make_args), parallel, **env_vars) |
| 64 | env.append(f'{key}={value}') | ||
| 65 | |||
| 66 | return [make_cmd, '-j', str(parallel), *env, ':'.join(make_args)] | ||
| 67 | 89 | ||
| 68 | 90 | ||
| 69 | def get_git_version(repo_dir='.', check_dir='.'): | 91 | def get_git_version(repo_dir='.', check_dir='.'): |
