diff options
author | Bao <qubidt@gmail.com> | 2021-09-15 23:59:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-16 14:59:57 +1000 |
commit | 590b405468fec906a51767a5cda4aa30ada5d52f (patch) | |
tree | 0c907b8836440475e7b2800737800f4d50d81649 /lib/python/qmk/commands.py | |
parent | f7054522106644a5fd9ee58b5117a44b3209b7b2 (diff) | |
download | qmk_firmware-590b405468fec906a51767a5cda4aa30ada5d52f.tar.gz qmk_firmware-590b405468fec906a51767a5cda4aa30ada5d52f.zip |
New CLI subcommand to create clang-compatible compilation database (`compile_commands.json`) (#14370)
* pulled source from dev branch
* missed a file from origin
* formatting
* revised argument names. relaxed matching rules to work for avr too
* add docstrings
* added docs. tightened up regex
* remove unused imports
* cleaning up command file. use existing qmk dir constant
* rename parser library file
* move lib functions into command file. there are only 2 and they aren't large
* currently debugging...
* more robustly find config
* updated docs
* remove unused imports
* reuse make executable from the main make command
* pulled source from dev branch
* missed a file from origin
* formatting
* revised argument names. relaxed matching rules to work for avr too
* add docstrings
* added docs. tightened up regex
* remove unused imports
* cleaning up command file. use existing qmk dir constant
* rename parser library file
* move lib functions into command file. there are only 2 and they aren't large
* currently debugging...
* more robustly find config
* updated docs
* remove unused imports
* reuse make executable from the main make command
* remove MAKEFLAGS from environment for better control over process management
* Update .gitignore
Co-authored-by: Michael Forster <forster@google.com>
* add a usage line to docs
* doc change as suggested
Co-authored-by: Nick Brassel <nick@tzarc.org>
* rename command
* remove debug print statements
* generate-compilation-database: fix arg handling
* generate-comilation-db: improve error handling
* use cli.run() instead of Popen()
Co-authored-by: Xton <cdewan@apple.com>
Co-authored-by: Christon DeWan <cmdpix@mac.com>
Co-authored-by: Michael Forster <forster@google.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'lib/python/qmk/commands.py')
-rw-r--r-- | lib/python/qmk/commands.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 01c23b261..2995a5fda 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py | |||
@@ -28,7 +28,7 @@ def _find_make(): | |||
28 | return make_cmd | 28 | return make_cmd |
29 | 29 | ||
30 | 30 | ||
31 | def create_make_target(target, parallel=1, **env_vars): | 31 | def create_make_target(target, dry_run=False, parallel=1, **env_vars): |
32 | """Create a make command | 32 | """Create a make command |
33 | 33 | ||
34 | Args: | 34 | Args: |
@@ -36,6 +36,9 @@ def create_make_target(target, parallel=1, **env_vars): | |||
36 | target | 36 | target |
37 | Usually a make rule, such as 'clean' or 'all'. | 37 | Usually a make rule, such as 'clean' or 'all'. |
38 | 38 | ||
39 | dry_run | ||
40 | make -n -- don't actually build | ||
41 | |||
39 | parallel | 42 | parallel |
40 | The number of make jobs to run in parallel | 43 | The number of make jobs to run in parallel |
41 | 44 | ||
@@ -52,10 +55,10 @@ def create_make_target(target, parallel=1, **env_vars): | |||
52 | for key, value in env_vars.items(): | 55 | for key, value in env_vars.items(): |
53 | env.append(f'{key}={value}') | 56 | env.append(f'{key}={value}') |
54 | 57 | ||
55 | return [make_cmd, *get_make_parallel_args(parallel), *env, target] | 58 | return [make_cmd, *(['-n'] if dry_run else []), *get_make_parallel_args(parallel), *env, target] |
56 | 59 | ||
57 | 60 | ||
58 | def create_make_command(keyboard, keymap, target=None, parallel=1, **env_vars): | 61 | def create_make_command(keyboard, keymap, target=None, dry_run=False, parallel=1, **env_vars): |
59 | """Create a make compile command | 62 | """Create a make compile command |
60 | 63 | ||
61 | Args: | 64 | Args: |
@@ -69,6 +72,9 @@ def create_make_command(keyboard, keymap, target=None, parallel=1, **env_vars): | |||
69 | target | 72 | target |
70 | Usually a bootloader. | 73 | Usually a bootloader. |
71 | 74 | ||
75 | dry_run | ||
76 | make -n -- don't actually build | ||
77 | |||
72 | parallel | 78 | parallel |
73 | The number of make jobs to run in parallel | 79 | The number of make jobs to run in parallel |
74 | 80 | ||
@@ -84,7 +90,7 @@ def create_make_command(keyboard, keymap, target=None, parallel=1, **env_vars): | |||
84 | if target: | 90 | if target: |
85 | make_args.append(target) | 91 | make_args.append(target) |
86 | 92 | ||
87 | return create_make_target(':'.join(make_args), parallel, **env_vars) | 93 | return create_make_target(':'.join(make_args), dry_run=dry_run, parallel=parallel, **env_vars) |
88 | 94 | ||
89 | 95 | ||
90 | def get_git_version(current_time, repo_dir='.', check_dir='.'): | 96 | def get_git_version(current_time, repo_dir='.', check_dir='.'): |