Skip to content

Commit 56802f5

Browse files
authored
Ensure qmk generate-compilation-database copies to userspace as well. (#23129)
1 parent c6668b9 commit 56802f5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/python/qmk/build_targets.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ def generate_compilation_database(self, build_target: str = None, skip_clean: bo
119119
command = self.compile_command(build_target=build_target, dry_run=True, **env_vars)
120120
from qmk.cli.generate.compilation_database import write_compilation_database # Lazy load due to circular references
121121
output_path = QMK_FIRMWARE / 'compile_commands.json'
122-
write_compilation_database(command=command, output_path=output_path, skip_clean=skip_clean, **env_vars)
123-
if output_path.exists() and HAS_QMK_USERSPACE:
122+
ret = write_compilation_database(command=command, output_path=output_path, skip_clean=skip_clean, **env_vars)
123+
if ret and output_path.exists() and HAS_QMK_USERSPACE:
124124
shutil.copy(str(output_path), str(QMK_USERSPACE / 'compile_commands.json'))
125+
return ret
125126

126127
def compile(self, build_target: str = None, dry_run: bool = False, **env_vars) -> None:
127128
if self._clean or self._compiledb:

lib/python/qmk/cli/generate/compilation_database.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from qmk.decorators import automagic_keyboard, automagic_keymap
1818
from qmk.keyboard import keyboard_completer, keyboard_folder
1919
from qmk.keymap import keymap_completer
20+
from qmk.build_targets import KeyboardKeymapBuildTarget
2021

2122

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

141-
return write_compilation_database(current_keyboard, current_keymap, QMK_FIRMWARE / 'compile_commands.json')
142+
target = KeyboardKeymapBuildTarget(current_keyboard, current_keymap)
143+
return target.generate_compilation_database()

0 commit comments

Comments
 (0)