|
|
@ -7,10 +7,12 @@ from argcomplete.completers import FilesCompleter |
|
|
|
from milc import cli |
|
|
|
from milc import cli |
|
|
|
|
|
|
|
|
|
|
|
import qmk.path |
|
|
|
import qmk.path |
|
|
|
|
|
|
|
from qmk.constants import QMK_FIRMWARE |
|
|
|
from qmk.decorators import automagic_keyboard, automagic_keymap |
|
|
|
from qmk.decorators import automagic_keyboard, automagic_keymap |
|
|
|
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json, build_environment |
|
|
|
from qmk.commands import compile_configurator_json, create_make_command, parse_configurator_json, build_environment |
|
|
|
from qmk.keyboard import keyboard_completer, keyboard_folder_or_all, is_all_keyboards |
|
|
|
from qmk.keyboard import keyboard_completer, keyboard_folder_or_all, is_all_keyboards |
|
|
|
from qmk.keymap import keymap_completer, locate_keymap |
|
|
|
from qmk.keymap import keymap_completer, locate_keymap |
|
|
|
|
|
|
|
from qmk.cli.generate.compilation_database import write_compilation_database |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _is_keymap_target(keyboard, keymap): |
|
|
|
def _is_keymap_target(keyboard, keymap): |
|
|
@ -30,6 +32,7 @@ def _is_keymap_target(keyboard, keymap): |
|
|
|
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.") |
|
|
|
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.") |
|
|
|
@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.") |
|
|
|
@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.") |
|
|
|
@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.") |
|
|
|
@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.") |
|
|
|
|
|
|
|
@cli.argument('--compiledb', arg_only=True, action='store_true', help="Generates the clang compile_commands.json file during build. Implies --clean.") |
|
|
|
@cli.subcommand('Compile a QMK Firmware.') |
|
|
|
@cli.subcommand('Compile a QMK Firmware.') |
|
|
|
@automagic_keyboard |
|
|
|
@automagic_keyboard |
|
|
|
@automagic_keymap |
|
|
|
@automagic_keymap |
|
|
@ -53,6 +56,9 @@ def compile(cli): |
|
|
|
# Determine the compile command |
|
|
|
# Determine the compile command |
|
|
|
commands = [] |
|
|
|
commands = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
current_keyboard = None |
|
|
|
|
|
|
|
current_keymap = None |
|
|
|
|
|
|
|
|
|
|
|
if cli.args.filename: |
|
|
|
if cli.args.filename: |
|
|
|
# If a configurator JSON was provided generate a keymap and compile it |
|
|
|
# If a configurator JSON was provided generate a keymap and compile it |
|
|
|
user_keymap = parse_configurator_json(cli.args.filename) |
|
|
|
user_keymap = parse_configurator_json(cli.args.filename) |
|
|
@ -69,11 +75,21 @@ def compile(cli): |
|
|
|
commands.append(create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, 'clean', **envs)) |
|
|
|
commands.append(create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, 'clean', **envs)) |
|
|
|
commands.append(create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, parallel=cli.config.compile.parallel, **envs)) |
|
|
|
commands.append(create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap, parallel=cli.config.compile.parallel, **envs)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
current_keyboard = cli.config.compile.keyboard |
|
|
|
|
|
|
|
current_keymap = cli.config.compile.keymap |
|
|
|
|
|
|
|
|
|
|
|
if not commands: |
|
|
|
if not commands: |
|
|
|
cli.log.error('You must supply a configurator export, both `--keyboard` and `--keymap`, or be in a directory for a keyboard or keymap.') |
|
|
|
cli.log.error('You must supply a configurator export, both `--keyboard` and `--keymap`, or be in a directory for a keyboard or keymap.') |
|
|
|
cli.print_help() |
|
|
|
cli.print_help() |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if cli.args.compiledb: |
|
|
|
|
|
|
|
if current_keyboard is None or current_keymap is None: |
|
|
|
|
|
|
|
cli.log.error('You must supply both `--keyboard` and `--keymap` or be in a directory with a keymap to generate a compile_commands.json file.') |
|
|
|
|
|
|
|
cli.print_help() |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
write_compilation_database(current_keyboard, current_keymap, QMK_FIRMWARE / 'compile_commands.json') |
|
|
|
|
|
|
|
|
|
|
|
cli.log.info('Compiling keymap with {fg_cyan}%s', ' '.join(commands[-1])) |
|
|
|
cli.log.info('Compiling keymap with {fg_cyan}%s', ' '.join(commands[-1])) |
|
|
|
if not cli.args.dry_run: |
|
|
|
if not cli.args.dry_run: |
|
|
|
cli.echo('\n') |
|
|
|
cli.echo('\n') |
|
|
|