chibios compiling, layout keymaps

This commit is contained in:
Jack Humbert 2023-04-06 16:22:14 -04:00
parent cc22d67b32
commit 5dd8efc7c0
27 changed files with 453 additions and 224 deletions

View File

@ -1,2 +1,3 @@
CompileFlags:
Remove: -mcall-prologues
Remove: -mcall-prologues
Add: -nostdinc

View File

@ -6,7 +6,7 @@
"files.exclude": {
"**/.build": true,
// "**/*.hex": true,
"**/*.bin": true,
// "**/*.bin": true,
"**/*.uf2": true
},
"files.associations": {

12
.vscode/tasks.json vendored
View File

@ -16,7 +16,7 @@
{
"label": "Only Load Keyboard",
"type": "shell",
"command": "cmake -D QMK_KEYBOARD_FOLDER=\"${input:all_keyboards}\" -D QMK_KEYMAP_FOLDER=\"${input:keymap}\" -P ${workspaceFolder}/cmake/ConfigureKeyboard.cmake",
"command": "cmake -D QMK_KEYBOARD_FOLDER=\"${input:all_keyboards}\" -D QMK_KEYMAP_FOLDER=\"${input:keyboard_keymap}\" -P ${workspaceFolder}/cmake/ConfigureKeyboard.cmake",
"problemMatcher": []
},
{
@ -100,5 +100,15 @@
"default"
]
},
{
"id": "keyboard_keymap",
"type": "command",
"command": "shellCommand.execute",
"args": {
"command": "cmake -D QMK_KEYBOARD_FOLDER=\"${input:all_keyboards}\" -P ${workspaceFolder}/cmake/GetKeymaps.cmake && type build\\keyboard_keymaps",
"description": "Keymap:",
"default": ""
},
},
]
}

View File

@ -5,10 +5,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(UpdateSubmodule)
include(ResolveKeyboard)
include(ValidateJson)
include(ProcessKeyboard)
set(QMK_KEYBOARDS_FOLDER "${CMAKE_SOURCE_DIR}/keyboards")
function (_get_all_cmake_targets out_var current_dir)
function(_get_all_cmake_targets out_var current_dir)
get_property(targets DIRECTORY ${current_dir} PROPERTY BUILDSYSTEM_TARGETS)
get_property(subdirs DIRECTORY ${current_dir} PROPERTY SUBDIRECTORIES)
@ -21,86 +22,85 @@ function (_get_all_cmake_targets out_var current_dir)
endfunction()
if(NOT DEFINED QMK_KEYBOARD)
# configure step - populate targets
project(qmk_firmware)
# configure step - populate targets
project(qmk_firmware)
add_subdirectory(keyboards)
add_subdirectory(keyboards)
else()
# build step
if(NOT DEFINED QMK_KEYMAP_FOLDER)
set(QMK_KEYMAP_FOLDER "default")
endif()
# build step
if(NOT DEFINED QMK_KEYMAP_FOLDER)
set(QMK_KEYMAP_FOLDER "default")
endif()
resolve_keyboard(${QMK_KEYBOARD_FOLDER} QMK_KEYBOARD_FOLDER_ABS)
cmake_path(IS_PREFIX QMK_KEYBOARDS_FOLDER "${QMK_KEYBOARD_FOLDER_ABS}" IS_KEYBOARDS_FOLDER)
resolve_config_h(${QMK_KEYBOARD_FOLDER_ABS} QMK_KEYBOARD_CONFIG_H)
resolve_keyboard_h(${QMK_KEYBOARD_FOLDER_ABS} QMK_KEYBOARD_H)
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}")
validate_json(${QMK_KEYBOARD_FOLDER_ABS}/info.json keyboard QMK_KEYBOARD_INFO_JSON_STRING)
string(JSON KEYBOARD_NAME GET ${QMK_KEYBOARD_INFO_JSON_STRING} keyboard_name)
string(JSON MANUFACTURER GET ${QMK_KEYBOARD_INFO_JSON_STRING} manufacturer)
string(JSON URL GET ${QMK_KEYBOARD_INFO_JSON_STRING} url)
string(JSON QMK_MCU GET ${QMK_KEYBOARD_INFO_JSON_STRING} processor)
string(JSON VENDOR_ID GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb vid)
string(JSON PRODUCT_ID GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb pid)
string(JSON DEVICE_VER GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb device_version)
project(${QMK_KEYBOARD}
LANGUAGES C CXX ASM
HOMEPAGE_URL ${URL}
VERSION ${DEVICE_VER})
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" VERSION_MATCH ${DEVICE_VER})
set(VERSION_MAJOR ${CMAKE_MATCH_1})
set(VERSION_MINOR ${CMAKE_MATCH_2})
set(VERSION_PATCH ${CMAKE_MATCH_3})
math(EXPR VERSION_C_EVAL "${VERSION_MAJOR} * 10000 + ${VERSION_MINOR} * 100 + ${VERSION_PATCH}" OUTPUT_FORMAT HEXADECIMAL)
add_compile_options(
-include ${QMK_KEYBOARD_CONFIG_H}
)
add_compile_definitions(
QMK_KEYBOARD_H="${QMK_KEYBOARD_H}"
KEYMAP_C="${QMK_KEYMAP_C}"
MATRIX_ROWS=6
MATRIX_COLS=15
VENDOR_ID=${VENDOR_ID}
PRODUCT_ID=${PRODUCT_ID}
DEVICE_VER=${VERSION_C_EVAL}
MANUFACTURER="${MANUFACTURER}"
PRODUCT="${KEYBOARD_NAME}"
)
# if(EXISTS ${QMK_KEYBOARD_FOLDER_ABS}/CMakeLists.txt)
# add_subdirectory(${QMK_KEYBOARD_FOLDER_ABS})
# else()
file(GLOB KEYBOARD_SRC "${QMK_KEYBOARD_FOLDER_ABS}/*.c")
list(REMOVE_ITEM KEYBOARD_SRC "${QMK_KEYBOARD_KEYMAP}")
add_qmk_executable(${TARGET_NAME} ${KEYBOARD_SRC})
# endif()
add_library(qmk)
resolve_keyboard_includes(${QMK_KEYBOARD_FOLDER_ABS})
add_subdirectory(quantum)
add_subdirectory(platforms)
add_subdirectory(tmk_core/protocol)
include(features/oled)
include(features/backlight)
include(features/eeprom)
resolve_keyboard(${QMK_KEYBOARD_FOLDER} QMK_KEYBOARD_FOLDER_ABS)
process_keyboard()
cmake_path(IS_PREFIX QMK_KEYBOARDS_FOLDER "${QMK_KEYBOARD_FOLDER_ABS}" IS_KEYBOARDS_FOLDER)
resolve_config_h(${QMK_KEYBOARD_FOLDER_ABS} QMK_KEYBOARD_CONFIG_H)
resolve_keyboard_h(${QMK_KEYBOARD_FOLDER_ABS} QMK_KEYBOARD_H)
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}")
project(${QMK_KEYBOARD}
LANGUAGES C CXX ASM
HOMEPAGE_URL ${URL}
VERSION ${DEVICE_VER})
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" VERSION_MATCH ${DEVICE_VER})
set(VERSION_MAJOR ${CMAKE_MATCH_1})
set(VERSION_MINOR ${CMAKE_MATCH_2})
set(VERSION_PATCH ${CMAKE_MATCH_3})
math(EXPR VERSION_C_EVAL "${VERSION_MAJOR} * 10000 + ${VERSION_MINOR} * 100 + ${VERSION_PATCH}" OUTPUT_FORMAT HEXADECIMAL)
# add_compile_options(
# -include ${QMK_KEYBOARD_CONFIG_H}
# )
add_compile_definitions(
QMK_KEYBOARD_H="${QMK_KEYBOARD_H}"
KEYBOARD_${QMK_KEYBOARD}
KEYMAP_C="${QMK_KEYMAP_C}"
MATRIX_ROWS=8
MATRIX_COLS=6
VENDOR_ID=${VENDOR_ID}
PRODUCT_ID=${PRODUCT_ID}
DEVICE_VER=${VERSION_C_EVAL}
MANUFACTURER="${MANUFACTURER}"
PRODUCT="${KEYBOARD_NAME}"
)
if(DEFINED DIODE_DIRECTION)
add_compile_definitions(DIODE_DIRECTION=${DIODE_DIRECTION})
endif()
include_directories(${CMAKE_SOURCE_DIR})
# if(EXISTS ${QMK_KEYBOARD_FOLDER_ABS}/CMakeLists.txt)
# add_subdirectory(${QMK_KEYBOARD_FOLDER_ABS})
# else()
file(GLOB KEYBOARD_SRC "${QMK_KEYBOARD_FOLDER_ABS}/*.c")
list(REMOVE_ITEM KEYBOARD_SRC "${QMK_KEYMAP_C}")
add_qmk_executable(${TARGET_NAME} ${KEYBOARD_SRC})
# endif()
# add_library(qmk)
target_precompile_headers(qmk PUBLIC
${QMK_KEYBOARD_CONFIG_H}
)
resolve_keyboard_includes(${QMK_KEYBOARD_FOLDER_ABS})
add_subdirectory(quantum)
add_subdirectory(platforms)
add_subdirectory(tmk_core/protocol)
include(features/oled)
include(features/backlight)
include(features/eeprom)
include(features/matrix)
include(features/fnv)
endif()

