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.

509 lines
18 KiB

7 years ago
7 years ago
7 years ago
7 years ago
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
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
  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. ifndef SUB_IS_SILENT
  18. ifndef SKIP_GIT
  19. QMK_VERSION := $(shell git describe --abbrev=0 --tags 2>/dev/null)
  20. endif
  21. ifneq ($(QMK_VERSION),)
  22. $(info QMK Firmware $(QMK_VERSION))
  23. endif
  24. endif
  25. # Determine which qmk cli to use
  26. QMK_BIN := qmk
  27. # avoid 'Entering|Leaving directory' messages
  28. MAKEFLAGS += --no-print-directory
  29. ON_ERROR := error_occurred=1
  30. BREAK_ON_ERRORS = no
  31. STARTING_MAKEFILE := $(firstword $(MAKEFILE_LIST))
  32. ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST))
  33. ROOT_DIR := $(dir $(ROOT_MAKEFILE))
  34. ifeq ($(ROOT_DIR),)
  35. ROOT_DIR := .
  36. endif
  37. ABS_STARTING_MAKEFILE := $(abspath $(STARTING_MAKEFILE))
  38. ABS_ROOT_MAKEFILE := $(abspath $(ROOT_MAKEFILE))
  39. ABS_STARTING_DIR := $(dir $(ABS_STARTING_MAKEFILE))
  40. ABS_ROOT_DIR := $(dir $(ABS_ROOT_MAKEFILE))
  41. STARTING_DIR := $(subst $(ABS_ROOT_DIR),,$(ABS_STARTING_DIR))
  42. BUILD_DIR := $(ROOT_DIR)/.build
  43. TEST_DIR := $(BUILD_DIR)/test
  44. ERROR_FILE := $(BUILD_DIR)/error_occurred
  45. # Helper function to process the newt element of a space separated path
  46. # It works a bit like the traditional functional head tail
  47. # so the CURRENT_PATH_ELEMENT will become the new head
  48. # and the PATH_ELEMENTS are the rest that are still unprocessed
  49. define NEXT_PATH_ELEMENT
  50. $$(eval CURRENT_PATH_ELEMENT := $$(firstword $$(PATH_ELEMENTS)))
  51. $$(eval PATH_ELEMENTS := $$(wordlist 2,9999,$$(PATH_ELEMENTS)))
  52. endef
  53. # We change the / to spaces so that we more easily can work with the elements
  54. # separately
  55. PATH_ELEMENTS := $(subst /, ,$(STARTING_DIR))
  56. # Initialize the path elements list for further processing
  57. $(eval $(call NEXT_PATH_ELEMENT))
  58. # Phony targets to enable a few simple make commands outside the main processing below.
  59. .PHONY: list-keyboards
  60. list-keyboards:
  61. util/list_keyboards.sh | sort -u | tr '\n' ' '
  62. .PHONY: generate-keyboards-file
  63. generate-keyboards-file:
  64. util/list_keyboards.sh | sort -u
  65. .PHONY: clean
  66. clean:
  67. echo -n 'Deleting .build/ ... '
  68. rm -rf $(BUILD_DIR)
  69. echo 'done.'
  70. .PHONY: distclean
  71. distclean: clean
  72. echo -n 'Deleting *.bin, *.hex, and *.uf2 ... '
  73. rm -f *.bin *.hex *.uf2
  74. echo 'done.'
  75. .DEFAULT_GOAL := all:all
  76. # Compare the start of the RULE variable with the first argument($1)
  77. # If the rules equals $1 or starts with $1:, RULE_FOUND is set to true
  78. # and $1 is removed from the RULE variable
  79. # Otherwise the RULE_FOUND variable is set to false, and RULE left as it was
  80. # The function is a bit tricky, since there's no built in $(startswith) function
  81. define COMPARE_AND_REMOVE_FROM_RULE_HELPER
  82. ifeq ($1,$$(RULE))
  83. RULE:=
  84. RULE_FOUND := true
  85. else
  86. STARTCOLON_REMOVED=$$(subst START$1:,,START$$(RULE))
  87. ifneq ($$(STARTCOLON_REMOVED),START$$(RULE))
  88. RULE_FOUND := true
  89. RULE := $$(STARTCOLON_REMOVED)
  90. else
  91. RULE_FOUND := false
  92. endif
  93. endif
  94. endef
  95. # This makes it easier to call COMPARE_AND_REMOVE_FROM_RULE, since it makes it behave like
  96. # a function that returns the value
  97. COMPARE_AND_REMOVE_FROM_RULE = $(eval $(call COMPARE_AND_REMOVE_FROM_RULE_HELPER,$1))$(RULE_FOUND)
  98. # Recursively try to find a match for the start of the rule to be checked
  99. # $1 The list to be checked
  100. # If a match is found, then RULE_FOUND is set to true
  101. # and MATCHED_ITEM to the item that was matched
  102. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER3
  103. ifneq ($1,)
  104. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,$$(firstword $1)),true)
  105. MATCHED_ITEM := $$(firstword $1)
  106. else
  107. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$$(wordlist 2,9999,$1)))
  108. endif
  109. endif
  110. endef
  111. # A recursive helper function for finding the longest match
  112. # $1 The list to be checked
  113. # It works by always removing the currently matched item from the list
  114. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER2
  115. # Stop the recursion when the list is empty
  116. ifneq ($1,)
  117. RULE_BEFORE := $$(RULE)
  118. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER3,$1))
  119. # If a match is found in the current list, otherwise just return what we had before
  120. ifeq ($$(RULE_FOUND),true)
  121. # Save the best match so far and call itself recursively
  122. BEST_MATCH := $$(MATCHED_ITEM)
  123. BEST_MATCH_RULE := $$(RULE)
  124. RULE_FOUND := false
  125. RULE := $$(RULE_BEFORE)
  126. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$$(filter-out $$(MATCHED_ITEM),$1)))
  127. endif
  128. endif
  129. endef
  130. # Recursively try to find the longest match for the start of the rule to be checked
  131. # $1 The list to be checked
  132. # If a match is found, then RULE_FOUND is set to true
  133. # and MATCHED_ITEM to the item that was matched
  134. define TRY_TO_MATCH_RULE_FROM_LIST_HELPER
  135. BEST_MATCH :=
  136. $$(eval $$(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER2,$1))
  137. ifneq ($$(BEST_MATCH),)
  138. RULE_FOUND := true
  139. RULE := $$(BEST_MATCH_RULE)
  140. MATCHED_ITEM := $$(BEST_MATCH)
  141. else
  142. RULE_FOUND := false
  143. MATCHED_ITEM :=
  144. endif
  145. endef
  146. # Make it easier to call TRY_TO_MATCH_RULE_FROM_LIST
  147. TRY_TO_MATCH_RULE_FROM_LIST = $(eval $(call TRY_TO_MATCH_RULE_FROM_LIST_HELPER,$1))$(RULE_FOUND)
  148. define ALL_IN_LIST_LOOP
  149. OLD_RULE$1 := $$(RULE)
  150. $$(eval $$(call $1,$$(ITEM$1)))
  151. RULE := $$(OLD_RULE$1)
  152. endef
  153. define PARSE_ALL_IN_LIST
  154. $$(foreach ITEM$1,$2,$$(eval $$(call ALL_IN_LIST_LOOP,$1)))
  155. endef
  156. # The entry point for rule parsing
  157. # parses a rule in the format <keyboard>:<keymap>:<target>
  158. # but this particular function only deals with the first <keyboard> part
  159. define PARSE_RULE
  160. RULE := $1
  161. COMMANDS :=
  162. REQUIRE_PLATFORM_KEY :=
  163. # If the rule starts with all, then continue the parsing from
  164. # PARSE_ALL_KEYBOARDS
  165. ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
  166. KEYBOARD_RULE=all
  167. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  168. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-avr),true)
  169. KEYBOARD_RULE=all
  170. REQUIRE_PLATFORM_KEY := avr
  171. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  172. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-chibios),true)
  173. KEYBOARD_RULE=all
  174. REQUIRE_PLATFORM_KEY := chibios
  175. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  176. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all-arm_atsam),true)
  177. KEYBOARD_RULE=all
  178. REQUIRE_PLATFORM_KEY := arm_atsam
  179. $$(eval $$(call PARSE_ALL_KEYBOARDS))
  180. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,test),true)
  181. $$(eval $$(call PARSE_TEST))
  182. # If the rule starts with the name of a known keyboard, then continue
  183. # the parsing from PARSE_KEYBOARD
  184. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(shell util/list_keyboards.sh | sort -u)),true)
  185. KEYBOARD_RULE=$$(MATCHED_ITEM)
  186. $$(eval $$(call PARSE_KEYBOARD,$$(MATCHED_ITEM)))
  187. else
  188. $$(info make: *** No rule to make target '$1'. Stop.)
  189. $$(info |)
  190. $$(info | QMK's make format is:)
  191. $$(info | make keyboard_folder:keymap_folder[:target])
  192. $$(info |)
  193. $$(info | Where `keyboard_folder` is the path to the keyboard relative to)
  194. $$(info | `qmk_firmware/keyboards/`, and `keymap_folder` is the name of the)
  195. $$(info | keymap folder under that board's `keymaps/` directory.)
  196. $$(info |)
  197. $$(info | Examples:)
  198. $$(info | keyboards/dz60, keyboards/dz60/keymaps/default)
  199. $$(info | -> make dz60:default)
  200. $$(info | -> qmk compile -kb dz60 -km default)
  201. $$(info | keyboards/planck/rev6, keyboards/planck/keymaps/default)
  202. $$(info | -> make planck/rev6:default:flash)
  203. $$(info | -> qmk flash -kb planck/rev6 -km default)
  204. $$(info |)
  205. endif
  206. endef
  207. # $1 = Keyboard
  208. # Parses a rule in the format <keymap>:<target>
  209. # the keyboard is already known when entering this function
  210. define PARSE_KEYBOARD
  211. # If we want to compile the default subproject, then we need to
  212. # include the correct makefile to determine the actual name of it
  213. CURRENT_KB := $1
  214. # KEYBOARD_FOLDERS := $$(subst /, , $(CURRENT_KB))
  215. DEFAULT_FOLDER := $$(CURRENT_KB)
  216. # We assume that every rules.mk will contain the full default value
  217. $$(eval include $(ROOT_DIR)/keyboards/$$(CURRENT_KB)/rules.mk)
  218. ifneq ($$(DEFAULT_FOLDER),$$(CURRENT_KB))
  219. $$(eval include $(ROOT_DIR)/keyboards/$$(DEFAULT_FOLDER)/rules.mk)
  220. endif
  221. CURRENT_KB := $$(DEFAULT_FOLDER)
  222. # 5/4/3/2/1
  223. KEYBOARD_FOLDER_PATH_1 := $$(CURRENT_KB)
  224. KEYBOARD_FOLDER_PATH_2 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_1)))
  225. KEYBOARD_FOLDER_PATH_3 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_2)))
  226. KEYBOARD_FOLDER_PATH_4 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_3)))
  227. KEYBOARD_FOLDER_PATH_5 := $$(patsubst %/,%,$$(dir $$(KEYBOARD_FOLDER_PATH_4)))
  228. KEYMAPS :=
  229. # get a list of all keymaps
  230. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_1)/keymaps/*/.)))
  231. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_2)/keymaps/*/.)))
  232. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_3)/keymaps/*/.)))
  233. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_4)/keymaps/*/.)))
  234. KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/keyboards/$$(KEYBOARD_FOLDER_PATH_5)/keymaps/*/.)))
  235. KEYBOARD_LAYOUTS := $(shell $(QMK_BIN) list-layouts --keyboard $1)
  236. LAYOUT_KEYMAPS :=
  237. $$(foreach LAYOUT,$$(KEYBOARD_LAYOUTS),$$(eval LAYOUT_KEYMAPS += $$(notdir $$(patsubst %/.,%,$$(wildcard $(ROOT_DIR)/layouts/*/$$(LAYOUT)/*/.)))))
  238. KEYMAPS := $$(sort $$(KEYMAPS) $$(LAYOUT_KEYMAPS))
  239. # if the rule after removing the start of it is empty (we haven't specified a kemap or target)
  240. # compile all the keymaps
  241. ifeq ($$(RULE),)
  242. $$(eval $$(call PARSE_ALL_KEYMAPS))
  243. # The same if all was specified
  244. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,all),true)
  245. $$(eval $$(call PARSE_ALL_KEYMAPS))
  246. # List all keymaps for the given keyboard
  247. else ifeq ($$(call COMPARE_AND_REMOVE_FROM_RULE,list-keymaps),true)
  248. $$(eval $$(call LIST_ALL_KEYMAPS))
  249. # Try to match the specified keyamp with the list of known keymaps
  250. else ifeq ($$(call TRY_TO_MATCH_RULE_FROM_LIST,$$(KEYMAPS)),true)
  251. $$(eval $$(call PARSE_KEYMAP,$$(MATCHED_ITEM)))
  252. # Otherwise try to match the keymap from the current folder, or arguments to the make command
  253. else ifneq ($$(KEYMAP),)
  254. $$(eval $$(call PARSE_KEYMAP,$$(KEYMAP)))
  255. # Otherwise if we are running make all:<user> just skip
  256. else ifeq ($$(KEYBOARD_RULE),all)
  257. # $$(info Skipping: No user keymap for $$(CURRENT_KB))
  258. # Otherwise, make all keymaps, again this is consistent with how it works without
  259. # any arguments
  260. else
  261. $$(eval $$(call PARSE_ALL_KEYMAPS))
  262. endif
  263. endef
  264. # if we are going to compile all keyboards, match the rest of the rule
  265. # for each of them
  266. define PARSE_ALL_KEYBOARDS
  267. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYBOARD,$(shell util/list_keyboards.sh noci | sort -u)))
  268. endef
  269. # Prints a list of all known keymaps for the given keyboard
  270. define LIST_ALL_KEYMAPS
  271. COMMAND_true_LIST_KEYMAPS := \
  272. printf "$$(KEYMAPS)\n";
  273. COMMAND_false_LIST_KEYMAPS := \
  274. printf "$$(MSG_AVAILABLE_KEYMAPS)\n"; \
  275. printf "$$(KEYMAPS)\n";
  276. COMMANDS += LIST_KEYMAPS
  277. endef
  278. # $1 Keymap
  279. # This is the meat of compiling a keyboard, when entering this, everything is known
  280. # keyboard, subproject, and keymap
  281. # Note that we are not directly calling the command here, but instead building a list,
  282. # which will later be processed
  283. define PARSE_KEYMAP
  284. CURRENT_KM = $1
  285. # The rest of the rule is the target
  286. # Remove the leading ":" from the target, as it acts as a separator
  287. MAKE_TARGET := $$(patsubst :%,%,$$(RULE))
  288. # We need to generate an unique indentifer to append to the COMMANDS list
  289. CURRENT_KB_UNDER := $$(subst /,_,$$(CURRENT_KB))
  290. COMMAND := COMMAND_KEYBOARD_$$(CURRENT_KB_UNDER)_KEYMAP_$$(CURRENT_KM)
  291. # If we are compiling a keyboard without a subproject, we want to display just the name
  292. # of the keyboard, otherwise keyboard/subproject
  293. KB_SP := $$(CURRENT_KB)
  294. # Format it in bold
  295. KB_SP := $(BOLD)$$(KB_SP)$(NO_COLOR)
  296. # Specify the variables that we are passing forward to submake
  297. MAKE_VARS := KEYBOARD=$$(CURRENT_KB) KEYMAP=$$(CURRENT_KM) REQUIRE_PLATFORM_KEY=$$(REQUIRE_PLATFORM_KEY) QMK_BIN=$$(QMK_BIN)
  298. # And the first part of the make command
  299. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_keyboard.mk $$(MAKE_TARGET)
  300. # The message to display
  301. MAKE_MSG := $$(MSG_MAKE_KB)
  302. # We run the command differently, depending on if we want more output or not
  303. # The true version for silent output and the false version otherwise
  304. $$(eval $$(call BUILD))
  305. endef
  306. define BUILD
  307. MAKE_VARS += VERBOSE=$(VERBOSE) COLOR=$(COLOR)
  308. COMMANDS += $$(COMMAND)
  309. COMMAND_true_$$(COMMAND) := \
  310. printf "$$(MAKE_MSG)" | \
  311. $$(MAKE_MSG_FORMAT); \
  312. LOG=$$$$($$(MAKE_CMD) $$(MAKE_VARS) SILENT=true 2>&1) ; \
  313. if [ $$$$? -gt 0 ]; \
  314. then $$(PRINT_ERROR_PLAIN); \
  315. elif [ "$$$$LOG" = "skipped" ] ; \
  316. then $$(PRINT_SKIPPED_PLAIN); \
  317. elif [ "$$$$LOG" != "" ] ; \
  318. then $$(PRINT_WARNING_PLAIN); \
  319. else \
  320. $$(PRINT_OK); \
  321. fi;
  322. COMMAND_false_$$(COMMAND) := \
  323. printf "$$(MAKE_MSG)\n\n"; \
  324. $$(MAKE_CMD) $$(MAKE_VARS) SILENT=false; \
  325. if [ $$$$? -gt 0 ]; \
  326. then error_occurred=1; \
  327. fi;
  328. endef
  329. # Just parse all the keymaps for a specific keyboard
  330. define PARSE_ALL_KEYMAPS
  331. $$(eval $$(call PARSE_ALL_IN_LIST,PARSE_KEYMAP,$$(KEYMAPS)))
  332. endef
  333. define BUILD_TEST
  334. TEST_PATH := $1
  335. TEST_NAME := $$(notdir $$(TEST_PATH))
  336. MAKE_TARGET := $2
  337. COMMAND := $1
  338. MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET)
  339. MAKE_VARS := TEST=$$(TEST_NAME) TEST_PATH=$$(TEST_PATH) FULL_TESTS="$$(FULL_TESTS)"
  340. MAKE_MSG := $$(MSG_MAKE_TEST)
  341. $$(eval $$(call BUILD))
  342. ifneq ($$(MAKE_TARGET),clean)
  343. TEST_EXECUTABLE := $$(TEST_DIR)/$$(TEST_NAME).elf
  344. TESTS += $$(TEST_NAME)
  345. TEST_MSG := $$(MSG_TEST)
  346. $$(TEST_NAME)_COMMAND := \
  347. printf "$$(TEST_MSG)\n"; \
  348. $$(TEST_EXECUTABLE); \
  349. if [ $$$$? -gt 0 ]; \
  350. then error_occurred=1; \
  351. fi; \
  352. printf "\n";
  353. endif
  354. endef
  355. define PARSE_TEST
  356. TESTS :=
  357. TEST_NAME := $$(firstword $$(subst :, ,$$(RULE)))
  358. TEST_TARGET := $$(subst $$(TEST_NAME),,$$(subst $$(TEST_NAME):,,$$(RULE)))
  359. ifeq ($$(TEST_NAME),all)
  360. MATCHED_TESTS := $$(TEST_LIST)
  361. else
  362. MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME), $$(notdir $$(TEST))), $$(TEST),))
  363. endif
  364. $$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET))))
  365. endef
  366. # Set the silent mode depending on if we are trying to compile multiple keyboards or not
  367. # By default it's on in that case, but it can be overridden by specifying silent=false
  368. # from the command line
  369. define SET_SILENT_MODE
  370. ifdef SUB_IS_SILENT
  371. SILENT_MODE := $(SUB_IS_SILENT)
  372. else ifeq ($$(words $$(COMMANDS)),1)
  373. SILENT_MODE := false
  374. else
  375. SILENT_MODE := true
  376. endif
  377. endef
  378. include paths.mk
  379. include $(BUILDDEFS_PATH)/message.mk
  380. ifeq ($(strip $(BREAK_ON_ERRORS)), yes)
  381. HANDLE_ERROR = exit 1
  382. else
  383. HANDLE_ERROR = echo $$error_occurred > $(ERROR_FILE)
  384. endif
  385. # The empty line is important here, as it will force a new shell to be created for each command
  386. # Otherwise the command line will become too long with a lot of keyboards and keymaps
  387. define RUN_COMMAND
  388. +error_occurred=0;\
  389. $(COMMAND_$(SILENT_MODE)_$(COMMAND))\
  390. if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
  391. endef
  392. define RUN_TEST
  393. +error_occurred=0;\
  394. $($(TEST)_COMMAND)\
  395. if [ $$error_occurred -gt 0 ]; then $(HANDLE_ERROR); fi;
  396. endef
  397. # Catch everything and parse the command line ourselves.
  398. .PHONY: %
  399. %:
  400. # Check if we have the CMP tool installed
  401. cmp $(ROOT_DIR)/Makefile $(ROOT_DIR)/Makefile >/dev/null 2>&1; if [ $$? -gt 0 ]; then printf "$(MSG_NO_CMP)"; exit 1; fi;
  402. # Ensure that $(QMK_BIN) works.
  403. if ! $(QMK_BIN) hello 1> /dev/null 2>&1; then printf "$(MSG_PYTHON_MISSING)"; exit 1; fi
  404. # Check if the submodules are dirty, and display a warning if they are
  405. ifndef SKIP_GIT
  406. if [ ! -e lib/chibios ]; then git submodule sync lib/chibios && git submodule update --depth 50 --init lib/chibios; fi
  407. if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --depth 50 --init lib/chibios-contrib; fi
  408. if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
  409. if [ ! -e lib/vusb ]; then git submodule sync lib/vusb && git submodule update --depth 50 --init lib/vusb; fi
  410. if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
  411. git submodule status --recursive 2>/dev/null | \
  412. while IFS= read -r x; do \
  413. case "$$x" in \
  414. \ *) ;; \
  415. *) printf "$(MSG_SUBMODULE_DIRTY)";break;; \
  416. esac \
  417. done
  418. endif
  419. rm -f $(ERROR_FILE) > /dev/null 2>&1
  420. $(eval $(call PARSE_RULE,$@))
  421. $(eval $(call SET_SILENT_MODE))
  422. # Run all the commands in the same shell, notice the + at the first line
  423. # it has to be there to allow parallel execution of the submake
  424. # This always tries to compile everything, even if error occurs in the middle
  425. # But we return the error code at the end, to trigger travis failures
  426. # The sort at this point is to remove duplicates
  427. $(foreach COMMAND,$(sort $(COMMANDS)),$(RUN_COMMAND))
  428. if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
  429. $(foreach TEST,$(sort $(TESTS)),$(RUN_TEST))
  430. if [ -f $(ERROR_FILE) ]; then printf "$(MSG_ERRORS)" & exit 1; fi;
  431. lib/%:
  432. git submodule sync $?
  433. git submodule update --init $?
  434. .PHONY: git-submodule
  435. git-submodule:
  436. git submodule sync --recursive
  437. git submodule update --init --recursive --progress
  438. # Generate the version.h file
  439. ifdef SKIP_GIT
  440. VERSION_H_FLAGS := --skip-git
  441. endif
  442. ifdef SKIP_VERSION
  443. VERSION_H_FLAGS := --skip-all
  444. SKIP_GIT := yes
  445. endif
  446. $(shell $(QMK_BIN) generate-version-h $(VERSION_H_FLAGS) -q -o quantum/version.h)
  447. include $(ROOT_DIR)/testlist.mk