fully compiling with qmk target

This commit is contained in:
Jack Humbert 2023-04-04 12:46:29 -04:00
parent 6a960cbf05
commit 060c15f32b
7 changed files with 48 additions and 15 deletions

11
.vscode/tasks.json vendored
View File

@ -16,7 +16,7 @@
{ {
"label": "Load Keyboard", "label": "Load Keyboard",
"type": "shell", "type": "shell",
"command": "cmake -Bbuild -DQMK_KEYBOARD_FOLDER=${input:keyboard}", "command": "cmake -Bbuild -DQMK_KEYBOARD_FOLDER=${input:all_keyboards}",
"problemMatcher": [] "problemMatcher": []
}, },
{ {
@ -90,6 +90,15 @@
"description": "Target:", "description": "Target:",
"fieldSeparator": "|" "fieldSeparator": "|"
}, },
},
{
"id": "all_keyboards",
"type": "command",
"command": "shellCommand.execute",
"args": {
"command": "type build\\all_keyboards",
"description": "Keyboard:"
},
} }
] ]
} }

View File

@ -103,6 +103,8 @@ endif()
add_library(qmk) add_library(qmk)
resolve_keyboard_includes(${QMK_KEYBOARD_FOLDER_ABS})
add_subdirectory(quantum) add_subdirectory(quantum)
add_subdirectory(platforms) add_subdirectory(platforms)
add_subdirectory(tmk_core/protocol) add_subdirectory(tmk_core/protocol)

View File

@ -113,4 +113,17 @@ function(resolve_keymap_c KEYBOARD_FOLDER_ABS KEYMAP_FOLDER KEYMAP_C_STR)
endif() endif()
endif() endif()
endif() endif()
endfunction()
function(resolve_keyboard_includes KEYBOARD_FOLDER_ABS)
if(${IS_KEYBOARDS_FOLDER})
file(RELATIVE_PATH RELATIVE_KEYBOARD_FOLDER ${QMK_KEYBOARDS_FOLDER} ${KEYBOARD_FOLDER_ABS})
# get the deepest config.h
while(NOT ${RELATIVE_KEYBOARD_FOLDER} STREQUAL "")
target_include_directories(qmk PUBLIC "${CMAKE_SOURCE_DIR}/keyboards/${RELATIVE_KEYBOARD_FOLDER}")
get_filename_component(RELATIVE_KEYBOARD_FOLDER ${RELATIVE_KEYBOARD_FOLDER} DIRECTORY)
endwhile()
else()
target_include_directories(qmk PUBLIC "${KEYBOARD_FOLDER_ABS}")
endif()
endfunction() endfunction()

View File

@ -4,27 +4,27 @@ 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) 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 ${NO_BACKLIGHT_PIN} STREQUAL "backlight-NOTFOUND")
add_library(backlight target_sources(qmk PUBLIC
quantum/backlight/backlight.c quantum/backlight/backlight.c
quantum/process_keycode/process_backlight.c quantum/process_keycode/process_backlight.c
) )
add_compile_definitions( target_compile_definitions(qmk PUBLIC
BACKLIGHT_ENABLE BACKLIGHT_ENABLE
BACKLIGHT_PIN=${BACKLIGHT_PIN} BACKLIGHT_PIN=${BACKLIGHT_PIN}
) )
if(${BACKLIGHT_DRIVER} STREQUAL "custom") if(${BACKLIGHT_DRIVER} STREQUAL "custom")
add_compile_definitions(BACKLIGHT_CUSTOM_DRIVER) target_compile_definitions(qmk PUBLIC BACKLIGHT_CUSTOM_DRIVER)
else() else()
target_sources(backlight PRIVATE quantum/backlight/backlight_driver_common.c) target_sources(qmk PUBLIC quantum/backlight/backlight_driver_common.c)
if(${BACKLIGHT_DRIVER} STREQUAL "pwm") if(${BACKLIGHT_DRIVER} STREQUAL "pwm")
target_sources(backlight PRIVATE quantum/backlight/backlight_${QMK_PLATFORM}.c) target_sources(qmk PUBLIC quantum/backlight/backlight_${QMK_PLATFORM}.c)
else() else()
target_sources(backlight PRIVATE quantum/backlight/backlight_${BACKLIGHT_DRIVER}.c) target_sources(qmk PUBLIC quantum/backlight/backlight_${BACKLIGHT_DRIVER}.c)
endif() endif()
endif() endif()
target_include_directories(qmk PUBLIC quantum/backlight) target_include_directories(qmk PUBLIC quantum/backlight)
target_include_directories(qmk PUBLIC drivers/oled) target_include_directories(qmk PUBLIC drivers/oled)
target_link_libraries(backlight qmk) # target_link_libraries(backlight qmk)
# target_include_directories(backlight PUBLIC quantum/backlight) # target_include_directories(backlight PUBLIC quantum/backlight)
# target_include_directories(quantum PUBLIC quantum/backlight) # target_include_directories(quantum PUBLIC quantum/backlight)
# target_link_libraries(backlight ${QMK_TARGET}) # target_link_libraries(backlight ${QMK_TARGET})

View File

@ -1,13 +1,13 @@
option(OLED_ENABLE "" TRUE) option(OLED_ENABLE "" TRUE)
if(${OLED_ENABLE}) if(${OLED_ENABLE})
add_library(oled target_sources(qmk PUBLIC
drivers/oled/ssd1306_sh1106.c drivers/oled/ssd1306_sh1106.c
platforms/${QMK_PLATFORM}/drivers/i2c_master.c) platforms/${QMK_PLATFORM}/drivers/i2c_master.c)
add_compile_definitions(OLED_ENABLE) target_compile_definitions(qmk PUBLIC OLED_ENABLE)
target_include_directories(oled PUBLIC drivers) target_include_directories(qmk PUBLIC drivers)
target_include_directories(oled PUBLIC drivers/oled) target_include_directories(qmk PUBLIC drivers/oled)
target_include_directories(oled PUBLIC platforms/${QMK_PLATFORM}/drivers) target_include_directories(qmk PUBLIC platforms/${QMK_PLATFORM}/drivers)
target_link_libraries(oled qmk) # target_link_libraries(oled qmk)
# target_link_libraries(oled ${QMK_TARGET}) # target_link_libraries(oled ${QMK_TARGET})
# target_link_libraries(oled platforms) # target_link_libraries(oled platforms)
endif() endif()

View File

@ -16,4 +16,13 @@ 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") add_keyboard(${KEYBOARD_FOLDER} "default")
endforeach()
file(GLOB_RECURSE POSSIBLE_KEYBOARDS **/info.json)
file(WRITE "${CMAKE_SOURCE_DIR}/build/all_keyboards" "")
foreach(KEYBOARD_INFO ${POSSIBLE_KEYBOARDS})
get_filename_component(KEYBOARD_FOLDER_ABS "${KEYBOARD_INFO}" DIRECTORY)
file(RELATIVE_PATH KEYBOARD_FOLDER "${CMAKE_SOURCE_DIR}/keyboards" "${KEYBOARD_FOLDER_ABS}")
file(APPEND "${CMAKE_SOURCE_DIR}/build/all_keyboards" "${KEYBOARD_FOLDER}\n")
endforeach() endforeach()

View File

@ -4,7 +4,7 @@ target_sources(qmk PUBLIC
usb_device_state.c usb_device_state.c
usb_util.c usb_util.c
) )
add_compile_definitions( target_compile_definitions(
# MOUSE_ENABLED # MOUSE_ENABLED
# EXTRAKEY_ENABLE # EXTRAKEY_ENABLE
# NKRO_ENABLE # NKRO_ENABLE