View File

@ -61,7 +61,7 @@ macro(add_keyboard KEYBOARD_FOLDER KEYMAP_FOLDER)
STAMP_DIR ${CMAKE_SOURCE_DIR}/build/stamp
LOG_DIR ${CMAKE_SOURCE_DIR}/build/log
INSTALL_DIR ${CMAKE_SOURCE_DIR}/build/install
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/build/${TARGET_NAME}.hex ${CMAKE_SOURCE_DIR}/${TARGET_NAME}.hex
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/build/${TARGET_NAME}${QMK_EXTENSION} ${CMAKE_SOURCE_DIR}/${TARGET_NAME}${QMK_EXTENSION}
# this seems to work well for all systems so far - not sure if it'd be useful to customize
CMAKE_GENERATOR "Unix Makefiles"
CMAKE_ARGS

View File

@ -39,6 +39,6 @@ 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")
file(APPEND "${CMAKE_SOURCE_DIR}/build/targets" "${TARGET_NAME}|${KEYBOARD_NAME} with ${QMK_KEYMAP_FOLDER}|${QMK_KEYBOARD_FOLDER}:${QMK_KEYMAP_FOLDER}|Made by: ${MANUFACTURER}\n")
message(STATUS "Added keyboard '${QMK_KEYBOARD_FOLDER}' with keymap '${QMK_KEYMAP_FOLDER}'")

View File

