Procházet zdrojové kódy

load keyboard ui through vscode

Jack Humbert před 3 roky
rodič
revize
fe59b4e5d6

+ 15 - 15
.vscode/tasks.json

@@ -2,10 +2,10 @@
     "version": "2.0.0",
     "tasks": [
         {
-            "label": "Load Keyboard & Refresh Outline",
+            "label": "Load Keyboard",
             "dependsOrder": "sequence",
             "dependsOn":[
-                "Load Keyboard",
+                "Only Load Keyboard",
                 "Configure CMake"
             ],
             "group": {
@@ -14,9 +14,9 @@
             }
         },
         {
-            "label": "Load Keyboard",
+            "label": "Only Load Keyboard",
             "type": "shell",
-            "command": "cmake -Bbuild -DQMK_KEYBOARD_FOLDER=${input:all_keyboards}",
+            "command": "cmake -D QMK_KEYBOARD_FOLDER=\"${input:all_keyboards}\" -D QMK_KEYMAP_FOLDER=\"${input:keymap}\" -P ${workspaceFolder}/cmake/ConfigureKeyboard.cmake",
             "problemMatcher": []
         },
         {
@@ -72,15 +72,6 @@
         // }
     ],
     "inputs": [
-        {
-            "id": "keyboard",
-            "description": "Keyboard:",
-            "type": "pickString",
-            "options":[
-                "planck/rev5",
-                "olkb/planck/rev3"
-            ]
-        },
         {
             "id": "keyboard_target",
             "type": "command",
@@ -97,8 +88,17 @@
             "command": "shellCommand.execute",
             "args": {
                 "command": "type build\\all_keyboards",
-                "description": "Keyboard:"
+                "description": "Keyboard:",
+                "default": ""
             },
-        }
+        },
+        {
+            "id": "keymap",
+            "description": "Keymap:",
+            "type": "pickString",
+            "options":[
+                "default"
+            ]
+        },
     ]
 }

+ 1 - 1
CMakeLists.txt

@@ -44,7 +44,7 @@ resolve_keymap_c(${QMK_KEYBOARD_FOLDER_ABS} ${QMK_KEYMAP_FOLDER} QMK_KEYMAP_C)
 
 message(STATUS "config.h: ${QMK_KEYBOARD_CONFIG_H}")
 message(STATUS "keyboard.h: ${QMK_KEYBOARD_H}")
-message(STATUS "Keymap.c: ${QMK_KEYMAP_C}")
+message(STATUS "keymap.c: ${QMK_KEYMAP_C}")
 
 validate_json(${QMK_KEYBOARD_FOLDER_ABS}/info.json keyboard QMK_KEYBOARD_INFO_JSON_STRING)
 

+ 1 - 1
cmake/AddKeyboard.cmake

@@ -72,5 +72,5 @@ macro(add_keyboard KEYBOARD_FOLDER KEYMAP_FOLDER)
       -DTARGET_NAME=${TARGET_NAME}
   )
   
-file(APPEND "${CMAKE_SOURCE_DIR}/build/targets" "${TARGET_NAME}|${KEYBOARD_NAME} with ${KEYMAP_FOLDER}|${KEYBOARD_FOLDER}|Made by: ${MANUFACTURER}\n")
+# file(APPEND "${CMAKE_SOURCE_DIR}/build/targets" "${TARGET_NAME}|${KEYBOARD_NAME} with ${KEYMAP_FOLDER}|${KEYBOARD_FOLDER}|Made by: ${MANUFACTURER}\n")
 endmacro(add_keyboard)

+ 44 - 0
cmake/ConfigureKeyboard.cmake

@@ -0,0 +1,44 @@
+cmake_minimum_required(VERSION 3.20)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
+
+include(ResolveKeyboard)
+include(ValidateJSON)
+
+resolve_keyboard(${QMK_KEYBOARD_FOLDER} KEYBOARD_FOLDER_ABS)
+validate_json(${KEYBOARD_FOLDER_ABS}/info.json keyboard JSON_STRING)
+
+if(NOT DEFINED QMK_KEYMAP_FOLDER)
+    set(QMK_KEYMAP_FOLDER default)
+endif()
+
+set(TEMP_PATH ${QMK_KEYBOARD_FOLDER})
+cmake_path(IS_RELATIVE TEMP_PATH IS_KEYBOARD_FOLDER_RELATIVE)
+
+set(TEMP_PATH ${QMK_KEYMAP_FOLDER})
+cmake_path(IS_RELATIVE TEMP_PATH IS_KEYMAP_FOLDER_RELATIVE)
+
+if(${IS_KEYMAP_FOLDER_RELATIVE})
+  set(KEYMAP_NAME ${QMK_KEYMAP_FOLDER})
+else()
+  if(WIN32)
+    set(KEYMAP_NAME $ENV{USERNAME})
+  else()
+    set(KEYMAP_NAME $ENV{USE})
+  endif()
+endif()  
+
+string(JSON KEYBOARD_NAME GET ${JSON_STRING} keyboard_name)
+
+if(${IS_KEYBOARD_FOLDER_RELATIVE})
+    string(MAKE_C_IDENTIFIER ${QMK_KEYBOARD_FOLDER} KEYBOARD_SLUG)
+else()
+    string(MAKE_C_IDENTIFIER ${KEYBOARD_NAME} KEYBOARD_SLUG)
+endif()
+
+string(JSON MANUFACTURER GET ${JSON_STRING} manufacturer)
+
+set(TARGET_NAME "${KEYBOARD_SLUG}_${KEYMAP_NAME}")
+file(APPEND "${CMAKE_SOURCE_DIR}/build/targets" "${TARGET_NAME}|${KEYBOARD_NAME} with ${QMK_KEYMAP_FOLDER}|${QMK_KEYBOARD_FOLDER}|Made by: ${MANUFACTURER}\n")
+
+message(STATUS "Added keyboard '${QMK_KEYBOARD_FOLDER}' with keymap '${QMK_KEYMAP_FOLDER}'")

+ 14 - 28
cmake/toolchains/arm-none-eabi.cmake

