Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added Clang-format tool for user files
- l0_lowlevel and l1_third party are excluded from clang-formatting
- Shifted project .elf creation to project_release.cmake file
- Added option for CLANG-FORMAT in options.cmake

Minor updates
- Added internal driver headers to build for clang-format
  • Loading branch information
coder137 committed Jan 23, 2021
commit 10bf0b0e219118c12d56f405e5c07d11dab12757
53 changes: 29 additions & 24 deletions Template/Minimal_Tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,29 @@ ess_include(l5_application)

set(USER_INCLUDE_DIRS
${l0_lowlevel_dirs}
${FreeRTOS_dirs}
${l2_driver_dirs}
${l2_peripheral_dirs}
${l5_application_dirs}
)

set(USER_SOURCES
${l0_lowlevel_sources}
${FreeRTOS_sources}
${l2_driver_sources}
${l2_peripheral_sources}
${l5_application_sources}
)

set(USER_CLANG_SOURCES
${l2_driver_sources}
${l2_peripheral_sources}
${l5_application_sources}
)

set(USER_CLANG_INC_DIRS
${l2_driver_dirs}
${l2_peripheral_dirs}
${FreeRTOS_dirs}
${l5_application_dirs}
)

Expand Down Expand Up @@ -58,47 +78,32 @@ if (TESTING)

# TODO, Add more tests here

# NOTE, Append to USER_CLANG_SOURCES and USER_CLANG_INC_DIRS
# to add unit-tests to clang format

# TODO, Add code coverage tool

else()

message("Configuring ARM Project")

# Tools to add before target is defined
## Static analysis tool
include(cmake/tool/cppcheck.cmake)

# Cross Compiled project
set(USER_PROJECT_TARGET "${PROJECT_NAME}.elf")
add_executable(${USER_PROJECT_TARGET}
${l0_lowlevel_sources}
${FreeRTOS_sources}
${l2_driver_sources}
${l2_peripheral_sources}
${l5_application_sources}
)

target_include_directories(${USER_PROJECT_TARGET} PRIVATE
${USER_INCLUDE_DIRS}
)

target_compile_options(${USER_PROJECT_TARGET} PRIVATE
${COMMON_C_FLAGS}
${USER_C_FLAGS}
)

target_link_options(${USER_PROJECT_TARGET} PRIVATE
${COMMON_C_FLAGS}
${USER_LINK_FLAGS}
)
include(cmake/project/project_release.cmake)
# TODO, Add more projects here

# Features
include(cmake/cross/semihosting.cmake)

# Tools
include(cmake/compile.cmake)
include(cmake/flash.cmake)
# TODO, Add Static Analysis tool
# TODO, Add documentation generator tool

endif()

# TODO, Add Clang format tool
include(cmake/tool/clangformat.cmake)
18 changes: 18 additions & 0 deletions Template/Minimal_Tools/cmake/project/project_release.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set(USER_PROJECT_TARGET "${PROJECT_NAME}.elf")
add_executable(${USER_PROJECT_TARGET}
${USER_SOURCES}
)

target_include_directories(${USER_PROJECT_TARGET} PRIVATE
${USER_INCLUDE_DIRS}
)

target_compile_options(${USER_PROJECT_TARGET} PRIVATE
${COMMON_C_FLAGS}
${USER_C_FLAGS}
)

target_link_options(${USER_PROJECT_TARGET} PRIVATE
${COMMON_C_FLAGS}
${USER_LINK_FLAGS}
)
32 changes: 32 additions & 0 deletions Template/Minimal_Tools/cmake/tool/clangformat.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if(NOT CLANGFORMAT_REQUIRED)
message("TOOL: CLANGFORMAT NOT required")
return()
endif()

message("TOOL: CLANGFORMAT required")
find_program(clangformat_program
"clang-format"
REQUIRED
)

set(USER_CLANG_INC_FILES "")
foreach(dir ${USER_CLANG_INC_DIRS})
file(GLOB temp CONFIGURE_DEPENDS
"${dir}/*.h"
)
list(APPEND USER_CLANG_INC_FILES ${temp})
endforeach()

set(USER_CLANG_FORMAT_FILES
${USER_CLANG_INC_FILES}
${USER_CLANG_SOURCES}
)

# clang-format
add_custom_target(
clang-format ALL
COMMAND ${clangformat_program} -i ${USER_CLANG_FORMAT_FILES} --style=file
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "TOOL: CLANGFORMAT running"
VERBATIM USES_TERMINAL
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ ess_data(l2_driver_sources
uart/uart.c
uart/uart_interrupt.c
)
ess_data(l2_driver_dirs
exti
gpio
rcc
uart
)
4 changes: 2 additions & 2 deletions Template/Minimal_Tools/l5_application/STM32L475xx_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

// Conditional includes
#if STM32L475xx
#include "exti/exti.h"
#include "rcc/rcc.h"
#include "exti.h"
#include "rcc.h"
#endif

/**
Expand Down
3 changes: 3 additions & 0 deletions Template/Minimal_Tools/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ option(TESTING OFF)

## CPPCHECK
set(CPPCHECK_REQUIRED ON)

## CLANG-FORMAT
set(CLANGFORMAT_REQUIRED ON)