@ -6,16 +6,44 @@ set(MCU "cortex-m4")
set(ARMV 7)
set(MCU_FAMILY "STM32")
set(MCU_SERIES "STM32F3xx")
string(TOUPPER ${MCU_SERIES} MCU_SERIES_UPPER)
set(MCU_LDSCRIPT "STM32F303xC")
set(MCU_STARTUP "stm32f3xx")
set(BOARD "GENERIC_STM32_F303XC")
set(USE_FPU TRUE)
set(UF2_FAMILY "STM32F3")
set(STM32_BOOTLOADER_ADDRESS 0x1FFFD800)
set(EEPROM_DRIVER "wear_leveling" CACHE STRING "" FORCE)
set(EEPROM_DRIVER "wear_leveling" FORCE)
set(WEAR_LEVELING_DRIVER "embedded_flash" FORCE)
target_compile_definitions(qmk PUBLIC
QMK_MCU_FAMILY_${MCU_FAMILY}
QMK_MCU_SERIES_${MCU_SERIES_UPPER}
)
target_compile_options(qmk PUBLIC
-march=armv7-m
)
target_compile_definitions(qmk PUBLIC
MCU_${MCU_FAMILY}
__ARM_ARCH_7M__
)
# platforms/chibios/platform.mk
if(NOT DEFINED USE_PROCESS_STACKSIZE)
set(USE_PROCESS_STACKSIZE 0x800)
endif()
if(NOT DEFINED USE_EXCEPTIONS_STACKSIZE)
set(USE_EXCEPTIONS_STACKSIZE 0x400)
endif()
target_link_options(qmk PUBLIC
-Wl,--defsym=__process_stack_size__=${USE_PROCESS_STACKSIZE},--defsym=__main_stack_size__=${USE_EXCEPTIONS_STACKSIZE}
)
if(NOT DEFINED MCU_PORT_NAME)
set(MCU_PORT_NAME ${MCU_FAMILY})
endif()
@ -42,6 +70,7 @@ find_file(STARTUP_MK startup_${MCU_STARTUP}.mk
${CHIBIOS}/os/common/startup/ARMCMx/compilers/GCC/mk
${CHIBIOS_CONTRIB}/os/common/startup/ARMCMx/compilers/GCC/mk
)
get_filename_component(STARTUP_DIR ${STARTUP_MK} DIRECTORY)
ParseMakefile(${STARTUP_MK})
target_sources(qmk PUBLIC ${STARTUPSRC} ${STARTUPASM})
target_include_directories(qmk PUBLIC ${STARTUPINC})
@ -54,15 +83,42 @@ NAMES
PATHS
${QMK_KEYBOARD_FOLDER}/boards/${BOARD}
${CMAKE_SOURCE_DIR}/platforms/chibios/boards/${BOARD}
${CHIBIOS}/os/hal/
${CHIBIOS_CONTRIB}/os/hal/
)
# if(EXISTS ${BOARD_PATH}/rules.mk)
# ParseMakefile(${BOARD_PATH}/rules.mk)
# endif()
if(EXISTS ${BOARD_PATH}/configs/config.h)
target_precompile_headers(qmk PUBLIC
${BOARD_PATH}/configs/config.h
)
endif()
if(EXISTS ${BOARD_PATH}/configs/post_config.h)
target_precompile_headers(qmk PUBLIC
${BOARD_PATH}/configs/post_config.h
)
endif()
find_file(BOARD_MK board.mk
${BOARD_PATH}/boards/${BOARD}
${BOARD_PATH}/board
)
ParseMakefile(${BOARD_MK})
target_sources(qmk PUBLIC ${BOARDSRC})
target_include_directories(qmk PUBLIC ${BOARDINC})
# allow board.c to be overriden
file(RELATIVE_PATH INIT_HOOK_RELATIVE ${CMAKE_BINARY_DIR}
"${CMAKE_SOURCE_DIR}/tmk_core/protocol/chibios/init_hooks.h")
set_source_files_properties(${BOARDSRC} TARGET_DIRECTORY qmk PROPERTIES
# COMPILE_OPTIONS "-include ../../../tmk_core/protocol/chibios/init_hooks.h"
COMPILE_OPTIONS "-include ${INIT_HOOK_RELATIVE}"
)
# bootloader
if(DEFINED STM32_BOOTLOADER_ADDRESS)
target_compile_definitions(qmk PUBLIC STM32_BOOTLOADER_ADDRESS=${STM32_BOOTLOADER_ADDRESS})
@ -101,6 +157,13 @@ find_file(LDSCRIPT ${MCU_LDSCRIPT}.ld
${QMK_KEYBOARD_FOLDER}/ld
${CMAKE_SOURCE_DIR}/platforms/chibios/boards/${BOARD}/ld
${CMAKE_SOURCE_DIR}/platforms/chibios/boards/common/ld
${STARTUPLD}
${STARTUPLD_CONTRIB}
)
get_filename_component(LDSCRIPT_PATH ${LDSCRIPT} DIRECTORY)
target_link_options(qmk PUBLIC
-T ${LDSCRIPT}
-L ${LDSCRIPT_PATH}
)
# os/hal/hal.mk

51
cmake/GetKeymaps.cmake Normal file
View File

@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 3.20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(ResolveKeyboard)
include(ValidateJson)
set(QMK_KEYBOARDS_FOLDER "${CMAKE_SOURCE_DIR}/keyboards")
set(CMAKE_MESSAGE_INDENT "")
resolve_keyboard(${QMK_KEYBOARD_FOLDER} KEYBOARD_FOLDER_ABS)
validate_json(${KEYBOARD_FOLDER_ABS}/info.json keyboard JSON_STR)
cmake_path(IS_PREFIX QMK_KEYBOARDS_FOLDER "${KEYBOARD_FOLDER_ABS}" IS_KEYBOARDS_FOLDER)
file(WRITE "${CMAKE_SOURCE_DIR}/build/keyboard_keymaps" "")
if(${IS_KEYBOARDS_FOLDER})
file(RELATIVE_PATH RELATIVE_KEYBOARD_FOLDER ${QMK_KEYBOARDS_FOLDER} ${KEYBOARD_FOLDER_ABS})
while(NOT ${RELATIVE_KEYBOARD_FOLDER} STREQUAL "")
file(GLOB KEYMAPS "${QMK_KEYBOARDS_FOLDER}/${RELATIVE_KEYBOARD_FOLDER}/keymaps/*/keymap.c")
foreach(KEYMAP ${KEYMAPS})
file(RELATIVE_PATH KEYMAP_C "${QMK_KEYBOARDS_FOLDER}/${RELATIVE_KEYBOARD_FOLDER}/keymaps" "${KEYMAP}")
get_filename_component(KEYMAP_FOLDER ${KEYMAP_C} DIRECTORY)
# message(STATUS "${KEYMAP_FOLDER}")
file(APPEND "${CMAKE_SOURCE_DIR}/build/keyboard_keymaps" "${KEYMAP_FOLDER}\n")
endforeach()
get_filename_component(RELATIVE_KEYBOARD_FOLDER ${RELATIVE_KEYBOARD_FOLDER} DIRECTORY)
endwhile()
else()
if(EXISTS "${KEYBOARD_FOLDER_ABS}/keymap.c")
set(${KEYMAP_C_STR} "${KEYBOARD_FOLDER_ABS}/keymap.c" PARENT_SCOPE)
elseif(EXISTS "${KEYBOARD_FOLDER_ABS}/keymaps/${KEYMAP_FOLDER}/keymap.c")
set(${KEYMAP_C_STR} "${KEYBOARD_FOLDER_ABS}/keymaps/${KEYMAP_FOLDER}/keymap.c" PARENT_SCOPE)
endif()
endif()
string(JSON COMMUNITY_LAYOUTS ERROR_VARIABLE NO_COMMUNITY_LAYOUTS GET ${JSON_STR} community_layouts)
if(${NO_COMMUNITY_LAYOUTS} STREQUAL "NOTFOUND")
string(JSON NUM_LAYOUTS LENGTH ${COMMUNITY_LAYOUTS})
math(EXPR MAX "${NUM_LAYOUTS} - 1")
foreach(IDX RANGE ${MAX})
string(JSON LAYOUT GET ${COMMUNITY_LAYOUTS} ${IDX})
file(GLOB KEYMAPS "${CMAKE_SOURCE_DIR}/layouts/community/${LAYOUT}/*/keymap.c")
foreach(KEYMAP ${KEYMAPS})
file(RELATIVE_PATH KEYMAP_C "${CMAKE_SOURCE_DIR}/layouts/community/${LAYOUT}" "${KEYMAP}")
get_filename_component(KEYMAP_FOLDER ${KEYMAP_C} DIRECTORY)
# message(STATUS "${KEYMAP_FOLDER}")
file(APPEND "${CMAKE_SOURCE_DIR}/build/keyboard_keymaps" "${KEYMAP_FOLDER}\n")
endforeach()
endforeach()
endif()

