mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-27 03:21:15 +00:00
add support for building multiple keyboards in parallel
This commit is contained in:
parent
08b0ecb175
commit
823a74ebae
@ -5,9 +5,10 @@ import json
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import DEVNULL
|
from subprocess import DEVNULL
|
||||||
from time import strftime
|
from time import sleep, strftime
|
||||||
|
|
||||||
from dotty_dict import dotty
|
from dotty_dict import dotty
|
||||||
from milc import cli
|
from milc import cli
|
||||||
@ -17,7 +18,6 @@ from qmk.constants import QMK_FIRMWARE, KEYBOARD_OUTPUT_PREFIX
|
|||||||
from qmk.info import info_json
|
from qmk.info import info_json
|
||||||
from qmk.json_schema import json_load
|
from qmk.json_schema import json_load
|
||||||
from qmk.keyboard import list_keyboards
|
from qmk.keyboard import list_keyboards
|
||||||
from qmk.metadata import true_values, false_values
|
|
||||||
|
|
||||||
time_fmt = '%Y-%m-%d-%H:%M:%S'
|
time_fmt = '%Y-%m-%d-%H:%M:%S'
|
||||||
|
|
||||||
@ -383,9 +383,9 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
|||||||
|
|
||||||
# Run clean if necessary
|
# Run clean if necessary
|
||||||
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 kb, km 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', kb, km)
|
||||||
_, _, make_cmd = create_make_command(keyboard, keymap, 'clean', parallel, multiple_compiles, **envs)
|
make_cmd = create_make_command(kb, km, 'clean', 1, 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)
|
||||||
@ -418,8 +418,13 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
|||||||
if command == 'multiple':
|
if command == 'multiple':
|
||||||
returncodes = []
|
returncodes = []
|
||||||
for keyboard, keymap in keyboard_keymap_iter(keyboard, keymap, filters):
|
for keyboard, keymap in keyboard_keymap_iter(keyboard, keymap, filters):
|
||||||
command = create_make_command(keyboard, keymap, target=target, parallel=parallel, silent=multiple_compiles, **envs)
|
command = create_make_command(keyboard, keymap, target=target, parallel=1, silent=multiple_compiles, **envs)
|
||||||
_execute_compile(keyboard, keymap, command, target)
|
while threading.active_count() >= parallel + 1:
|
||||||
|
sleep(1)
|
||||||
|
threading.Thread(target=_execute_compile, args=(keyboard, keymap, command, target, returncodes)).start()
|
||||||
|
|
||||||
|
while threading.active_count() > 1:
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
if any(returncodes):
|
if any(returncodes):
|
||||||
print()
|
print()
|
||||||
@ -446,7 +451,10 @@ def do_compile(keyboard, keymap, parallel, target=None, filters=None, environmen
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _execute_compile(keyboard, keymap, command, target):
|
def _execute_compile(keyboard, keymap, command, target, returncodes=None):
|
||||||
|
if not returncodes:
|
||||||
|
returncodes = []
|
||||||
|
|
||||||
if keymap not in qmk.keymap.list_keymaps(keyboard):
|
if keymap not in qmk.keymap.list_keymaps(keyboard):
|
||||||
cli.log.debug('Skipping keyboard %s, no %s keymap found.', keyboard, keymap)
|
cli.log.debug('Skipping keyboard %s, no %s keymap found.', keyboard, keymap)
|
||||||
return 0
|
return 0
|
||||||
@ -460,13 +468,15 @@ def _execute_compile(keyboard, keymap, command, target):
|
|||||||
|
|
||||||
if not cli.args.dry_run:
|
if not cli.args.dry_run:
|
||||||
compile = cli.run(command, capture_output=False)
|
compile = cli.run(command, capture_output=False)
|
||||||
|
|
||||||
|
cli.acquire_lock()
|
||||||
|
returncodes.append(compile.returncode)
|
||||||
|
cli.release_lock()
|
||||||
|
|
||||||
if compile.returncode == 0:
|
if compile.returncode == 0:
|
||||||
cli.log.info('Success!')
|
cli.log.info('Success!')
|
||||||
else:
|
else:
|
||||||
cli.log.error('Failed!')
|
cli.log.error('Failed!')
|
||||||
return compile.returncode
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
|
Loading…
Reference in New Issue
Block a user