Parent directory

message.mk

5579 bytes
  1COLOR ?= true
  2
  3ifeq ($(COLOR),true)
  4	NO_COLOR=\033[0m
  5	OK_COLOR=\033[32;01m
  6	ERROR_COLOR=\033[31;01m
  7	WARN_COLOR=\033[33;01m
  8	SKIPPED_COLOR=\033[36;01m
  9	BLUE=\033[0;34m
 10	BOLD=\033[1m
 11endif
 12
 13ifneq ($(shell echo "1 2 3" | awk '{ printf "%2s", $$3; }' 2>/dev/null)," 3")
 14	AWK=awk
 15else
 16	AWK=cat && test
 17endif
 18
 19ON_ERROR ?= exit 1
 20
 21OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)\n
 22ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)\n
 23WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)\n
 24SKIPPED_STRING=$(SKIPPED_COLOR)[SKIPPED]$(NO_COLOR)\n
 25
 26TAB_LOG = printf "\n%s\n\n" "$$LOG" | $(AWK) '{ sub(/^/," | "); print }'
 27TAB_LOG_PLAIN = printf "%s\n" "$$LOG"
 28AWK_STATUS = $(AWK) '{ printf " %-10s\n", $$1; }'
 29AWK_CMD = $(AWK) '{ printf "%-99s", $$0; }'
 30PRINT_ERROR = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG) && $(ON_ERROR)
 31PRINT_WARNING = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG)
 32PRINT_ERROR_PLAIN = ($(SILENT) ||printf " $(ERROR_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN) && $(ON_ERROR)
 33PRINT_WARNING_PLAIN = ($(SILENT) || printf " $(WARN_STRING)" | $(AWK_STATUS)) && $(TAB_LOG_PLAIN)
 34PRINT_SKIPPED_PLAIN = ($(SILENT) || printf " $(SKIPPED_STRING)" | $(AWK_STATUS))
 35PRINT_OK = $(SILENT) || printf " $(OK_STRING)" | $(AWK_STATUS)
 36BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -gt 0 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi;
 37MAKE_MSG_FORMAT = $(AWK) '{ printf "%-118s", $$0;}'
 38
 39# The UNSYNC_OUTPUT_CMD command disables the `--output-sync` for the current command, if the `--output-sync` granularity is `target` or lower.
 40# This is achieved by telling make to treat the current command as if it invokes a recursive make subcommand (as if by calling `$(MAKE)`).
 41UNSYNC_OUTPUT_CMD = +true
 42
 43# Define Messages
 44# English
 45MSG_ERRORS_NONE = Errors: none
 46MSG_ERRORS = $(ERROR_COLOR)Make finished with errors\n$(NO_COLOR)
 47MSG_BEGIN = -------- begin --------
 48MSG_END = --------  end  --------
 49MSG_SIZE_BEFORE = Size before:
 50MSG_SIZE_AFTER = Size after:
 51MSG_COFF = Converting to AVR COFF:
 52MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
 53MSG_FLASH = Creating load file for flashing:
 54MSG_UF2 = Creating UF2 file for deployment:
 55MSG_EEPROM = Creating load file for EEPROM:
 56MSG_BIN = Creating binary load file for flashing:
 57MSG_EXTENDED_LISTING = Creating Extended Listing:
 58MSG_SYMBOL_TABLE = Creating Symbol Table:
 59MSG_EXECUTING = Executing:
 60MSG_LINKING = Linking:
 61MSG_COMPILING = Compiling:
 62MSG_COMPILING_CXX = Compiling:
 63MSG_ASSEMBLING = Assembling:
 64MSG_CLEANING = Cleaning project:
 65MSG_CREATING_LIBRARY = Creating library:
 66MSG_GENERATING = Generating:
 67MSG_NOT_REPO = $(WARN_COLOR)WARNING:$(NO_COLOR) Target folder is not a git repo, you probably downloaded a zip file instead of cloning.\n\
 68Please consider following $(BOLD)https://docs.qmk.fm/\#/newbs_getting_started$(NO_COLOR).\n\n
 69MSG_SUBMODULE_DIRTY = $(WARN_COLOR)WARNING:$(NO_COLOR) Some git submodules are out of date or modified.\n\
 70Please consider running $(BOLD)qmk git-submodule$(NO_COLOR).\n\n
 71
 72define GENERATE_MSG_MAKE_KB
 73    MSG_MAKE_KB_ACTUAL := Making $$(KB_SP) with keymap $(BOLD)$$(CURRENT_KM)$(NO_COLOR)
 74    ifneq ($$(MAKE_TARGET),)
 75        MSG_MAKE_KB_ACTUAL += and target $(BOLD)$$(MAKE_TARGET)$(NO_COLOR)
 76    endif
 77endef
 78MSG_MAKE_KB = $(eval $(call GENERATE_MSG_MAKE_KB))$(MSG_MAKE_KB_ACTUAL)
 79define GENERATE_MSG_MAKE_TEST
 80    MSG_MAKE_TEST_ACTUAL := Making test $(BOLD)$(TEST_NAME)$(NO_COLOR)
 81    ifneq ($$(MAKE_TARGET),)
 82        MSG_MAKE_TEST_ACTUAL += with target $(BOLD)$$(MAKE_TARGET)$(NO_COLOR)
 83    endif
 84endef
 85MSG_MAKE_TEST = $(eval $(call GENERATE_MSG_MAKE_TEST))$(MSG_MAKE_TEST_ACTUAL)
 86MSG_TEST = Testing $(BOLD)$(TEST_NAME)$(NO_COLOR)
 87define GENERATE_MSG_AVAILABLE_KEYMAPS
 88    MSG_AVAILABLE_KEYMAPS_ACTUAL := Available keymaps for $(BOLD)$$(CURRENT_KB)$(NO_COLOR):
 89endef
 90MSG_AVAILABLE_KEYMAPS = $(eval $(call GENERATE_MSG_AVAILABLE_KEYMAPS))$(MSG_AVAILABLE_KEYMAPS_ACTUAL)
 91
 92MSG_BOOTLOADER_NOT_FOUND_BASE = Bootloader not found. Make sure the board is in bootloader mode. See https://docs.qmk.fm/\#/newbs_flashing\n
 93MSG_CHECK_FILESIZE = Checking file size of $(TARGET).$(FIRMWARE_FORMAT)
 94MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) bytes over)\n
 95MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n
 96MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
 97MSG_FILE_NEAR_LIMIT = The firmware size is approaching the maximum - $(CURRENT_SIZE)/$(MAX_SIZE) ($(PERCENT_SIZE)%%, $(FREE_SIZE) bytes free)\n
 98MSG_PYTHON_MISSING = $(ERROR_COLOR)ERROR:$(NO_COLOR) Cannot run \"qmk hello\"!\n\n\
 99	Please run $(BOLD)qmk setup$(NO_COLOR) to install all the dependencies QMK requires.\n\n
100MSG_FLASH_BOOTLOADER = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's bootloader is not specified or is not supported by the \":flash\" target at this time.\n\n
101MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n
102MSG_BOOTLOADER_NOT_FOUND = $(ERROR_COLOR)ERROR:$(NO_COLOR) $(MSG_BOOTLOADER_NOT_FOUND_BASE) Trying again in 5s (Ctrl+C to cancel)\n
103BOOTLOADER_RETRY_TIME ?= 0.5
104MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY = $(MSG_BOOTLOADER_NOT_FOUND_BASE) Trying again every $(BOOTLOADER_RETRY_TIME)s (Ctrl+C to cancel)
105
106define WARNING_MESSAGE
107    $(shell printf "\n %-99s $(WARN_STRING)\n" "$1" >&2)
108endef
109
110define CATASTROPHIC_ERROR
111    $(shell printf "\n * %-99s $(ERROR_STRING)\n" "$2" >&2)
112    $(error $1)
113endef