View File

@ -1,10 +1,10 @@
# Simple CMake utility to read variables from MK files
# - Gets contents from given file (name or path)
# - Parses the assignment statements
# - Makes the same assignments in the PARENT_SCOPE
# - Gets contents from given file (name or path)
# - Parses the assignment statements
# - Makes the same assignments in the PARENT_SCOPE
if(POLICY CMP0007)
cmake_policy(SET CMP0007 NEW)
cmake_policy(SET CMP0007 NEW)
endif()
function(ParseMakefile MKFile)
@ -12,38 +12,61 @@ function(ParseMakefile MKFile)
endfunction()
macro(_ParseMakefile MKFile)
message(STATUS "Parsing ${MKFile}")
file(READ "${MKFile}" FileContents)
string(REGEX REPLACE "\\\\\r?\n *" " " FileContents ${FileContents})
string(REGEX REPLACE "\r?\n" ";" FileLines ${FileContents})
list(REMOVE_ITEM FileLines "")
foreach(line ${FileLines})
# if(line MATCHES "\\$\\((.+)\\)")
# set(MAKE_VARIABLE "${CMAKE_MATCH_1}")
# string(REPLACE "$(${MAKE_VARIABLE})" "${${MAKE_VARIABLE}}" line ${line})
# endif()
# message(STATUS "From: ${line}")
string(REGEX REPLACE "\\$\\(([^\\(\\)]+)\\)" "${CHIBIOS}" line ${line})
# message(STATUS "To : ${line}")
# if(line MATCHES "^include (.+)$")
# set(MAKE_CHILD ${CMAKE_MATCH_1})
# message(STATUS "Reading ${MAKE_CHILD}")
# _ParseMakefile("${MAKE_CHILD}")
# else()
string(REPLACE "=" ";" line_split ${line})
list(LENGTH line_split count)
if (count LESS 2)
message(STATUS "Skipping ${line}")
message(VERBOSE "Parsing ${MKFile}")
file(READ "${MKFile}" FileContents)
string(REGEX REPLACE "\\\\\r?\n *" " " FileContents ${FileContents})
string(REGEX REPLACE "(\r?\n)+" ";" FileLines ${FileContents})
list(REMOVE_ITEM FileLines "")
foreach(line ${FileLines})
# if(line MATCHES "\\$\\((.+)\\)")
# set(MAKE_VARIABLE "${CMAKE_MATCH_1}")
# string(REPLACE "$(${MAKE_VARIABLE})" "${${MAKE_VARIABLE}}" line ${line})
# endif()
# message(STATUS "From: ${line}")
string(REGEX REPLACE "#.*" "" line ${line})
if("${line}" STREQUAL "")
continue()
endif()
string(REGEX REPLACE "\\$\\(([^\\(\\)]+)\\)" "${CHIBIOS}" line ${line})
# message(STATUS "To : ${line}")
# if(line MATCHES "^include (.+)$")
# set(MAKE_CHILD ${CMAKE_MATCH_1})
# message(STATUS "Reading ${MAKE_CHILD}")
# _ParseMakefile("${MAKE_CHILD}")
# else()
string(REPLACE "=" ";" line_split ${line})
list(LENGTH line_split count)
if(count LESS 2)
message(VERBOSE "Skipping ${line}")
continue()
endif()
list(GET line_split -1 value)
string(STRIP ${value} value)
separate_arguments(value)
list(REMOVE_AT line_split -1)
foreach(var_name ${line_split})
string(STRIP ${var_name} var_name)
set(${var_name} ${value} PARENT_SCOPE)
if(${var_name} MATCHES "([^ \\+]+) *\\+")
message(VERBOSE "Appending '${CMAKE_MATCH_1}' with '${value}'")
set(${CMAKE_MATCH_1} ${${CMAKE_MATCH_1}} ${value} PARENT_SCOPE)
else()
if(DEFINED CACHE${${var_name}})
message(VERBOSE "Caching '${var_name}' to '${value}'")
set(${var_name} ${value} CACHE INTERNAL "")
else()
message(VERBOSE "Setting '${var_name}' to '${value}'")
set(${var_name} ${value} PARENT_SCOPE)
endif()
endif()
endforeach()
# endif()
endforeach()
# endif()
endforeach()
endmacro()

View File

@ -0,0 +1,17 @@
include(ParseMakefile)
macro(process_keyboard)
validate_json(${QMK_KEYBOARD_FOLDER_ABS}/info.json keyboard QMK_KEYBOARD_INFO_JSON_STRING)
string(JSON KEYBOARD_NAME GET ${QMK_KEYBOARD_INFO_JSON_STRING} keyboard_name)
string(JSON MANUFACTURER GET ${QMK_KEYBOARD_INFO_JSON_STRING} manufacturer)
string(JSON URL GET ${QMK_KEYBOARD_INFO_JSON_STRING} url)
string(JSON QMK_MCU GET ${QMK_KEYBOARD_INFO_JSON_STRING} processor)
string(JSON VENDOR_ID GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb vid)
string(JSON PRODUCT_ID GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb pid)
string(JSON DEVICE_VER GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb device_version)
string(JSON DIODE_DIRECTION ERROR_VARIABLE _ GET ${QMK_KEYBOARD_INFO_JSON_STRING} diode_direction)
string(JSON BOOTLOADER ERROR_VARIABLE _ GET ${QMK_KEYBOARD_INFO_JSON_STRING} bootloader)
ParseMakefile(${QMK_KEYBOARD_FOLDER_ABS}/rules.mk)
endmacro()

View File

