qmk / qmk_firmware

Open-source keyboard firmware for Atmel AVR and Arm USB families
https://qmk.fm
GNU General Public License v2.0
18.02k stars 38.73k forks source link

compile_commands.json #15434

Closed nathanvercaemert closed 2 years ago

nathanvercaemert commented 2 years ago

Makefile doesn't lend itself to generating compile_commands.json with bear. This would be to use a language server (ccls) with the repository. Is there a workaround for this? I dug up a post on Reddit, but it's a few years old and isn't quite perfect anymore.

tzarc commented 2 years ago

qmk generate-compilation-database -kb <yourkb> -km <yourkeymap> should suffice, nowadays.

nathanvercaemert commented 2 years ago

That's what I was looking for. Thanks for this. Do you know if it's referenced anywhere?

tzarc commented 2 years ago

Yep, just not in an obvious position by the looks of it:

https://docs.qmk.fm/#/cli_commands?id=qmk-generate-compilation-database

nathanvercaemert commented 2 years ago

Thanks. This will be helpful if I ever have to piece it together in the future. Thanks again for the help.

nathanvercaemert commented 2 years ago
➜ qmk_firmware (master) ✗ qmk generate-compilation-database -kb ergodox_ez -km nathanvercaemert
usage: qmk [-h] [-V] [-v] [--datetime-fmt DATETIME_FMT]
           [--log-fmt LOG_FMT] [--log-file-fmt LOG_FILE_FMT]
           [--log-file-level {debug,info,warning,error,critical}]
           [--log-file LOG_FILE] [--color] [--no-color]
           [--unicode] [--no-unicode] [--interactive]
           [--config-file CONFIG_FILE]
           {config,clone,console,env,setup,c2json,cd,chibios-confmigrate,clean,compile,doctor,flash,generate-rgb-breathe-table,info,json2c,lint,list-keyboards,list-keymaps,list-layouts,new-keyboard,new-keymap}
           ...
qmk: error: argument {config,clone,console,env,setup,c2json,cd,chibios-confmigrate,clean,compile,doctor,flash,generate-rgb-breathe-table,info,json2c,lint,list-keyboards,list-keymaps,list-layouts,new-keyboard,new-keymap}: invalid choice: 'generate-compilation-database' (choose from 'config', 'clone', 'console', 'env', 'setup', 'bux', 'c2json', 'cd', 'cformat', 'chibios-confmigrate', 'clean', 'compile', 'docs', 'doctor', 'fileformat', 'flash', 'format-c', 'format-json', 'format-python', 'format-text', 'generate-api', 'generate-config-h', 'generate-dfu-header', 'generate-docs', 'generate-info-json', 'generate-keyboard-h', 'generate-layouts', 'generate-rgb-breathe-table', 'generate-rules-mk', 'generate-version-h', 'hello', 'info', 'json2c', 'lint', 'list-keyboards', 'list-keymaps', 'list-layouts', 'kle2json', 'multibuild', 'new-keyboard', 'new-keymap', 'pyformat', 'pytest')

Any suggestions?

tzarc commented 2 years ago

Sounds like your repo is out of date, it was added to the repo on November 27th, this year.

nathanvercaemert commented 2 years ago

I resolved this issue with help from https://github.com/qmk/qmk_firmware/issues/4855

I just needed to run:

bear -vvvv qmk compile
nathanvercaemert commented 2 years ago

O wow, love how QMK is always being improved. Thanks for the help. Closing issue.