@@ -30,8 +30,8 @@ set(AVR_SIZE           "${TOOLCHAIN_ROOT}/${QMK_TOOLCHAIN}-size${OS_SUFFIX}"
 
 find_program(CMAKE_MAKE_PROGRAM NAME make
     PATHS
-    $<$<WIN32>:"${CMAKE_SOURCE_DIR}/toolchains/avr-gcc-12.1.0-x64-windows/bin/">
-    $<$UNIX>:"${CMAKE_SOURCE_DIR}/toolchains/avr-gcc-12.1.0-x64-linux/bin/">
+    "${CMAKE_SOURCE_DIR}/toolchains/avr-gcc-12.1.0-x64-windows/bin/"
+    "${CMAKE_SOURCE_DIR}/toolchains/avr-gcc-12.1.0-x64-linux/bin/"
     /usr/bin/
     /usr/local/bin
     /bin/
@@ -100,36 +100,17 @@ else()
     )
 endif()
 
-# include_directories("C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/avr/include")
-
 macro(add_qmk_executable target_name)
 
-    set(elf_file ${target_name}-${QMK_MCU}.elf)
-    set(map_file ${target_name}-${QMK_MCU}.map)
-    set(hex_file ${target_name}-${QMK_MCU}.hex)
-    set(lst_file ${target_name}-${QMK_MCU}.lst)
-
-    # add_link_options(-Wl,--gc-sections,-nostartfiles)
+    set(elf_file ${target_name}.elf)
+    set(map_file ${target_name}.map)
+    set(hex_file ${target_name}.hex)
+    set(lst_file ${target_name}.lst)
 
     # create elf file
-    add_executable(${elf_file}
-        ${ARGN}
-    )
-
-    target_link_libraries(${elf_file} 
-    PUBLIC 
-        quantum 
-        tmk_core_protocol
-        platforms
-    )
+    add_executable(${elf_file} ${ARGN})
 
-    # set_target_properties(
-    #     ${elf_file}
-
-    #     PROPERTIES
-    #         COMPILE_FLAGS "-mmcu=${QMK_MCU} -g -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics"
-    #         LINK_FLAGS    "-mmcu=${QMK_MCU} -Wl,-Map,${map_file}"
-    # )
+    target_link_libraries(${elf_file} qmk)
 
     # generate the lst file
     add_custom_command(
@@ -169,11 +150,16 @@ macro(add_qmk_executable target_name)
         DEPENDS ${hex_file}
     )
 
+    add_custom_target(copy_hex
+        COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${elf_file}> ${CMAKE_SOURCE_DIR}/build/${target_name}.hex
+        DEPENDS ${hex_file}
+    )
+
     # build the intel hex file for the device
     add_custom_target(
         ${target_name}
         ALL
-        DEPENDS ${hex_file} ${lst_file} "print-size-${elf_file}" "print-size-${hex_file}"
+        DEPENDS ${hex_file} ${lst_file} "print-size-${elf_file}" "print-size-${hex_file}" copy_hex
     )
 
     set_target_properties(

+ 0 - 2
cmake/toolchains/avr.cmake

@@ -95,8 +95,6 @@ add_link_options(
     -Wl,--gc-sections
 )
 
-# include_directories("C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/avr/include")
-
 macro(add_qmk_executable target_name)
 
     set(elf_file ${target_name}.elf)

+ 25 - 13
keyboards/CMakeLists.txt

@@ -1,22 +1,34 @@
 include(ExternalProject)
 include(AddKeyboard)
   
-file(WRITE "${CMAKE_SOURCE_DIR}/build/targets" "")
+# file(WRITE "${CMAKE_SOURCE_DIR}/build/targets" "")
 
-if(DEFINED QMK_KEYBOARD_FOLDER)
-  if(NOT DEFINED QMK_KEYMAP_FOLDER)
-    set(QMK_KEYMAP_FOLDER "default")
-  endif()
-  add_keyboard(${QMK_KEYBOARD_FOLDER} ${QMK_KEYMAP_FOLDER})
-endif()
+# if(DEFINED QMK_KEYBOARD_FOLDER)
+#   if(NOT DEFINED QMK_KEYMAP_FOLDER)
+#     set(QMK_KEYMAP_FOLDER "default")
+#   endif()
+#   add_keyboard(${QMK_KEYBOARD_FOLDER} ${QMK_KEYMAP_FOLDER})
+# endif()
 
-file(GLOB_RECURSE KEYBOARDS **/CMakeLists.txt)
+# file(GLOB_RECURSE KEYBOARDS **/CMakeLists.txt)
 
-foreach(KEYBOARD_CMAKE ${KEYBOARDS})
-  get_filename_component(KEYBOARD_FOLDER_ABS "${KEYBOARD_CMAKE}" DIRECTORY)
-  file(RELATIVE_PATH KEYBOARD_FOLDER "${CMAKE_SOURCE_DIR}/keyboards" "${KEYBOARD_FOLDER_ABS}")
-  add_keyboard(${KEYBOARD_FOLDER} "default")
-endforeach()
+# foreach(KEYBOARD_CMAKE ${KEYBOARDS})
+#   get_filename_component(KEYBOARD_FOLDER_ABS "${KEYBOARD_CMAKE}" DIRECTORY)
+#   file(RELATIVE_PATH KEYBOARD_FOLDER "${CMAKE_SOURCE_DIR}/keyboards" "${KEYBOARD_FOLDER_ABS}")
+#   add_keyboard(${KEYBOARD_FOLDER} "default")
+# endforeach()
+
+file(STRINGS "${CMAKE_SOURCE_DIR}/build/targets" TARGETS)
+
+while(TARGETS)
+    list(POP_FRONT TARGETS LINE)
+    if (LINE MATCHES "(.+)\\|(.+)\\|(.+)\\|(.+)")
+      set(KEYBOARD_FOLDER ${CMAKE_MATCH_3})
+      add_keyboard(${KEYBOARD_FOLDER} "default")
+    endif()
+endwhile()
+
+# list all keyboards in build/all_keyboards
 
 file(GLOB_RECURSE POSSIBLE_KEYBOARDS **/info.json)