aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/mass_compile.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/cli/mass_compile.py')
-rwxr-xr-xlib/python/qmk/cli/mass_compile.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/python/qmk/cli/mass_compile.py b/lib/python/qmk/cli/mass_compile.py
index d13afc6143..cf9be0fd1e 100755
--- a/lib/python/qmk/cli/mass_compile.py
+++ b/lib/python/qmk/cli/mass_compile.py
@@ -7,6 +7,7 @@ from typing import List
from pathlib import Path
from subprocess import DEVNULL
from milc import cli
+import shlex
from qmk.constants import QMK_FIRMWARE
from qmk.commands import find_make, get_make_parallel_args, build_environment
@@ -26,7 +27,8 @@ def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool,
if dry_run:
cli.log.info('Compilation targets:')
for target in sorted(targets, key=lambda t: (t.keyboard, t.keymap)):
- cli.log.info(f"{{fg_cyan}}qmk compile -kb {target.keyboard} -km {target.keymap}{{fg_reset}}")
+ extra_args = ' '.join([f"-e {shlex.quote(f'{k}={v}')}" for k, v in target.extra_args.items()])
+ cli.log.info(f"{{fg_cyan}}qmk compile -kb {target.keyboard} -km {target.keymap} {extra_args}{{fg_reset}}")
else:
if clean:
cli.run([make_cmd, 'clean'], capture_output=False, stdin=DEVNULL)
@@ -36,18 +38,26 @@ def mass_compile_targets(targets: List[BuildTarget], clean: bool, dry_run: bool,
for target in sorted(targets, key=lambda t: (t.keyboard, t.keymap)):
keyboard_name = target.keyboard
keymap_name = target.keymap
+ keyboard_safe = keyboard_name.replace('/', '_')
+ target_filename = target.target_name(**env)
target.configure(parallel=1) # We ignore parallelism on a per-build basis as we defer to the parent make invocation
target.prepare_build(**env) # If we've got json targets, allow them to write out any extra info to .build before we kick off `make`
command = target.compile_command(**env)
command[0] = '+@$(MAKE)' # Override the make so that we can use jobserver to handle parallelism
- keyboard_safe = keyboard_name.replace('/', '_')
+ extra_args = '_'.join([f"{k}_{v}" for k, v in target.extra_args.items()])
build_log = f"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
failed_log = f"{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
+ target_suffix = ''
+ if len(extra_args) > 0:
+ build_log += f".{extra_args}"
+ failed_log += f".{extra_args}"
+ target_suffix = f"_{extra_args}"
# yapf: disable
f.write(
f"""\
-all: {keyboard_safe}_{keymap_name}_binary
-{keyboard_safe}_{keymap_name}_binary:
+.PHONY: {target_filename}{target_suffix}_binary
+all: {target_filename}{target_suffix}_binary
+{target_filename}{target_suffix}_binary:
@rm -f "{build_log}" || true
@echo "Compiling QMK Firmware for target: '{keyboard_name}:{keymap_name}'..." >>"{build_log}"
{' '.join(command)} \\
@@ -65,9 +75,9 @@ all: {keyboard_safe}_{keymap_name}_binary
# yapf: disable
f.write(
f"""\
- @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{keymap_name}.elf" 2>/dev/null || true
- @rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{keymap_name}.map" 2>/dev/null || true
- @rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}_{keymap_name}" || true
+ @rm -rf "{QMK_FIRMWARE}/.build/{target_filename}.elf" 2>/dev/null || true
+ @rm -rf "{QMK_FIRMWARE}/.build/{target_filename}.map" 2>/dev/null || true
+ @rm -rf "{QMK_FIRMWARE}/.build/obj_{target_filename}" || true
"""# noqa
)
# yapf: enable