@ -1,24 +1,24 @@
function(resolve_keyboard KEYBOARD KEYBOAD_FOLDER_ABS_STR)
message(STATUS "Resolving ${KEYBOARD}")
message(VERBOSE "Resolving ${KEYBOARD}")
if(EXISTS "${CMAKE_SOURCE_DIR}/keyboards/${KEYBOARD}")
message(STATUS "Found in repo: ${KEYBOARD}")
message(VERBOSE "Found in repo: ${KEYBOARD}")
set(${KEYBOAD_FOLDER_ABS_STR} "${CMAKE_SOURCE_DIR}/keyboards/${KEYBOARD}" PARENT_SCOPE)
return()
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/build/keyboard_repository/${KEYBOARD}")
message(STATUS "Already checked out: ${KEYBOARD}")
message(VERBOSE "Already checked out: ${KEYBOARD}")
set(${KEYBOAD_FOLDER_ABS_STR} "${CMAKE_SOURCE_DIR}/build/keyboard_repository/${KEYBOARD}" PARENT_SCOPE)
return()
endif()
file(READ ${CMAKE_SOURCE_DIR}/data/keyboards.json KEYBOARDS_JSON)
string(JSON KEYBOARD_SLUG ERROR_VARIABLE JSON_ERROR GET ${KEYBOARDS_JSON} ${KEYBOARD})
if(${JSON_ERROR} STREQUAL "NOTFOUND")
message(STATUS "Found ${KEYBOARD_SLUG}")
message(VERBOSE "Found ${KEYBOARD_SLUG}")
if(${KEYBOARD_SLUG} MATCHES "^@([0-9a-zA-Z_]+/[0-9a-zA-Z_]+)")
# keyboard slug is mapped to a github repo
set(GIT_SLUG ${CMAKE_MATCH_1})
# string(MAKE_C_IDENTIFIER ${KEYBOARD} KEYBOARD_NAME)
message(STATUS "Cloning ${GIT_SLUG}")
message(VERBOSE "Cloning ${GIT_SLUG}")
find_package(Git QUIET)
if(GIT_FOUND)
file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/build/keyboard_repository/${KEYBOARD}")
@ -88,8 +88,7 @@ function(resolve_keymap_c KEYBOARD_FOLDER_ABS KEYMAP_FOLDER KEYMAP_C_STR)
if(IS_ABSOLUTE ${KEYMAP_FOLDER})
if(EXISTS "${KEYMAP_FOLDER}/keymap.c")
set(${KEYMAP_C_STR} "${KEYMAP_FOLDER}/keymap.c" PARENT_SCOPE)
else()
message(FATAL_ERROR "Could not find keymap.c in ${KEYMAP_FOLDER}")
return()
endif()
else()
if(${IS_KEYBOARDS_FOLDER})
@ -102,17 +101,31 @@ function(resolve_keymap_c KEYBOARD_FOLDER_ABS KEYMAP_FOLDER KEYMAP_C_STR)
endif()
get_filename_component(RELATIVE_KEYBOARD_FOLDER ${RELATIVE_KEYBOARD_FOLDER} DIRECTORY)
endwhile()
message(FATAL_ERROR "Could not find keymap.c in ${KEYBOARD_FOLDER_ABS}")
else()
if(EXISTS "${KEYBOARD_FOLDER_ABS}/keymap.c")
set(${KEYMAP_C_STR} "${KEYBOARD_FOLDER_ABS}/keymap.c" PARENT_SCOPE)
return()
elseif(EXISTS "${KEYBOARD_FOLDER_ABS}/keymaps/${KEYMAP_FOLDER}/keymap.c")
set(${KEYMAP_C_STR} "${KEYBOARD_FOLDER_ABS}/keymaps/${KEYMAP_FOLDER}/keymap.c" PARENT_SCOPE)
else()
message(FATAL_ERROR "Could not find keymap.c in ${KEYBOARD_FOLDER_ABS}")
return()
endif()
endif()
endif()
string(JSON COMMUNITY_LAYOUTS ERROR_VARIABLE NO_COMMUNITY_LAYOUTS GET ${QMK_KEYBOARD_INFO_JSON_STRING} community_layouts)
if(${NO_COMMUNITY_LAYOUTS} STREQUAL "NOTFOUND")
string(JSON NUM_LAYOUTS LENGTH ${COMMUNITY_LAYOUTS})
math(EXPR MAX "${NUM_LAYOUTS} - 1")
foreach(IDX RANGE ${MAX})
string(JSON LAYOUT GET ${COMMUNITY_LAYOUTS} ${IDX})
if(EXISTS "${CMAKE_SOURCE_DIR}/layouts/community/${LAYOUT}/${KEYMAP_FOLDER}/keymap.c")
set(${KEYMAP_C_STR} "${CMAKE_SOURCE_DIR}/layouts/community/${LAYOUT}/${KEYMAP_FOLDER}/keymap.c" PARENT_SCOPE)
return()
endif()
endforeach()
endif()
message(FATAL_ERROR "Could not resolve keymap '${KEYMAP_FOLDER}'")
endfunction()
function(resolve_keyboard_includes KEYBOARD_FOLDER_ABS)

View File

@ -4,6 +4,7 @@ function(resolve_toolchain PROCESSOR TOOLCHAIN_STR)
${PROCESSOR} MATCHES "^at.*"
)
set(${TOOLCHAIN_STR} "avr" PARENT_SCOPE)
set(QMK_EXTENSION ".hex" PARENT_SCOPE)
include(FindAVRToolchain)
find_avr_toolchain()
elseif(
@ -14,12 +15,14 @@ function(resolve_toolchain PROCESSOR TOOLCHAIN_STR)
${PROCESSOR} MATCHES "^GD32.*"
)
set(${TOOLCHAIN_STR} "arm-none-eabi" PARENT_SCOPE)
set(QMK_EXTENSION ".bin" PARENT_SCOPE)
include(FindARMToolchain)
find_arm_toolchain()
elseif(
${PROCESSOR} MATCHES "risc-v"
)
set(${TOOLCHAIN_STR} "riscv32-unknown-elf" PARENT_SCOPE)
set(QMK_EXTENSION ".bin" PARENT_SCOPE)
else()
message(FATAL_ERROR "Could not find toolchain for ${PROCESSOR}")
endif()

View File

