load keyboard ui through vscode

This commit is contained in:
Jack Humbert 2023-04-04 16:26:44 -04:00
parent 7093a41c6c
commit fe59b4e5d6
7 changed files with 100 additions and 60 deletions

30
.vscode/tasks.json vendored
View File

@ -2,10 +2,10 @@
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {
"label": "Load Keyboard & Refresh Outline", "label": "Load Keyboard",
"dependsOrder": "sequence", "dependsOrder": "sequence",
"dependsOn":[ "dependsOn":[
"Load Keyboard", "Only Load Keyboard",
"Configure CMake" "Configure CMake"
], ],
"group": { "group": {
@ -14,9 +14,9 @@
} }
}, },
{ {
"label": "Load Keyboard", "label": "Only Load Keyboard",
"type": "shell", "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": [] "problemMatcher": []
}, },
{ {
@ -72,15 +72,6 @@
// } // }
], ],
"inputs": [ "inputs": [
{
"id": "keyboard",
"description": "Keyboard:",
"type": "pickString",
"options":[
"planck/rev5",
"olkb/planck/rev3"
]
},
{ {
"id": "keyboard_target", "id": "keyboard_target",
"type": "command", "type": "command",
@ -97,8 +88,17 @@
"command": "shellCommand.execute", "command": "shellCommand.execute",
"args": { "args": {
"command": "type build\\all_keyboards", "command": "type build\\all_keyboards",
"description": "Keyboard:" "description": "Keyboard:",
"default": ""
},
},
{
"id": "keymap",
"description": "Keymap:",
"type": "pickString",
"options":[
"default"
]
}, },
}
] ]
} }

View File

@ -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 "config.h: ${QMK_KEYBOARD_CONFIG_H}")
message(STATUS "keyboard.h: ${QMK_KEYBOARD_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) validate_json(${QMK_KEYBOARD_FOLDER_ABS}/info.json keyboard QMK_KEYBOARD_INFO_JSON_STRING)

View File

@ -72,5 +72,5 @@ macro(add_keyboard KEYBOARD_FOLDER KEYMAP_FOLDER)
-DTARGET_NAME=${TARGET_NAME} -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) endmacro(add_keyboard)

View File

@ -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}'")

View File

@ -30,8 +30,8 @@ set(AVR_SIZE "${TOOLCHAIN_ROOT}/${QMK_TOOLCHAIN}-size${OS_SUFFIX}"
find_program(CMAKE_MAKE_PROGRAM NAME make find_program(CMAKE_MAKE_PROGRAM NAME make
PATHS PATHS
$<$<WIN32>:"${CMAKE_SOURCE_DIR}/toolchains/avr-gcc-12.1.0-x64-windows/bin/"> "${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-linux/bin/"
/usr/bin/ /usr/bin/
/usr/local/bin /usr/local/bin
/bin/ /bin/
@ -100,36 +100,17 @@ else()
) )
endif() endif()
# include_directories("C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/avr/include")
macro(add_qmk_executable target_name) macro(add_qmk_executable target_name)
set(elf_file ${target_name}-${QMK_MCU}.elf) set(elf_file ${target_name}.elf)
set(map_file ${target_name}-${QMK_MCU}.map) set(map_file ${target_name}.map)
set(hex_file ${target_name}-${QMK_MCU}.hex) set(hex_file ${target_name}.hex)
set(lst_file ${target_name}-${QMK_MCU}.lst) set(lst_file ${target_name}.lst)
# add_link_options(-Wl,--gc-sections,-nostartfiles)
# create elf file # create elf file
add_executable(${elf_file} add_executable(${elf_file} ${ARGN})
${ARGN}
)
target_link_libraries(${elf_file} target_link_libraries(${elf_file} qmk)
PUBLIC
quantum
tmk_core_protocol
platforms
)
# 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}"
# )
# generate the lst file # generate the lst file
add_custom_command( add_custom_command(
@ -169,11 +150,16 @@ macro(add_qmk_executable target_name)
DEPENDS ${hex_file} 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 # build the intel hex file for the device
add_custom_target( add_custom_target(
${target_name} ${target_name}
ALL 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( set_target_properties(

View File

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

View File

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