message.mk 5.3 KB

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