forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI: Add subcommand to generate version.h (qmk#13151)
- Loading branch information
Showing
5 changed files
with
79 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Used by the make system to generate version.h for use in code. | ||
""" | ||
from milc import cli | ||
|
||
from qmk.commands import create_version_h | ||
from qmk.path import normpath | ||
|
||
|
||
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') | ||
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") | ||
@cli.argument('--skip-git', arg_only=True, action='store_true', help='Skip Git operations') | ||
@cli.argument('--skip-all', arg_only=True, action='store_true', help='Use placeholder values for all defines (implies --skip-git)') | ||
@cli.subcommand('Used by the make system to generate version.h for use in code', hidden=True) | ||
def generate_version_h(cli): | ||
"""Generates the version.h file. | ||
""" | ||
if cli.args.skip_all: | ||
cli.args.skip_git = True | ||
|
||
version_h = create_version_h(cli.args.skip_git, cli.args.skip_all) | ||
|
||
if cli.args.output: | ||
cli.args.output.write_text(version_h) | ||
|
||
if not cli.args.quiet: | ||
cli.log.info('Wrote version.h to %s.', cli.args.output) | ||
else: | ||
print(version_h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters