Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
2922fce0f7
21 changed files with 543 additions and 97 deletions
40
Lib/CMake/FindDFUSuffix.cmake
Normal file
40
Lib/CMake/FindDFUSuffix.cmake
Normal file
|
@ -0,0 +1,40 @@
|
|||
# The module defines the following variables:
|
||||
# DFU_SUFFIX_EXECUTABLE - path to ctags command line client
|
||||
# DFU_SUFFIX_FOUND - true if the command line client was found
|
||||
# DFU_SUFFIX_VERSION_STRING - the version of dfu-suffix found (since CMake 2.8.8)
|
||||
# Example usage:
|
||||
# find_package( DFUSuffix )
|
||||
# if( DFU_SUFFIX_FOUND )
|
||||
# message("ctags found: ${DFU_SUFFIX_EXECUTABLE}")
|
||||
# endif()
|
||||
|
||||
find_program ( DFU_SUFFIX_EXECUTABLE
|
||||
NAMES dfu-suffix
|
||||
DOC "dfu-suffix executable"
|
||||
)
|
||||
mark_as_advanced ( DFU_SUFFIX_EXECUTABLE )
|
||||
|
||||
if ( DFU_SUFFIX_EXECUTABLE )
|
||||
execute_process ( COMMAND ${DFU_SUFFIX_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE dfu_suffix_version
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if ( dfu_suffix_version MATCHES "^dfu-suffix \\(dfu-util\\)" )
|
||||
string ( REPLACE "\n" "" DFU_SUFFIX_VERSION_STRING ${dfu_suffix_version} )
|
||||
string ( REPLACE "dfu-suffix (dfu-util) " "" DFU_SUFFIX_VERSION_STRING ${DFU_SUFFIX_VERSION_STRING} )
|
||||
string ( REGEX REPLACE "Copyright .*$" "" DFU_SUFFIX_VERSION_STRING ${DFU_SUFFIX_VERSION_STRING} )
|
||||
endif ()
|
||||
unset ( dfu_suffix_version )
|
||||
endif ()
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set DFU_SUFFIX_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
|
||||
include ( FindPackageHandleStandardArgs )
|
||||
find_package_handle_standard_args ( DFU_SUFFIX
|
||||
REQUIRED_VARS DFU_SUFFIX_EXECUTABLE
|
||||
VERSION_VAR DFU_SUFFIX_VERSION_STRING
|
||||
)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
###| CMAKE Kiibohd Controller Source Configurator |###
|
||||
#
|
||||
# Written by Jacob Alexander in 2011-2014 for the Kiibohd Controller
|
||||
# Written by Jacob Alexander in 2011-2015 for the Kiibohd Controller
|
||||
#
|
||||
# Released into the Public Domain
|
||||
#
|
||||
|
@ -46,12 +46,25 @@ endif ()
|
|||
|
||||
|
||||
#| Convert the .ELF into a .bin to load onto the McHCK
|
||||
#| Then sign using dfu-suffix (requries dfu-util)
|
||||
if ( DEFINED DFU )
|
||||
# dfu-suffix is required to sign the dfu binary
|
||||
find_package ( DFUSuffix )
|
||||
|
||||
set( TARGET_BIN ${TARGET}.dfu.bin )
|
||||
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
||||
COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
|
||||
COMMENT "Creating dfu binary file: ${TARGET_BIN}"
|
||||
)
|
||||
if ( DFU_SUFFIX_FOUND )
|
||||
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
||||
COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
|
||||
COMMAND ${DFU_SUFFIX_EXECUTABLE} --add ${TARGET_BIN} --vid ${BOOT_VENDOR_ID} --pid ${BOOT_PRODUCT_ID} 1> /dev/null
|
||||
COMMENT "Create and sign dfu bin file: ${TARGET_BIN}"
|
||||
)
|
||||
else ()
|
||||
message ( WARNING "DFU Binary has not been signed, requires dfu-suffix..." )
|
||||
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
||||
COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
|
||||
COMMENT "Creating dfu binary file: ${TARGET_BIN}"
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
###| CMAKE Kiibohd Controller KLL Configurator |###
|
||||
#
|
||||
# Written by Jacob Alexander in 2014 for the Kiibohd Controller
|
||||
# Written by Jacob Alexander in 2014-2015 for the Kiibohd Controller
|
||||
#
|
||||
# Released into the Public Domain
|
||||
#
|
||||
|
@ -46,14 +46,10 @@ endif () # kll/kll.py exists
|
|||
|
||||
#| KLL_DEPENDS is used to build a dependency tree for kll.py, this way when files are changed, kll.py gets re-run
|
||||
|
||||
#| Search for capabilities.kll in each module directory
|
||||
foreach ( DIR ${ScanModulePath} ${MacroModulePath} ${OutputModulePath} ${DebugModulePath} )
|
||||
# capabilities.kll exists, add to BaseMap
|
||||
set ( filename "${PROJECT_SOURCE_DIR}/${DIR}/capabilities.kll" )
|
||||
if ( EXISTS ${filename} )
|
||||
set ( BaseMap_Args ${BaseMap_Args} ${filename} )
|
||||
set ( KLL_DEPENDS ${KLL_DEPENDS} ${filename} )
|
||||
endif ()
|
||||
#| Add each of the detected capabilities.kll
|
||||
foreach ( filename ${ScanModule_KLL} ${MacroModule_KLL} ${OutputModule_KLL} ${DebugModule_KLL} )
|
||||
set ( BaseMap_Args ${BaseMap_Args} ${filename} )
|
||||
set ( KLL_DEPENDS ${KLL_DEPENDS} ${filename} )
|
||||
endforeach ()
|
||||
|
||||
#| If set BaseMap cannot be found, use default map
|
||||
|
@ -118,21 +114,25 @@ endforeach ()
|
|||
#
|
||||
|
||||
#| KLL Options
|
||||
set ( kll_backend -b kiibohd )
|
||||
set ( kll_template -t ${PROJECT_SOURCE_DIR}/kll/templates/kiibohdKeymap.h )
|
||||
set ( kll_outputname generatedKeymap.h )
|
||||
set ( kll_output -o ${kll_outputname} )
|
||||
set ( kll_define_output --defines-output kll_defs.h )
|
||||
set ( kll_define_template --defines-template ${PROJECT_SOURCE_DIR}/kll/templates/kiibohdDefs.h )
|
||||
set ( kll_backend --backend kiibohd )
|
||||
set ( kll_template --templates ${PROJECT_SOURCE_DIR}/kll/templates/kiibohdKeymap.h ${PROJECT_SOURCE_DIR}/kll/templates/kiibohdDefs.h )
|
||||
set ( kll_outputname generatedKeymap.h kll_defs.h )
|
||||
set ( kll_output --outputs ${kll_outputname} )
|
||||
|
||||
#| KLL Cmd
|
||||
set ( kll_cmd ${PROJECT_SOURCE_DIR}/kll/kll.py ${BaseMap_Args} ${DefaultMap_Args} ${PartialMap_Args} ${kll_backend} ${kll_template} ${kll_output} ${kll_define_template} ${kll_define_output} )
|
||||
set ( kll_cmd ${PROJECT_SOURCE_DIR}/kll/kll.py ${BaseMap_Args} ${DefaultMap_Args} ${PartialMap_Args} ${kll_backend} ${kll_template} ${kll_output} )
|
||||
add_custom_command ( OUTPUT ${kll_outputname}
|
||||
COMMAND ${kll_cmd}
|
||||
DEPENDS ${KLL_DEPENDS}
|
||||
COMMENT "Generating KLL Layout"
|
||||
)
|
||||
|
||||
#| KLL Regen Convenience Target
|
||||
add_custom_target ( kll_regen
|
||||
COMMAND ${kll_cmd}
|
||||
COMMENT "Re-generating KLL Layout"
|
||||
)
|
||||
|
||||
#| Append generated file to required sources so it becomes a dependency in the main build
|
||||
set ( SRCS ${SRCS} ${kll_outputname} )
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
###| CMAKE Kiibohd Controller Source Configurator |###
|
||||
#
|
||||
# Written by Jacob Alexander in 2011-2014 for the Kiibohd Controller
|
||||
# Written by Jacob Alexander in 2011-2015 for the Kiibohd Controller
|
||||
#
|
||||
# Released into the Public Domain
|
||||
#
|
||||
|
@ -104,10 +104,8 @@ function ( AddModule ModuleType ModuleName )
|
|||
PathPrepend ( Module_SRCS ${ModulePath} ${Module_SRCS} )
|
||||
|
||||
# Check the current scope to see if a sub-module added some source files
|
||||
set ( Module_SRCS ${${ModuleType}_SRCS} ${Module_SRCS} )
|
||||
|
||||
# Append each of the sources to each type of module srcs list
|
||||
set ( ${ModuleType}_SRCS ${Module_SRCS} )
|
||||
set ( ${ModuleType}_SRCS ${${ModuleType}_SRCS} ${Module_SRCS} )
|
||||
|
||||
# Add .h files
|
||||
add_definitions ( -I${ModuleFullPath} )
|
||||
|
@ -124,8 +122,17 @@ function ( AddModule ModuleType ModuleName )
|
|||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Finally, add the sources to the parent scope (i.e. return)
|
||||
# Check for any capabilities.kll files in the Module
|
||||
set ( kll_capabilities_file "${ModuleFullPath}/capabilities.kll" )
|
||||
if ( EXISTS ${kll_capabilities_file} )
|
||||
# Add the kll file and any submodule kll files to the running list
|
||||
set ( ${ModuleType}Module_KLL ${${ModuleType}Module_KLL} ${kll_capabilities_file} )
|
||||
endif ()
|
||||
|
||||
|
||||
# Finally, add the sources and kll files to the parent scope (i.e. return)
|
||||
set ( ${ModuleType}_SRCS ${${ModuleType}_SRCS} PARENT_SCOPE )
|
||||
set ( ${ModuleType}Module_KLL ${${ModuleType}Module_KLL} PARENT_SCOPE )
|
||||
endfunction ()
|
||||
|
||||
|
||||
|
@ -150,7 +157,7 @@ find_package ( Ctags ) # Optional
|
|||
#
|
||||
|
||||
#| Manufacturer name
|
||||
set( MANUFACTURER "Kiibohd" )
|
||||
set ( MANUFACTURER "Kiibohd" )
|
||||
|
||||
|
||||
#| Serial Number
|
||||
|
@ -158,19 +165,29 @@ set( MANUFACTURER "Kiibohd" )
|
|||
|
||||
#| Modified
|
||||
#| Takes a bit of work to extract the "M " using CMake, and not using it if there are no modifications
|
||||
execute_process( COMMAND ${GIT_EXECUTABLE} status -s -uno --porcelain
|
||||
execute_process ( COMMAND ${GIT_EXECUTABLE} status -s -uno --porcelain
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE Git_Modified_INFO
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string( LENGTH "${Git_Modified_INFO}" Git_Modified_LENGTH )
|
||||
set( Git_Modified_Status "Clean" )
|
||||
string ( LENGTH "${Git_Modified_INFO}" Git_Modified_LENGTH )
|
||||
set ( Git_Modified_Status "Clean" )
|
||||
if ( ${Git_Modified_LENGTH} GREATER 2 )
|
||||
string( SUBSTRING "${Git_Modified_INFO}" 1 2 Git_Modified_Flag_INFO )
|
||||
set( Git_Modified_Status "Dirty" )
|
||||
string ( SUBSTRING "${Git_Modified_INFO}" 1 2 Git_Modified_Flag_INFO )
|
||||
set ( Git_Modified_Status "Dirty" )
|
||||
endif ()
|
||||
|
||||
#| List of modified files
|
||||
execute_process ( COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE Git_Modified_Files
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string ( REGEX REPLACE "\n" "\\\\r\\\\n\\\\t" Git_Modified_Files "${Git_Modified_Files}" )
|
||||
set ( Git_Modified_Files "\\r\\n\\t${Git_Modified_Files}" )
|
||||
|
||||
#| Branch
|
||||
execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
|
@ -180,7 +197,7 @@ execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
|||
)
|
||||
|
||||
#| Date
|
||||
execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format=%ci
|
||||
execute_process ( COMMAND ${GIT_EXECUTABLE} show -s --format=%ci
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE Git_Date_INFO
|
||||
ERROR_QUIET
|
||||
|
@ -188,7 +205,7 @@ execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format=%ci
|
|||
)
|
||||
|
||||
#| Commit Author and Email
|
||||
execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format="%cn <%ce>"
|
||||
execute_process ( COMMAND ${GIT_EXECUTABLE} show -s --format="%cn <%ce>"
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE Git_Commit_Author
|
||||
ERROR_QUIET
|
||||
|
@ -196,7 +213,7 @@ execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format="%cn <%ce>"
|
|||
)
|
||||
|
||||
#| Commit Revision
|
||||
execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format=%H
|
||||
execute_process ( COMMAND ${GIT_EXECUTABLE} show -s --format=%H
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE Git_Commit_Revision
|
||||
ERROR_QUIET
|
||||
|
@ -204,7 +221,7 @@ execute_process( COMMAND ${GIT_EXECUTABLE} show -s --format=%H
|
|||
)
|
||||
|
||||
#| Origin URL
|
||||
execute_process( COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url
|
||||
execute_process ( COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE Git_Origin_URL
|
||||
ERROR_QUIET
|
||||
|
@ -212,25 +229,25 @@ execute_process( COMMAND ${GIT_EXECUTABLE} config --get remote.origin.url
|
|||
)
|
||||
|
||||
#| Build Date
|
||||
execute_process( COMMAND "date" "+%Y-%m-%d %T %z"
|
||||
execute_process ( COMMAND "date" "+%Y-%m-%d %T %z"
|
||||
OUTPUT_VARIABLE Build_Date
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
#| Last Commit Date
|
||||
set( GitLastCommitDate "${Git_Modified_Status} ${Git_Branch_INFO} - ${Git_Date_INFO}" )
|
||||
set ( GitLastCommitDate "${Git_Modified_Status} ${Git_Branch_INFO} - ${Git_Date_INFO}" )
|
||||
|
||||
#| Uses CMake variables to include as defines
|
||||
#| Primarily for USB configuration
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Lib/_buildvars.h buildvars.h )
|
||||
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/Lib/_buildvars.h buildvars.h )
|
||||
|
||||
|
||||
|
||||
###
|
||||
# Source Defines
|
||||
#
|
||||
set( SRCS
|
||||
set ( SRCS
|
||||
${MAIN_SRCS}
|
||||
${COMPILER_SRCS}
|
||||
${Scan_SRCS}
|
||||
|
@ -240,7 +257,7 @@ set( SRCS
|
|||
)
|
||||
|
||||
#| Directories to include by default
|
||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
|
||||
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
|
||||
|
||||
|
||||
|
||||
|
@ -248,20 +265,20 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
|
|||
# ctag Generation
|
||||
#
|
||||
|
||||
if( CTAGS_EXECUTABLE )
|
||||
if ( CTAGS_EXECUTABLE )
|
||||
# Populate list of directories for ctags to parse
|
||||
# NOTE: Doesn't support dots in the folder names...
|
||||
foreach( filename ${SRCS} )
|
||||
string( REGEX REPLACE "/[a-zA-Z0-9_-]+.c$" "" pathglob ${filename} )
|
||||
file( GLOB filenames "${pathglob}/*.c" )
|
||||
set( CTAG_PATHS ${CTAG_PATHS} ${filenames} )
|
||||
file( GLOB filenames "${pathglob}/*.h" )
|
||||
set( CTAG_PATHS ${CTAG_PATHS} ${filenames} )
|
||||
endforeach()
|
||||
foreach ( filename ${SRCS} )
|
||||
string ( REGEX REPLACE "/[a-zA-Z0-9_-]+.c$" "" pathglob ${filename} )
|
||||
file ( GLOB filenames "${pathglob}/*.c" )
|
||||
set ( CTAG_PATHS ${CTAG_PATHS} ${filenames} )
|
||||
file ( GLOB filenames "${pathglob}/*.h" )
|
||||
set ( CTAG_PATHS ${CTAG_PATHS} ${filenames} )
|
||||
endforeach ()
|
||||
|
||||
# Generate the ctags
|
||||
execute_process( COMMAND ctags ${CTAG_PATHS}
|
||||
execute_process ( COMMAND ctags ${CTAG_PATHS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2013-2014 by Jacob Alexander
|
||||
/* Copyright (C) 2013-2015 by Jacob Alexander
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -38,6 +38,7 @@
|
|||
#define CLI_Revision "@Git_Commit_Revision@"
|
||||
#define CLI_Branch "@Git_Branch_INFO@"
|
||||
#define CLI_ModifiedStatus "@Git_Modified_Status@"
|
||||
#define CLI_ModifiedFiles "@Git_Modified_Files@"
|
||||
#define CLI_RepoOrigin "@Git_Origin_URL@"
|
||||
#define CLI_CommitDate "@Git_Date_INFO@"
|
||||
#define CLI_CommitAuthor @Git_Commit_Author@
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue