compile.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. """Compile a QMK Firmware.
  2. You can compile a keymap already in the repo or using a QMK Configurator export.
  3. """
  4. from subprocess import DEVNULL
  5. from argcomplete.completers import FilesCompleter
  6. from dotty_dict import dotty
  7. from milc import cli
  8. import qmk.path
  9. from qmk.decorators import automagic_keyboard, automagic_keymap
  10. from qmk.commands import do_compile
  11. from qmk.keyboard import keyboard_completer, is_keyboard_target
  12. from qmk.keymap import keymap_completer
  13. @cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='The configurator export to compile')
  14. @cli.argument('-t', '--target', help="The make target to run. By default it compiles the keyboard only.")
  15. @cli.argument('-kb', '--keyboard', type=is_keyboard_target, completer=keyboard_completer, help='The keyboard to build a firmware for. Ignored when a configurator export is supplied.')
  16. @cli.argument('-km', '--keymap', completer=keymap_completer, help='The keymap to build a firmware for. Ignored when a configurator export is supplied.')
  17. @cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't actually build, just show the make command to be run.")
  18. @cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs to run.")
  19. @cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter your list against info.json.")
  20. @cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.")
  21. @cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
  22. @cli.subcommand('Compile a QMK Firmware.')
  23. @automagic_keyboard
  24. @automagic_keymap
  25. def compile(cli):
  26. """Compile a QMK Firmware.
  27. If a Configurator export is supplied this command will create a new keymap, overwriting an existing keymap if one exists.
  28. If a keyboard and keymap are provided this command will build a firmware based on that.
  29. """
  30. do_compile(cli.config.compile.keyboard, cli.config.compile.keymap, cli.config.compile.parallel, cli.config.compile.target)