aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPeter Johanson <[email protected]>2024-03-08 10:17:02 -0800
committerPete Johanson <[email protected]>2024-03-08 10:58:10 -0800
commit2adaa00d1092e41ce11dfae46ce7d2a5bad97ead (patch)
tree4cd70d956d9ed87e116c8f0a5398142135d6282e
parent08ab45fc7875a042c787d353ff0e3512319af030 (diff)
downloadzmk-2adaa00d1092e41ce11dfae46ce7d2a5bad97ead.tar.gz
zmk-2adaa00d1092e41ce11dfae46ce7d2a5bad97ead.zip
fix(build): Properly board revision keymaps.
* Handle board keymap location for boards with Zephyr board revisions included. * Includes bare non-revision file and a revision specific keymap in case newer revision changes the layout/key positions.
-rw-r--r--app/keymap-module/modules/modules.cmake24
1 files changed, 23 insertions, 1 deletions
diff --git a/app/keymap-module/modules/modules.cmake b/app/keymap-module/modules/modules.cmake
index c286809df1..f513bcc4f5 100644
--- a/app/keymap-module/modules/modules.cmake
+++ b/app/keymap-module/modules/modules.cmake
@@ -63,6 +63,13 @@ if(DEFINED SHIELD)
string(REPLACE " " ";" SHIELD_AS_LIST "${SHIELD}")
endif()
+string(FIND "${BOARD}" "@" REVISION_SEPARATOR_INDEX)
+if(NOT (REVISION_SEPARATOR_INDEX EQUAL -1))
+ math(EXPR BOARD_REVISION_INDEX "${REVISION_SEPARATOR_INDEX} + 1")
+ string(SUBSTRING ${BOARD} ${BOARD_REVISION_INDEX} -1 BOARD_REVISION)
+ string(SUBSTRING ${BOARD} 0 ${REVISION_SEPARATOR_INDEX} BOARD)
+endif()
+
foreach(root ${BOARD_ROOT})
set(shield_dir ${root}/boards/shields)
# Match the Kconfig.shield files in the shield directories to make sure we are
@@ -107,6 +114,21 @@ foreach(root ${BOARD_ROOT})
endif()
endforeach()
+if(EXISTS ${BOARD_DIR}/revision.cmake)
+ # Board provides revision handling.
+ include(${BOARD_DIR}/revision.cmake)
+elseif(BOARD_REVISION)
+ message(WARNING "Board revision ${BOARD_REVISION} specified for ${BOARD}, \
+ but board has no revision so revision will be ignored.")
+endif()
+
+if(DEFINED BOARD_REVISION)
+ string(REPLACE "." "_" BOARD_REVISION_STRING ${BOARD_REVISION})
+ set(KEYMAP_BOARD_REVISION_PREFIX "${BOARD}_${BOARD_REVISION_STRING}")
+else()
+ set(KEYMAP_BOARD_REVISION_PREFIX "")
+endif()
+
# Give a shield like `kyria_rev2_left` we want to use `kyria_rev2` and `kyria` as candidate names for
# overlay/conf/keymap files.
if(DEFINED SHIELD)
@@ -178,7 +200,7 @@ endif()
if(NOT KEYMAP_FILE)
foreach(keymap_dir ${KEYMAP_DIRS})
- foreach(keymap_prefix ${shield_candidate_names} ${SHIELD_AS_LIST} ${SHIELD_DIR} ${BOARD} ${BOARD_DIR_NAME})
+ foreach(keymap_prefix ${shield_candidate_names} ${SHIELD_AS_LIST} ${SHIELD_DIR} ${KEYMAP_BOARD_REVISION_PREFIX} ${BOARD} ${BOARD_DIR_NAME})
if (EXISTS ${keymap_dir}/${keymap_prefix}.keymap)
set(KEYMAP_FILE "${keymap_dir}/${keymap_prefix}.keymap" CACHE STRING "Selected keymap file")
message(STATUS "Using keymap file: ${KEYMAP_FILE}")