@ -1,6 +1,6 @@
function(validate_json JSON_FILE SCHEMA_NAME JSON_STRING_STR)
unset(${JSON_STRING_STR} PARENT_SCOPE)
message(STATUS "Validating ${JSON_FILE} with '${SCHEMA_NAME}' schema")
message(VERBOSE "Validating ${JSON_FILE} with '${SCHEMA_NAME}' schema")
file(READ ${JSON_FILE} JSON_STRING)
file(READ ${CMAKE_SOURCE_DIR}/data/schemas/${SCHEMA_NAME}.jsonschema SCHEMA_STRING)
string(JSON SCHEMA_ID GET ${SCHEMA_STRING} $id)
@ -19,7 +19,7 @@ function(validate_json JSON_FILE SCHEMA_NAME JSON_STRING_STR)
# foreach(IDX RANGE ${MAX})
# string(JSON DEFINITION_NAME MEMBER ${SCHEMA_DEFINITIONS} ${IDX})
# string(JSON DEFINITION GET ${SCHEMA_DEFINITIONS} ${DEFINITION_NAME})
# message(DEBUG "Loading local definition '${DEFINITION_NAME}'")
# message(VERBOSE "Loading local definition '${DEFINITION_NAME}'")
# string(JSON DEFINITIONS_STRING SET ${DEFINITIONS_STRING} ${DEFINITION_NAME} ${DEFINITION})
# endforeach()
endif()
@ -51,7 +51,7 @@ function(validate_object JSON_STRING SCHEMA_STRING OBJECT_ERROR_STR)
foreach(IDX RANGE ${MAX})
string(JSON PROPERTY_NAME MEMBER ${JSON_STRING} ${IDX})
list(REMOVE_ITEM REQUIRED_LIST ${PROPERTY_NAME})
message(DEBUG "Validating property '${PROPERTY_NAME}'")
message(VERBOSE "Validating property '${PROPERTY_NAME}'")
if(${PROPERTY_NAMES_ERROR} STREQUAL "NOTFOUND")
validate_property(${PROPERTY_NAME} ${PROPERTY_NAME_SCHEMA} PROPERTY_NAME_ERROR)
if(DEFINED PROPERTY_NAME_ERROR)
@ -90,7 +90,7 @@ function(validate_property PROPERTY PROPERTY_SCHEMA PROPERTY_ERROR_STR)
endif()
string(JSON PROPERTY_TYPE ERROR_VARIABLE JSON_ERROR GET ${PROPERTY_SCHEMA} type)
if(${JSON_ERROR} STREQUAL "NOTFOUND")
message(DEBUG "Validating property type '${PROPERTY_TYPE}'")
message(VERBOSE "Validating property type '${PROPERTY_TYPE}'")
if(${PROPERTY_TYPE} STREQUAL "object")
validate_object(${PROPERTY} ${PROPERTY_SCHEMA} OBJECT_ERROR)
if(DEFINED OBJECT_ERROR)
@ -172,7 +172,7 @@ function(validate_property PROPERTY PROPERTY_SCHEMA PROPERTY_ERROR_STR)
endif()
endif()
else()
message(STATUS "Unknown type '${PROPERTY_TYPE}'")
message(VERBOSE "Unknown type '${PROPERTY_TYPE}'")
endif()
else()
string(JSON PROPERTY_ONEOF ERROR_VARIABLE JSON_ERROR GET ${PROPERTY_SCHEMA} oneOf)

View File

