|
@@ -3,7 +3,6 @@
|
|
You can compile a keymap already in the repo or using a QMK Configurator export.
|
|
You can compile a keymap already in the repo or using a QMK Configurator export.
|
|
A bootloader must be specified.
|
|
A bootloader must be specified.
|
|
"""
|
|
"""
|
|
-import subprocess
|
|
|
|
from argparse import FileType
|
|
from argparse import FileType
|
|
|
|
|
|
from milc import cli
|
|
from milc import cli
|
|
@@ -37,6 +36,9 @@ def print_bootloader_help():
|
|
@cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
|
|
@cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
|
|
@cli.argument('-kb', '--keyboard', help='The keyboard to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
|
|
@cli.argument('-kb', '--keyboard', help='The keyboard to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.')
|
|
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
|
|
@cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
|
|
|
|
+@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs to run.")
|
|
|
|
+@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.subcommand('QMK Flash.')
|
|
@cli.subcommand('QMK Flash.')
|
|
@automagic_keyboard
|
|
@automagic_keyboard
|
|
@automagic_keymap
|
|
@automagic_keymap
|
|
@@ -50,6 +52,20 @@ def flash(cli):
|
|
|
|
|
|
If bootloader is omitted the make system will use the configured bootloader for that keyboard.
|
|
If bootloader is omitted the make system will use the configured bootloader for that keyboard.
|
|
"""
|
|
"""
|
|
|
|
+ if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
|
|
|
|
+ command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, 'clean')
|
|
|
|
+ cli.run(command, capture_output=False)
|
|
|
|
+
|
|
|
|
+ # Build the environment vars
|
|
|
|
+ envs = {}
|
|
|
|
+ for env in cli.args.env:
|
|
|
|
+ if '=' in env:
|
|
|
|
+ key, value = env.split('=', 1)
|
|
|
|
+ envs[key] = value
|
|
|
|
+ else:
|
|
|
|
+ cli.log.warning('Invalid environment variable: %s', env)
|
|
|
|
+
|
|
|
|
+ # Determine the compile command
|
|
command = ''
|
|
command = ''
|
|
|
|
|
|
if cli.args.bootloaders:
|
|
if cli.args.bootloaders:
|
|
@@ -60,16 +76,16 @@ def flash(cli):
|
|
|
|
|
|
if cli.args.filename:
|
|
if cli.args.filename:
|
|
# Handle compiling a configurator JSON
|
|
# Handle compiling a configurator JSON
|
|
- user_keymap = parse_configurator_json(cli.args.filename)
|
|
|
|
|
|
+ user_keymap = parse_configurator_json(cli.args.filename, parallel=cli.config.flash.parallel)
|
|
keymap_path = qmk.path.keymap(user_keymap['keyboard'])
|
|
keymap_path = qmk.path.keymap(user_keymap['keyboard'])
|
|
- command = compile_configurator_json(user_keymap, cli.args.bootloader)
|
|
|
|
|
|
+ command = compile_configurator_json(user_keymap, cli.args.bootloader, **envs)
|
|
|
|
|
|
cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap'])
|
|
cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap'])
|
|
|
|
|
|
else:
|
|
else:
|
|
if cli.config.flash.keyboard and cli.config.flash.keymap:
|
|
if cli.config.flash.keyboard and cli.config.flash.keymap:
|
|
# Generate the make command for a specific keyboard/keymap.
|
|
# Generate the make command for a specific keyboard/keymap.
|
|
- command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, cli.args.bootloader)
|
|
|
|
|
|
+ command = create_make_command(cli.config.flash.keyboard, cli.config.flash.keymap, cli.args.bootloader, parallel=cli.config.flash.parallel, **envs)
|
|
|
|
|
|
elif not cli.config.flash.keyboard:
|
|
elif not cli.config.flash.keyboard:
|
|
cli.log.error('Could not determine keyboard!')
|
|
cli.log.error('Could not determine keyboard!')
|
|
@@ -81,7 +97,7 @@ def flash(cli):
|
|
cli.log.info('Compiling keymap with {fg_cyan}%s', ' '.join(command))
|
|
cli.log.info('Compiling keymap with {fg_cyan}%s', ' '.join(command))
|
|
if not cli.args.dry_run:
|
|
if not cli.args.dry_run:
|
|
cli.echo('\n')
|
|
cli.echo('\n')
|
|
- compile = subprocess.run(command)
|
|
|
|
|
|
+ compile = cli.run(command, capture_output=False, text=True)
|
|
return compile.returncode
|
|
return compile.returncode
|
|
|
|
|
|
else:
|
|
else:
|