You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

452 lines
16 KiB

7 years ago
7 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. ifndef VERBOSE
  2. .SILENT:
  3. endif
  4. # Never run this makefile in parallel, as it could screw things up
  5. # It won't affect the submakes, so you still get the speedup from specifying -jx
  6. .NOTPARALLEL:
  7. # Allow the silent with lower caps to work the same way as upper caps
  8. ifdef silent
  9. SILENT = $(silent)
  10. endif
  11. ifdef SILENT
  12. SUB_IS_SILENT := $(SILENT)
  13. endif
  14. # We need to make sure that silent is always turned off at the top level
  15. # Otherwise the [OK], [ERROR] and [WARN] messages won't be displayed correctly
  16. override SILENT := false
  17. ifdef SKIP_VERSION
  18. SKIP_GIT := yes
  19. endif
  20. ifndef SUB_IS_SILENT
  21. ifndef SKIP_GIT
  22. QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
  23. endif
  24. ifneq ($(QMK_VERSION),)
  25. $(info QMK Firmware $(QMK_VERSION))
  26. endif
  27. endif
  28. # Determine which qmk cli to use
  29. QMK_BIN := qmk
  30. # avoid 'Entering|Leaving directory' messages
  31. MAKEFLAGS += --no-print-directory
  32. ON_ERROR := error_occurred=1
  33. BREAK_ON_ERRORS = no
  34. STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
  35. ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
  36. ROOT_DIR := $(dir $(ROOT_MAKEFILE))
  37. ifeq ($(ROOT_DIR),)
  38. ROOT_DIR := .
  39. endif
  40. ABS_STARTING_MAKEFILE := $(abspath $(STARTING_MAKEFILE))
  41. ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE))
  42. ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE))
  43. ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
  44. STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
  45. include paths.mk
  46. TEST_OUTPUT_DIR := $(BUILD_DIR)/test
  47. ERROR_FILE := $(BUILD_DIR)/error_occurred
  48. .DEFAULT_GOAL := all:all
  49. # Compare the start of the RULE variable with the first argument($1)
  50. # If the rules equals $1 or starts with $1:, RULE_FOUND is set to true
  51. # and $1 is removed from the RULE variable
  52. # Otherwise the RULE_FOUND variable is set to false, and RULE left as it was
  53. # The function is a bit tricky, since there's no built in $(startswith) function
  54. define COMPARE_AND_REMOVE_FROM_RULE_HELPER
  55. ifeq ($1,$$(RULE))
  56. RULE:=
  57. RULE_FOUND := true
  58. else
  59. STARTCOLON_REMOVED=$$(subst START$1:,,START$$(RULE))
  60. ifneq ($$(STARTCOLON_REMOVED),START$$(RULE))
  61. RULE_FOUND := true
  62. RULE := $$(STARTCOLON_REMOVED)
  63. else
  64. RULE_FOUND := false
  65. endif
  66. endif
  67. endef
  68. # This makes it easier to call COMPARE_AND_REMOVE_FROM_RULE, since it makes it behave like
  69. # a function that returns the value
  70. COMPARE_AND_REMOVE_FROM_RULE = $(eval $(call COMPARE_AND_REMOVE_FROM_RULE_HELPER,$1))$(RULE_FOUND)
  71. # Try to find a match for the start of the rule to be checked
  72. # $1 The list to be checked
  73. # If a match is found, then RULE_FOUND is set to true
  74. # and MATCHED_ITEM to the item that was matched
  75. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER
  76. # Split on ":", padding with empty strings to avoid indexing issues
  77. TOKEN1:=$$(shell python3 -c "import sys; print((sys.argv[1].split(':',1)+[''])[0])" $$(RULE))
  78. TOKENr:=$$(shell python3 -c "import sys; print((sys.argv[1].split(':',1)+[''])[1])" $$(RULE))
  79. FOUNDx:=$$(shell echo $1 | tr " " "\n" | grep -Fx $$(TOKEN1))
  80. ifneq ($$(FOUNDx),)
  81. RULE := $$(TOKENr)
  82. RULE_FOUND := true
  83. MATCHED_ITEM := $$(TOKEN1)
  84. else
  85. RULE_FOUND := false
  86. MATCHED_ITEM :=
  87. endif
  88. endef
  89. # Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST
  90. TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
  91. define ALL_IN_LIST_LOOP
  92. OLD_RULE$1 := $$(RULE)
  93. $$(eval $$(call $1,$$(ITEM$1)))
  94. RULE := $$(OLD_RULE$1)
  95. endef
  96. define PARSE_ALL_IN_LIST
  97. $$(foreach ITEM$1,$2,$$(eval $$(call ALL_IN_LIST_LOOP,$1)))
  98. endef
  99. # The entry point for rule parsing
  100. # parses a rule in the format <keyboard>:<keymap>:<target>
  101. # but this particular function only deals with the first <keyboard> part
  102. define PARSE_RULE
  103. RULE := $1
  104. COMMANDS :=
  105. REQUIRE_PLATFORM_KEY :=
  106. # If the rule starts with all, then continue the parsing from
  107. # PARSE_ALL_KEYBOARDS
  108. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
  109. KEYBOARD_RULE=all
  110. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  111. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-avr),true)
  112. KEYBOARD_RULE=all
  113. REQUIRE_PLATFORM_KEY := avr
  114. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  115. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-chibios),true)
  116. KEYBOARD_RULE=all
  117. REQUIRE_PLATFORM_KEY := chibios
  118. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  119. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-arm_atsam),true)
  120. KEYBOARD_RULE=all
  121. REQUIRE_PLATFORM_KEY := arm_atsam
  122. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  123. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true)
  124. $$(eval $$(call PARSE_TEST))
  125. # If the rule starts with the name of a known keyboard, then continue
  126. # the parsing from PARSE_KEYBOARD
  127. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(shell util/list_keyboards.sh | sort -u)),true)
  128. KEYBOARD_RULE=$$(MATCHED_ITEM)
  129. $$(eval $$(call PARSE_KEYBOARD,$$(MATCHED_ITEM)))
  130. else
  131. $$(info make: *** No rule to make target '$1'. Stop.)
  132. $$(info |)
  133. $$(info | QMK's make format is:)
  134. $$(info | make keyboard_folder:keymap_folder[:target])
  135. $$(info |)
  136. $$(info | Where `keyboard_folder` is the path to the keyboard relative to)
  137. $$(info | `qmk_firmware/keyboards/`, and `keymap_folder` is the name of the)
  138. $$(info | keymap folder under that board's `keymaps/` directory.)
  139. $$(info |)
  140. $$(info | Examples:)
  141. $$(info | keyboards/dz60, keyboards/dz60/keymaps/default)
  142. $$(info | -> make dz60:default)
  143. $$(info | -> qmk compile -kb dz60 -km default)
  144. $$(info | keyboards/planck/rev6, keyboards/planck/keymaps/default)
  145. $$(info | -> make planck/rev6:default:flash)
  146. $$(info | -> qmk flash -kb planck/rev6 -km default)
  147. $$(info |)
  148. endif
  149. endef
  150. # $1 = Keyboard
  151. # Parses a rule in the format <keymap>:<target>
  152. # the keyboard is already known when entering this function
  153. define PARSE_KEYBOARD
  154. # If we want to compile the default subproject, then we need to
  155. # include the correct makefile to determine the actual name of it
  156. CURRENT_KB := $1
  157. # KEYBOARD_FOLDERS := $$(subst /, , $(CURRENT_KB))
  158. DEFAULT_FOLDER := $$(CURRENT_KB)
  159. # We assume that every rules.mk will contain the full default value
  160. $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
  161. ifneq ($$(DEFAULT_FOLDER),$$(CURRENT_KB))
  162. $$(eval include $(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk)
  163. endif
  164. CURRENT_KB := $$(DEFAULT_FOLDER)
  165. # 5/4/3/2/1
  166. KEYBOARD_FOLDER_PATH_1 := $$(CURRENT_KB)
  167. KEYBOARD_FOLDER_PATH_2 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_1)))
  168. KEYBOARD_FOLDER_PATH_3 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_2)))
  169. KEYBOARD_FOLDER_PATH_4 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_3)))
  170. KEYBOARD_FOLDER_PATH_5 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_4)))
  171. KEYMAPS :=
  172. # get a list of all keymaps
  173. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/*/.)))
  174. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/*/.)))
  175. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
  176. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
  177. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
  178. KEYBOARD_LAYOUTS := $(shell $(QMK_BIN) list-layouts --keyboard $1)
  179. LAYOUT_KEYMAPS :=
  180. $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
  181. KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
  182. # if the rule after removing the start of it is empty (we haven't specified a kemap or target)
  183. # compile all the keymaps
  184. ifeq ($$(RULE),)
  185. $$(eval $$(call PARSE_ALL_KEYMAPS))
  186. # The same if all was specified
  187. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
  188. $$(eval $$(call PARSE_ALL_KEYMAPS))
  189. # List all keymaps for the given keyboard
  190. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,list-keymaps),true)
  191. $$(eval $$(call LIST_ALL_KEYMAPS))
  192. # Try to match the specified keyamp with the list of known keymaps
  193. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true)
  194. $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM)))
  195. # Otherwise try to match the keymap from the current folder, or arguments to the make command
  196. else ifneq ($$(KEYMAP),)
  197. $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP)))
  198. # Otherwise if we are running make all:<user> just skip
  199. else ifeq ($$(KEYBOARD_RULE),all)
  200. # $$(info Skipping: No user keymap for $$(CURRENT_KB))
  201. # Otherwise, make all keymaps, again this is consistent with how it works without
  202. # any arguments
  203. else
  204. $$(eval $$(call PARSE_ALL_KEYMAPS))
  205. endif
  206. endef
  207. # if we are going to compile all keyboards, match the rest of the rule
  208. # for each of them
  209. define PARSE_ALL_KEYBOARDS
  210. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell util/list_keyboards.sh noci | sort -u)))
  211. endef
  212. # Prints a list of all known keymaps for the given keyboard
  213. define LIST_ALL_KEYMAPS
  214. COMMAND_true_LIST_KEYMAPS := \
  215. printf "$$(KEYMAPS)\n";
  216. COMMAND_false_LIST_KEYMAPS := \
  217. printf "$$(MSG_AVAILABLE_KEYMAPS)\n"; \
  218. printf "$$(KEYMAPS)\n";
  219. COMMANDS += LIST_KEYMAPS
  220. endef
  221. # $1 Keymap
  222. # This is the meat of compiling a keyboard, when entering this, everything is known
  223. # keyboard, subproject, and keymap
  224. # Note that we are not directly calling the command here, but instead building a list,
  225. # which will later be processed
  226. define PARSE_KEYMAP
  227. CURRENT_KM = $1
  228. # The rest of the rule is the target
  229. # Remove the leading ":" from the target, as it acts as a separator
  230. MAKE_TARGET := $$(patsubst :%,%,$$(RULE))
  231. # We need to generate an unique indentifer to append to the COMMANDS list
  232. CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB))
  233. COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM)
  234. # If we are compiling a keyboard without a subproject, we want to display just the name
  235. # of the keyboard, otherwise keyboard/subproject
  236. KB_SP := $$(CURRENT_KB)
  237. # Format it in bold
  238. KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
  239. # Specify the variables that we are passing forward to submake
  240. MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) REQUIRE_PLATFORM_KEY=$$(REQUIRE_PLATFORM_KEY) QMK_BIN=$$(QMK_BIN)
  241. # And the first part of the make command
  242. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f $(BUILDDEFS_PATH)/build_keyboard.mk $$(MAKE_TARGET)
  243. # The message to display
  244. MAKE_MSG := $$(MSG_MAKE_KB)
  245. # We run the command differently, depending on if we want more output or not
  246. # The true version for silent output and the false version otherwise
  247. $$(eval $$(call BUILD))
  248. endef
  249. define BUILD
  250. MAKE_VARS += VERBOSE=$(VERBOSE) COLOR=$(COLOR)
  251. COMMANDS += $$(COMMAND)
  252. COMMAND_true_$$(COMMAND) := \
  253. printf "$$(MAKE_MSG)" | \
  254. $$(MAKE_MSG_FORMAT); \
  255. LOG=$$$$($$(MAKE_CMD) $$(MAKE_VARS) SILENT=true 2>&1) ; \
  256. if [ $$$$? -gt 0 ]; \
  257. then $$(PRINT_ERROR_PLAIN); \
  258. elif [ "$$$$LOG" = "skipped" ] ; \
  259. then $$(PRINT_SKIPPED_PLAIN); \
  260. elif [ "$$$$LOG" != "" ] ; \
  261. then $$(PRINT_WARNING_PLAIN); \
  262. else \
  263. $$(PRINT_OK); \
  264. fi;
  265. COMMAND_false_$$(COMMAND) := \
  266. printf "$$(MAKE_MSG)\n\n"; \
  267. $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; \
  268. if [ $$$$? -gt 0 ]; \
  269. then error_occurred=1; \
  270. fi;
  271. endef
  272. # Just parse all the keymaps for a specific keyboard
  273. define PARSE_ALL_KEYMAPS
  274. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
  275. endef
  276. define BUILD_TEST
  277. TEST_PATH := $1
  278. TEST_NAME := $$(notdir $$(TEST_PATH))
  279. MAKE_TARGET := $2
  280. COMMAND := $1
  281. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f $(BUILDDEFS_PATH)/build_test.mk $$(MAKE_TARGET)
  282. MAKE_VARS := TEST=$$(TEST_NAME) TEST_PATH=$$(TEST_PATH) FULL_TESTS="$$(FULL_TESTS)"
  283. MAKE_MSG := $$(MSG_MAKE_TEST)
  284. $$(eval $$(call BUILD))
  285. ifneq ($$(MAKE_TARGET),clean)
  286. TEST_EXECUTABLE := $$(TEST_OUTPUT_DIR)/$$(TEST_NAME).elf
  287. TESTS += $$(TEST_NAME)
  288. TEST_MSG := $$(MSG_TEST)
  289. $$(TEST_NAME)_COMMAND := \
  290. printf "$$(TEST_MSG)\n"; \
  291. $$(TEST_EXECUTABLE); \
  292. if [ $$$$? -gt 0 ]; \
  293. then error_occurred=1; \
  294. fi; \
  295. printf "\n";
  296. endif
  297. endef
  298. define PARSE_TEST
  299. TESTS :=
  300. TEST_NAME := $$(firstword $$(subst :, ,$$(RULE)))
  301. TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE)))
  302. include $(BUILDDEFS_PATH)/testlist.mk
  303. ifeq ($$(TEST_NAME),all)
  304. MATCHED_TESTS := $$(TEST_LIST)
  305. else
  306. MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME), $$(notdir $$(TEST))), $$(TEST),))
  307. endif
  308. $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET))))
  309. endef
  310. # Set the silent mode depending on if we are trying to compile multiple keyboards or not
  311. # By default it's on in that case, but it can be overridden by specifying silent=false
  312. # from the command line
  313. define SET_SILENT_MODE
  314. ifdef SUB_IS_SILENT
  315. SILENT_MODE := $(SUB_IS_SILENT)
  316. else ifeq ($$(words $$(COMMANDS)),1)
  317. SILENT_MODE := false
  318. else
  319. SILENT_MODE := true
  320. endif
  321. endef
  322. include $(BUILDDEFS_PATH)/message.mk
  323. ifeq ($(strip $(BREAK_ON_ERRORS)), yes)
  324. HANDLE_ERROR = exit 1
  325. else
  326. HANDLE_ERROR = echo $$error_occurred > $(ERROR_FILE)
  327. endif
  328. # The empty line is important here, as it will force a new shell to be created for each command
  329. # Otherwise the command line will become too long with a lot of keyboards and keymaps
  330. define RUN_COMMAND
  331. +error_occurred=0;\
  332. $(COMMAND_$(SILENT_MODE)_$(COMMAND))\
  333. if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
  334. endef
  335. define RUN_TEST
  336. +error_occurred=0;\
  337. $($(TEST)_COMMAND)\
  338. if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
  339. endef
  340. # Catch everything and parse the command line ourselves.
  341. .PHONY: %
  342. %:
  343. # Check if we have the CMP tool installed
  344. cmp $(ROOT_DIR)/Makefile $(ROOT_DIR)/Makefile >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
  345. # Ensure that $(QMK_BIN) works.
  346. if ! $(QMK_BIN) hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; exit 1; fi
  347. # Check if the submodules are dirty, and display a warning if they are
  348. ifndef SKIP_GIT
  349. if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 50 --init lib/chibios; fi
  350. if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --depth 50 --init lib/chibios-contrib; fi
  351. if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
  352. if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
  353. if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
  354. git submodule status --recursive 2>/dev/null | \
  355. while IFS= read -r x; do \
  356. case "$$x" in \
  357. \ *) ;; \
  358. *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \
  359. esac \
  360. done
  361. endif
  362. rm -f $(ERROR_FILE) > /dev/null 2>&1
  363. $(eval $(call PARSE_RULE,$@))
  364. $(eval $(call SET_SILENT_MODE))
  365. # Run all the commands in the same shell, notice the + at the first line
  366. # it has to be there to allow parallel execution of the submake
  367. # This always tries to compile everything, even if error occurs in the middle
  368. # But we return the error code at the end, to trigger travis failures
  369. # The sort at this point is to remove duplicates
  370. $(foreach COMMAND,$(sort $(COMMANDS)),$(RUN_COMMAND))
  371. if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
  372. $(foreach TEST,$(sort $(TESTS)),$(RUN_TEST))
  373. if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
  374. lib/%:
  375. git submodule sync $?
  376. git submodule update --init $?
  377. .PHONY: git-submodule
  378. git-submodule:
  379. git submodule sync --recursive
  380. git submodule update --init --recursive --progress
  381. .PHONY: list-keyboards
  382. list-keyboards:
  383. util/list_keyboards.sh | sort -u | tr '\n' ' '
  384. .PHONY: generate-keyboards-file
  385. generate-keyboards-file:
  386. util/list_keyboards.sh | sort -u
  387. .PHONY: clean
  388. clean:
  389. echo -n 'Deleting .build/ ... '
  390. rm -rf $(BUILD_DIR)
  391. echo 'done.'
  392. .PHONY: distclean
  393. distclean: clean
  394. echo -n 'Deleting *.bin, *.hex, and *.uf2 ... '
  395. rm -f *.bin *.hex *.uf2
  396. echo 'done.'