forked from mirrors/qmk_userspace
		
	Add ability to remove temporary files during multibuild. (#18381)
This commit is contained in:
		
					parent
					
						
							
								617f957e82
							
						
					
				
			
			
				commit
				
					
						cf88d95613
					
				
			
		
					 1 changed files with 17 additions and 1 deletions
				
			
		| 
						 | 
					@ -28,6 +28,7 @@ def _is_split(keyboard_name):
 | 
				
			||||||
    return True if 'SPLIT_KEYBOARD' in rules_mk and rules_mk['SPLIT_KEYBOARD'].lower() == 'yes' else False
 | 
					    return True if 'SPLIT_KEYBOARD' in rules_mk and rules_mk['SPLIT_KEYBOARD'].lower() == 'yes' else False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@cli.argument('-t', '--no-temp', arg_only=True, action='store_true', help="Remove temporary files during build.")
 | 
				
			||||||
@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.")
 | 
					@cli.argument('-j', '--parallel', type=int, default=1, help="Set the number of parallel make jobs; 0 means unlimited.")
 | 
				
			||||||
@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
 | 
					@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
 | 
				
			||||||
@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on the supplied value in rules.mk. Supported format is 'SPLIT_KEYBOARD=yes'. May be passed multiple times.")
 | 
					@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on the supplied value in rules.mk. Supported format is 'SPLIT_KEYBOARD=yes'. May be passed multiple times.")
 | 
				
			||||||
| 
						 | 
					@ -77,11 +78,26 @@ all: {keyboard_safe}_binary
 | 
				
			||||||
		|| {{ grep '\[WARNINGS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;33m[WARNINGS]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" ; }} \\
 | 
							|| {{ grep '\[WARNINGS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;33m[WARNINGS]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" ; }} \\
 | 
				
			||||||
		|| printf "Build %-64s \e[1;32m[OK]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}"
 | 
							|| printf "Build %-64s \e[1;32m[OK]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}"
 | 
				
			||||||
	@rm -f "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" || true
 | 
						@rm -f "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" || true
 | 
				
			||||||
 | 
					 | 
				
			||||||
"""# noqa
 | 
					"""# noqa
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
                # yapf: enable
 | 
					                # yapf: enable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if cli.args.no_temp:
 | 
				
			||||||
 | 
					                    # yapf: disable
 | 
				
			||||||
 | 
					                    f.write(
 | 
				
			||||||
 | 
					                        f"""\
 | 
				
			||||||
 | 
						@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.elf" 2>/dev/null || true
 | 
				
			||||||
 | 
						@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.map" 2>/dev/null || true
 | 
				
			||||||
 | 
						@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.hex" 2>/dev/null || true
 | 
				
			||||||
 | 
						@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.bin" 2>/dev/null || true
 | 
				
			||||||
 | 
						@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{cli.args.keymap}.uf2" 2>/dev/null || true
 | 
				
			||||||
 | 
						@rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}" || true
 | 
				
			||||||
 | 
						@rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}_{cli.args.keymap}" || true
 | 
				
			||||||
 | 
					"""# noqa
 | 
				
			||||||
 | 
					                    )
 | 
				
			||||||
 | 
					                    # yapf: enable
 | 
				
			||||||
 | 
					                f.write('\n')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cli.run([make_cmd, *get_make_parallel_args(cli.args.parallel), '-f', makefile.as_posix(), 'all'], capture_output=False, stdin=DEVNULL)
 | 
					    cli.run([make_cmd, *get_make_parallel_args(cli.args.parallel), '-f', makefile.as_posix(), 'all'], capture_output=False, stdin=DEVNULL)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Check for failures
 | 
					    # Check for failures
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue