compile matching boards as we find them, not after building the whole list
This commit is contained in:
parent
b4e18c9019
commit
08b0ecb175
1 changed files with 46 additions and 30 deletions
|
@ -103,7 +103,7 @@ def create_make_command(keyboard, keymap, target=None, parallel=1, silent=False,
|
||||||
for key, value in env_vars.items():
|
for key, value in env_vars.items():
|
||||||
make_cmd.append(f'{key}={value}')
|
make_cmd.append(f'{key}={value}')
|
||||||
|
|
||||||
return keyboard, keymap, make_cmd
|
return make_cmd
|
||||||
|
|
||||||
|
|
||||||
def get_git_version(current_time, repo_dir='.', check_dir='.'):
|
def get_git_version(current_time, repo_dir='.', check_dir='.'):
|
||||||
|
@ -362,10 +362,13 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
||||||
if environment is None:
|
if environment is None:
|
||||||
environment = {}
|
environment = {}
|
||||||
|
|
||||||
envs = {'REQUIRE_PLATFORM_KEY': ''}
|
all_keyboards = keyboard == 'all' or keyboard.startswith('all-')
|
||||||
silent = keyboard == 'all' or keyboard.startswith('all-') or keymap == 'all'
|
all_keymaps = keymap == 'all'
|
||||||
|
multiple_compiles = all_keyboards or all_keymaps
|
||||||
|
|
||||||
# Setup the environment
|
# Setup the environment
|
||||||
|
envs = {'REQUIRE_PLATFORM_KEY': ''}
|
||||||
|
|
||||||
for env in environment:
|
for env in environment:
|
||||||
if '=' in env:
|
if '=' in env:
|
||||||
key, value = env.split('=', 1)
|
key, value = env.split('=', 1)
|
||||||
|
@ -382,11 +385,11 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
||||||
if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
|
if cli.args.clean and not cli.args.filename and not cli.args.dry_run:
|
||||||
for keyboard, keymap in keyboard_keymap_iter(keyboard, keymap):
|
for keyboard, keymap in keyboard_keymap_iter(keyboard, keymap):
|
||||||
cli.log.info('Cleaning previous build files for keyboard {fg_cyan}%s{fg_reset} keymap {fg_cyan}%s', keyboard, keymap)
|
cli.log.info('Cleaning previous build files for keyboard {fg_cyan}%s{fg_reset} keymap {fg_cyan}%s', keyboard, keymap)
|
||||||
_, _, make_cmd = create_make_command(keyboard, keymap, 'clean', parallel, silent, **envs)
|
_, _, make_cmd = create_make_command(keyboard, keymap, 'clean', parallel, multiple_compiles, **envs)
|
||||||
cli.run(make_cmd, capture_output=False, stdin=DEVNULL)
|
cli.run(make_cmd, capture_output=False, stdin=DEVNULL)
|
||||||
|
|
||||||
# Determine the compile command(s)
|
# Determine the compile command(s)
|
||||||
commands = None
|
command = None
|
||||||
|
|
||||||
if cli.args.filename:
|
if cli.args.filename:
|
||||||
if cli.args.keyboard:
|
if cli.args.keyboard:
|
||||||
|
@ -397,13 +400,13 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
||||||
|
|
||||||
# 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)
|
||||||
commands = [compile_configurator_json(user_keymap, parallel=parallel, **envs)]
|
command = compile_configurator_json(user_keymap, parallel=parallel, **envs)
|
||||||
|
|
||||||
elif keyboard and keymap:
|
elif keyboard and keymap:
|
||||||
if filters:
|
if multiple_compiles:
|
||||||
cli.log.info('Generating the list of keyboards to compile, this may take some time.')
|
command = 'multiple'
|
||||||
|
else:
|
||||||
commands = [create_make_command(keyboard, keymap, target=target, parallel=parallel, silent=silent, **envs) for keyboard, keymap in keyboard_keymap_iter(keyboard, keymap, filters)]
|
command = create_make_command(keyboard, keymap, target=target, parallel=parallel, silent=multiple_compiles, **envs)
|
||||||
|
|
||||||
elif not keyboard:
|
elif not keyboard:
|
||||||
cli.log.error('Could not determine keyboard!')
|
cli.log.error('Could not determine keyboard!')
|
||||||
|
@ -412,27 +415,11 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
||||||
cli.log.error('Could not determine keymap!')
|
cli.log.error('Could not determine keymap!')
|
||||||
|
|
||||||
# Compile the firmware, if we're able to
|
# Compile the firmware, if we're able to
|
||||||
if commands:
|
if command == 'multiple':
|
||||||
returncodes = []
|
returncodes = []
|
||||||
for keyboard, keymap, command in commands:
|
for keyboard, keymap in keyboard_keymap_iter(keyboard, keymap, filters):
|
||||||
if keymap not in qmk.keymap.list_keymaps(keyboard):
|
command = create_make_command(keyboard, keymap, target=target, parallel=parallel, silent=multiple_compiles, **envs)
|
||||||
cli.log.debug('Skipping keyboard %s, no %s keymap found.', keyboard, keymap)
|
_execute_compile(keyboard, keymap, command, target)
|
||||||
continue
|
|
||||||
|
|
||||||
print()
|
|
||||||
if target:
|
|
||||||
cli.log.info('Building firmware for {fg_cyan}%s{fg_reset} with keymap {fg_cyan}%s{fg_reset} and target {fg_cyan}%s', keyboard, keymap, target)
|
|
||||||
else:
|
|
||||||
cli.log.info('Building firmware for {fg_cyan}%s{fg_reset} with keymap {fg_cyan}%s', keyboard, keymap)
|
|
||||||
cli.log.debug('Running make command: {fg_blue}%s', ' '.join(command))
|
|
||||||
|
|
||||||
if not cli.args.dry_run:
|
|
||||||
compile = cli.run(command, capture_output=False)
|
|
||||||
returncodes.append(compile.returncode)
|
|
||||||
if compile.returncode == 0:
|
|
||||||
cli.log.info('Success!')
|
|
||||||
else:
|
|
||||||
cli.log.error('Failed!')
|
|
||||||
|
|
||||||
if any(returncodes):
|
if any(returncodes):
|
||||||
print()
|
print()
|
||||||
|
@ -443,6 +430,12 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
||||||
keyboard, keymap, command = commands[i]
|
keyboard, keymap, command = commands[i]
|
||||||
cli.echo('\tkeyboard: {fg_cyan}%s{fg_reset} keymap: {fg_cyan}%s', keyboard, keymap)
|
cli.echo('\tkeyboard: {fg_cyan}%s{fg_reset} keymap: {fg_cyan}%s', keyboard, keymap)
|
||||||
|
|
||||||
|
elif command:
|
||||||
|
if _execute_compile(keyboard, keymap, command, target) != 0:
|
||||||
|
print()
|
||||||
|
cli.log.error('Could not compile all targets, look above this message for more details. Failing target(s):')
|
||||||
|
cli.echo('\tkeyboard: {fg_cyan}%s{fg_reset} keymap: {fg_cyan}%s', keyboard, keymap)
|
||||||
|
|
||||||
elif filters:
|
elif filters:
|
||||||
cli.log.error('No keyboards found after applying filter(s)!')
|
cli.log.error('No keyboards found after applying filter(s)!')
|
||||||
return False
|
return False
|
||||||
|
@ -453,6 +446,29 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _execute_compile(keyboard, keymap, command, target):
|
||||||
|
if keymap not in qmk.keymap.list_keymaps(keyboard):
|
||||||
|
cli.log.debug('Skipping keyboard %s, no %s keymap found.', keyboard, keymap)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
print()
|
||||||
|
if target:
|
||||||
|
cli.log.info('Building firmware for {fg_cyan}%s{fg_reset} with keymap {fg_cyan}%s{fg_reset} and target {fg_cyan}%s', keyboard, keymap, target)
|
||||||
|
else:
|
||||||
|
cli.log.info('Building firmware for {fg_cyan}%s{fg_reset} with keymap {fg_cyan}%s', keyboard, keymap)
|
||||||
|
cli.log.debug('Running make command: {fg_blue}%s', ' '.join(command))
|
||||||
|
|
||||||
|
if not cli.args.dry_run:
|
||||||
|
compile = cli.run(command, capture_output=False)
|
||||||
|
if compile.returncode == 0:
|
||||||
|
cli.log.info('Success!')
|
||||||
|
else:
|
||||||
|
cli.log.error('Failed!')
|
||||||
|
return compile.returncode
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
def _keyboard_list(keyboard):
|
def _keyboard_list(keyboard):
|
||||||
"""Returns a list of keyboards matching keyboard.
|
"""Returns a list of keyboards matching keyboard.
|
||||||
|
|
Loading…
Reference in a new issue