version_h.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. """Used by the make system to generate version.h for use in code.
  2. """
  3. from milc import cli
  4. from qmk.commands import create_version_h
  5. from qmk.path import normpath
  6. @cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
  7. @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
  8. @cli.argument('--skip-git', arg_only=True, action='store_true', help='Skip Git operations')
  9. @cli.argument('--skip-all', arg_only=True, action='store_true', help='Use placeholder values for all defines (implies --skip-git)')
  10. @cli.subcommand('Used by the make system to generate version.h for use in code', hidden=True)
  11. def generate_version_h(cli):
  12. """Generates the version.h file.
  13. """
  14. if cli.args.skip_all:
  15. cli.args.skip_git = True
  16. version_h = create_version_h(cli.args.skip_git, cli.args.skip_all)
  17. if cli.args.output:
  18. cli.args.output.write_text(version_h)
  19. if not cli.args.quiet:
  20. cli.log.info('Wrote version.h to %s.', cli.args.output)
  21. else:
  22. print(version_h)