Skip to content

Commit

Permalink
Ensure qmk generate-compilation-database copies to userspace as wel…
Browse files Browse the repository at this point in the history
…l. (qmk#23129)
  • Loading branch information
tzarc authored and nuess0r committed Sep 8, 2024
1 parent 3f0788e commit 7fad4fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/python/qmk/build_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ def generate_compilation_database(self, build_target: str = None, skip_clean: bo
command = self.compile_command(build_target=build_target, dry_run=True, **env_vars)
from qmk.cli.generate.compilation_database import write_compilation_database # Lazy load due to circular references
output_path = QMK_FIRMWARE / 'compile_commands.json'
write_compilation_database(command=command, output_path=output_path, skip_clean=skip_clean, **env_vars)
if output_path.exists() and HAS_QMK_USERSPACE:
ret = write_compilation_database(command=command, output_path=output_path, skip_clean=skip_clean, **env_vars)
if ret and output_path.exists() and HAS_QMK_USERSPACE:
shutil.copy(str(output_path), str(QMK_USERSPACE / 'compile_commands.json'))
return ret

def compile(self, build_target: str = None, dry_run: bool = False, **env_vars) -> None:
if self._clean or self._compiledb:
Expand Down
4 changes: 3 additions & 1 deletion lib/python/qmk/cli/generate/compilation_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from qmk.decorators import automagic_keyboard, automagic_keymap
from qmk.keyboard import keyboard_completer, keyboard_folder
from qmk.keymap import keymap_completer
from qmk.build_targets import KeyboardKeymapBuildTarget


@lru_cache(maxsize=10)
Expand Down Expand Up @@ -138,4 +139,5 @@ def generate_compilation_database(cli: MILC) -> Union[bool, int]:
elif not current_keymap:
cli.log.error('Could not determine keymap!')

return write_compilation_database(current_keyboard, current_keymap, QMK_FIRMWARE / 'compile_commands.json')
target = KeyboardKeymapBuildTarget(current_keyboard, current_keymap)
return target.generate_compilation_database()

0 comments on commit 7fad4fc

Please sign in to comment.