@ -3,7 +3,7 @@ set(BACKLIGHT_DRIVER "pwm" CACHE STRING "Backlight driver")
set_property(CACHE BACKLIGHT_DRIVER PROPERTY STRINGS pwm timer software custom)
string(JSON BACKLIGHT_PIN ERROR_VARIABLE NO_BACKLIGHT_PIN GET ${QMK_KEYBOARD_INFO_JSON_STRING} backlight pin)
if(${BACKLIGHT_ENABLE} AND NOT ${NO_BACKLIGHT_PIN} STREQUAL "backlight-NOTFOUND")
if(${BACKLIGHT_ENABLE} AND NOT ${BACKLIGHT_PIN} STREQUAL "backlight-NOTFOUND")
target_sources(qmk PUBLIC
quantum/backlight/backlight.c
quantum/process_keycode/process_backlight.c

View File

@ -3,6 +3,15 @@ set_property(CACHE EEPROM_DRIVER PROPERTY STRINGS vendor custom transient i2c sp
set(WEAR_LEVELING_DRIVER "none" CACHE STRING "EEPROM wear-leveling driver")
set_property(CACHE WEAR_LEVELING_DRIVER PROPERTY STRINGS custom embedded_flash spi_flash rp2040_flash legacy)
target_compile_definitions(qmk PUBLIC
EEPROM_ENABLE
)
target_include_directories(qmk PUBLIC
platforms/${QMK_PLATFORM}/drivers/eeprom
drivers/eeprom
platforms/common
)
if(${EEPROM_DRIVER} STREQUAL "wear_leveling")
target_compile_definitions(qmk PUBLIC
EEPROM_DRIVER
@ -12,13 +21,12 @@ if(${EEPROM_DRIVER} STREQUAL "wear_leveling")
drivers/eeprom/eeprom_driver.c
drivers/eeprom/eeprom_wear_leveling.c
)
target_include_directories(qmk PUBLIC drivers/eeprom)
elseif(${EEPROM_DRIVER} STREQUAL "vendor")
target_compile_definitions(qmk PUBLIC
EEPROM_VENDOR
)
if(${QMK_PLATFORM} STREQUAL "chibios")
if(${QMK_MCU} MATHCES "STM32F.*")
if(${QMK_MCU} MATCHES "STM32F[1-9].*" OR ${QMK_MCU} MATCHES "WB32.*" OR ${QMK_MCU} MATCHES "GD32.*")
target_compile_definitions(qmk PUBLIC
EEPROM_DRIVER
EEPROM_WEAR_LEVELING
@ -27,28 +35,36 @@ elseif(${EEPROM_DRIVER} STREQUAL "vendor")
drivers/eeprom/eeprom_driver.c
drivers/eeprom/eeprom_wear_leveling.c
)
set(WEAR_LEVELING_DRIVER "embedded_flash" FORCE)
set(WEAR_LEVELING_DRIVER "embedded_flash")
endif()
endif()
endif()
if(NOT ${WEAR_LEVELING_DRIVER} STREQUAL "none")
set(FNV_ENABLE TRUE)
target_compile_definitions(qmk PUBLIC
WEAR_LEVELING_ENABLE
WEAR_LEVELING_EMBEDDED_FLASH
)
target_include_directories(qmk PUBLIC
platforms/${QMK_PLATFORM}/drivers/wear_leveling
drivers/wear_leveling
quantum/wear_leveling
)
target_sources(qmk PUBLIC wear_leveling.c)
target_sources(qmk PUBLIC quantum/wear_leveling/wear_leveling.c)
if(NOT ${WEAR_LEVELING_DRIVER} STREQUAL "embedded_flash")
if(${WEAR_LEVELING_DRIVER} STREQUAL "embedded_flash")
target_compile_definitions(qmk PUBLIC
HAL_USE_EFL
WEAR_LEVELING_EMBEDDED_FLASH
)
target_sources(qmk PUBLIC
platforms/${QMK_PLATFORM}/drivers/wear_leveling/wear_leveling_efl.c
)
# target_compile_options(qmk PUBLIC
# -include ${CMAKE_SOURCE_DIR}/platforms/${QMK_PLATFORM}/drivers/wear_leveling/wear_leveling_efl_config.h
# )
target_precompile_headers(qmk PUBLIC
${CMAKE_SOURCE_DIR}/platforms/${QMK_PLATFORM}/drivers/wear_leveling/wear_leveling_efl_config.h
)
target_sources(qmk PUBLIC wear_leveling_efl.c)
# post config.h platforms/${QMK_PLATFORM}/drivers/wear_leveling/wear_leveling_efl_config.h
endif()
endif()

9
cmake/features/fnv.cmake Normal file
View File

@ -0,0 +1,9 @@
if(${FNV_ENABLE})
target_compile_definitions(qmk PUBLIC FNV_ENABLE)
target_include_directories(qmk PUBLIC lib/fnv)
target_sources(qmk PUBLIC
lib/fnv/qmk_fnv_type_validation.c
lib/fnv/hash_32a.c
lib/fnv/hash_64a.c
)
endif()

View File

@ -0,0 +1,9 @@
message(STATUS "Custom Matrix: ${CUSTOM_MATRIX}")
set(CUSTOM_MATRIX "no" CACHE STRING "Custom matrix-scanning")
set_property(CACHE CUSTOM_MATRIX PROPERTY STRINGS yes lite no)
if(NOT ${CUSTOM_MATRIX} STREQUAL yes)
target_sources(qmk PUBLIC quantum/matrix_common.c)
if(NOT ${CUSTOM_MATRIX} STREQUAL lite)
target_sources(qmk PUBLIC quantum/matrix.c)
endif()
endif()

View File

@ -1,4 +1,4 @@
option(OLED_ENABLE "" TRUE)
option(OLED_ENABLE "" OFF)
if(${OLED_ENABLE})
target_sources(qmk PUBLIC
drivers/oled/ssd1306_sh1106.c
@ -7,7 +7,4 @@ if(${OLED_ENABLE})
target_include_directories(qmk PUBLIC drivers)
target_include_directories(qmk PUBLIC drivers/oled)
target_include_directories(qmk PUBLIC platforms/${QMK_PLATFORM}/drivers)
# target_link_libraries(oled qmk)
# target_link_libraries(oled ${QMK_TARGET})
# target_link_libraries(oled platforms)
endif()

View File

@ -5,6 +5,7 @@ include(ResolveToolchain)
set(QMK_TOOLCHAIN "arm-none-eabi")
set(QMK_PLATFORM "chibios")
set(QMK_PROTOCOL "chibios")
set(QMK_EXTENSION ".bin")
if(UNIX)
set(OS_SUFFIX "")
@ -28,7 +29,7 @@ set(CMAKE_OBJCOPY "${TOOLCHAIN_ROOT}/${QMK_TOOLCHAIN}-objcopy${OS_SUFFIX}"
set(CMAKE_OBJDUMP "${TOOLCHAIN_ROOT}/${QMK_TOOLCHAIN}-objdump${OS_SUFFIX}" CACHE PATH "objdump" FORCE)
set(CMAKE_STRIP "${TOOLCHAIN_ROOT}/${QMK_TOOLCHAIN}-strip${OS_SUFFIX}" CACHE PATH "strip" FORCE)
set(CMAKE_RANLIB "${TOOLCHAIN_ROOT}/${QMK_TOOLCHAIN}-ranlib${OS_SUFFIX}" CACHE PATH "ranlib" FORCE)
set(AVR_SIZE "${TOOLCHAIN_ROOT}/${QMK_TOOLCHAIN}-size${OS_SUFFIX}" CACHE PATH "size" FORCE)
set(CMAKE_SIZE "${TOOLCHAIN_ROOT}/${QMK_TOOLCHAIN}-size${OS_SUFFIX}" CACHE PATH "size" FORCE)
find_program(CMAKE_MAKE_PROGRAM NAME make
PATHS
@ -73,89 +74,71 @@ add_link_options(
-nostartfiles
-Wl,--no-wchar-size-warning
--specs=nano.specs
-lm
)
if(${USE_FPU})
add_compile_definitions(
CORTEX_USE_FPU=TRUE
)
add_link_options(
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
-fsingle-precision-constant
)
else()
add_compile_definitions(
CORTEX_USE_FPU=FALSE
)
endif()
macro(add_qmk_executable target_name)
set(elf_file ${target_name}.elf)
set(map_file ${target_name}.map)
set(hex_file ${target_name}.hex)
set(bin_file ${target_name}.bin)
set(lst_file ${target_name}.lst)
# create elf file
add_executable(${elf_file} ${ARGN})
add_link_options(
-Wl,-Map=${map_file},--cref
)
target_link_libraries(${elf_file} qmk)
# create elf file
add_executable(qmk ${ARGN})
# add_executable(${elf_file} ${ARGN})
# target_link_libraries(${elf_file} qmk)
set_target_properties(qmk
PROPERTIES
OUTPUT_NAME ${elf_file}
)
# generate the lst file
add_custom_command(
OUTPUT ${lst_file}
COMMAND
${CMAKE_OBJDUMP} -h -S ${elf_file} > ${lst_file}
DEPENDS ${elf_file}
COMMAND ${CMAKE_OBJDUMP} -h -S ${elf_file} > ${lst_file}
DEPENDS qmk
)
# create hex file
add_custom_command(
OUTPUT ${hex_file}
# add_custom_command(
# OUTPUT "print-size-${elf_file}"
COMMAND
${CMAKE_OBJCOPY} -j .text -j .data -O ihex ${elf_file} ${hex_file}
# COMMAND
# ${CMAKE_SIZE} ${elf_file}
DEPENDS ${elf_file}
)
# DEPENDS ${elf_file}
# )
# add_custom_command(
# OUTPUT "print-size-${bin_file}"
# COMMAND
# ${CMAKE_SIZE} ${bin_file} sizeafter
# DEPENDS ${bin_file}
# )
add_custom_command(
OUTPUT "print-size-${elf_file}"
COMMAND
${AVR_SIZE} ${elf_file}
DEPENDS ${elf_file}
)
add_custom_command(
OUTPUT "print-size-${hex_file}"
COMMAND
${AVR_SIZE} ${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}
TARGET qmk
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O binary ${elf_file} ${CMAKE_SOURCE_DIR}/build/${bin_file}
# COMMAND ${CMAKE_COMMAND} -E copy ${elf_file} ${CMAKE_SOURCE_DIR}/build/${elf_file}
# COMMAND ${CMAKE_COMMAND} -E copy ${lst_file} ${CMAKE_SOURCE_DIR}/build/${lst_file}
# COMMAND ${CMAKE_COMMAND} -E copy ${map_file} ${CMAKE_SOURCE_DIR}/build/${map_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}" copy_hex
add_custom_target(${target_name} ALL
DEPENDS ${elf_file} ${lst_file}
)
set_target_properties(
${target_name}
set_target_properties(${target_name}
PROPERTIES
OUTPUT_NAME ${elf_file}
OUTPUT_NAME ${bin_file}
)
endmacro(add_qmk_executable)

View File

@ -11,6 +11,7 @@ include(ResolveToolchain)
set(QMK_TOOLCHAIN "avr")
set(QMK_PLATFORM "avr")
set(QMK_PROTOCOL "lufa")
set(QMK_EXTENSION ".hex")
if(UNIX)
set(OS_SUFFIX "")
@ -114,14 +115,15 @@ macro(add_qmk_executable target_name)
)
# create elf file
add_executable(${elf_file} ${ARGN})
# add_executable(${elf_file} ${ARGN})
# target_link_libraries(${elf_file} qmk)
# add_executable(qmk ${ARGN})
# set_target_properties(qmk
# PROPERTIES OUTPUT_NAME ${elf_file}
# )
add_executable(qmk ${ARGN})
set_target_properties(qmk
PROPERTIES
OUTPUT_NAME ${elf_file}
)
target_link_libraries(${elf_file} qmk)
# set_target_properties(${elf_file}
# PROPERTIES
@ -162,7 +164,7 @@ macro(add_qmk_executable target_name)
)
add_custom_target(copy_hex
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${elf_file}> ${CMAKE_SOURCE_DIR}/build/${target_name}.hex
COMMAND ${CMAKE_COMMAND} -E copy ${hex_file} ${CMAKE_SOURCE_DIR}/build/${hex_file}
DEPENDS ${hex_file}
)
@ -172,7 +174,8 @@ macro(add_qmk_executable target_name)
)
set_target_properties(${target_name}
PROPERTIES OUTPUT_NAME ${elf_file}
PROPERTIES
OUTPUT_NAME ${hex_file}
)

View File

@ -24,9 +24,10 @@ file(STRINGS "${CMAKE_SOURCE_DIR}/build/targets" TARGETS)
while(TARGETS)
list(POP_FRONT TARGETS LINE)
if (LINE MATCHES "(.+)\\|(.+)\\|(.+)\\|(.+)")
if (LINE MATCHES "(.+)\\|(.+)\\|(.+):(.+)\\|(.+)")
set(KEYBOARD_FOLDER ${CMAKE_MATCH_3})
add_keyboard(${KEYBOARD_FOLDER} "default")
set(KEYMAP_FOLDER ${CMAKE_MATCH_4})
add_keyboard(${KEYBOARD_FOLDER} ${KEYMAP_FOLDER})
endif()
endwhile()

View File

@ -16,6 +16,7 @@
"processor": "STM32F303",
"bootloader": "stm32-dfu",
"board": "QMK_PROTON_C",
"diode_direction": "COL2ROW",
"community_layouts": ["ortho_4x12", "planck_mit"],
"layouts": {
"LAYOUT_ortho_4x12": {

View File

@ -15,6 +15,7 @@
},
"processor": "STM32F303",
"bootloader": "stm32-dfu",
"diode_direction": "COL2ROW",
"community_layouts": ["ortho_4x12", "planck_mit"],
"layouts": {
"LAYOUT_ortho_4x12": {

View File

@ -1,7 +1,7 @@
find_package(Chibios REQUIRED)
target_link_options(qmk PUBLIC
-mcpu=${QMK_MCU}
-mcpu=${MCU}
-mthumb
-mno-thumb-interwork
-mno-unaligned-access
@ -30,12 +30,26 @@ else()
)
endif()
# bootloader
if(${BOOTLOADER} STREQUAL "stm32-dfu")
target_compile_definitions(qmk PUBLIC BOOTLOADER_STM32_DFU)
set(BOOTLOADER_TYPE stm32_dfu)
endif()
target_sources(qmk PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/syscall-fallbacks.c
${CMAKE_CURRENT_SOURCE_DIR}/wait.c
${CMAKE_CURRENT_SOURCE_DIR}/synchronization_util.c
syscall-fallbacks.c
wait.c
synchronization_util.c
hardware_id.c
platform.c
suspend.c
timer.c
bootloaders/${BOOTLOADER_TYPE}.c
)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/boards/common/configs)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}/configs)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}/configs)
# mabye this should be in a different place
add_subdirectory(${CMAKE_SOURCE_DIR}/quantum/logging logging)

View File

@ -15,17 +15,15 @@ target_sources(qmk PUBLIC
sync_timer.c
logging/debug.c
logging/sendchar.c
matrix_common.c
matrix.c
debounce/sym_defer_g.c
bootmagic/magic.c
)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/logging)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/keymap_extras)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/process_keycode)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/sequencer)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/logging)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/bootmagic)
# target_link_libraries(quantum ${QMK_TARGET})

View File

@ -0,0 +1,19 @@
set(PRINTF_PATH ${CMAKE_SOURCE_DIR}/lib/printf/src)
target_sources(qmk PUBLIC
print.c
${PRINTF_PATH}/printf/printf.c
)
target_include_directories(qmk PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PRINTF_PATH}/printf
${PRINTF_PATH}
)
target_compile_definitions(qmk PUBLIC
PRINTF_SUPPORT_DECIMAL_SPECIFIERS=0
PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS=0
PRINTF_SUPPORT_LONG_LONG=0
PRINTF_SUPPORT_WRITEBACK_SPECIFIER=0
SUPPORT_MSVC_STYLE_INTEGER_SPECIFIERS=0
PRINTF_ALIAS_STANDARD_FUNCTION_NAMES=1
)

View File

@ -13,10 +13,7 @@ target_sources(qmk PUBLIC
)
find_package(Chibios REQUIRED)
# include(FindChibios)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lufa_utils)
# if no printf
target_sources(qmk PUBLIC ${CMAKE_SOURCE_DIR}/lib/printf/src/printf/printf.c)
target_include_directories(qmk PUBLIC ${CMAKE_SOURCE_DIR}/lib/printf/src/printf)
target_include_directories(qmk PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lufa_utils)