Skip to content

Commit

Permalink
Linting: Additional fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Pro committed Mar 13, 2019
1 parent 407068c commit 58d08d5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 29 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,6 @@ set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "_CmakePredifinedTargets"

set_target_properties(open62541 PROPERTIES FOLDER "open62541/lib")
set_target_properties(open62541-object PROPERTIES FOLDER "open62541/lib")
set_target_properties(clang-tidy PROPERTIES FOLDER "CodeAnalysis")
if (UA_ENABLE_AMALGAMATION)
set_target_properties(open62541-amalgamation-header PROPERTIES FOLDER "open62541/lib")
set_target_properties(open62541-amalgamation-source PROPERTIES FOLDER "open62541/lib")
Expand Down
1 change: 1 addition & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ filter=-readability/alt_tokens
filter=-runtime/indentation_namespace
filter=-whitespace/comments
filter=-whitespace/blank_line
filter=-whitespace/parens
filter=-readability/braces
exclude_files=deps/*
exclude_files=build/*
20 changes: 0 additions & 20 deletions tools/cmake/linting_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,3 @@ elseif(UA_ENABLE_STATIC_ANALYZER STREQUAL FULL)
endif()
endif()

# adds new target "clangformat" to enforce clang-format rules
find_program(CLANG_FORMAT_EXE NAMES "clang-format")
if(CLANG_FORMAT_EXE)
file(GLOB_RECURSE FILES_TO_FORMAT
${PROJECT_SOURCE_DIR}/arch/*.c
${PROJECT_SOURCE_DIR}/plugins/*.c
${PROJECT_SOURCE_DIR}/src/*.c
${PROJECT_SOURCE_DIR}/arch/*.h
${PROJECT_SOURCE_DIR}/include/*.h
${PROJECT_SOURCE_DIR}/plugins/*.h
${PROJECT_SOURCE_DIR}/src/*.h
)
add_custom_target(
clangformat COMMAND ${CLANG_FORMAT_EXE}
-style=file
-i
${FILES_TO_FORMAT}
)
endif()

34 changes: 26 additions & 8 deletions tools/cmake/linting_target.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
find_package(ClangTools)
# clang-tidy uses the compile_commands.json file for include dirs and other config
add_custom_target(clang-tidy ${CLANG_TIDY_PROGRAM}
${lib_sources}
-p=compile_commands.json
-format-style=file
--
-I${PROJECT_SOURCE_DIR}/include
-I${PROJECT_SOURCE_DIR}/plugins
-I${PROJECT_SOURCE_DIR}/deps
-I${PROJECT_SOURCE_DIR}/src
-I${PROJECT_SOURCE_DIR}/src/server
-I${PROJECT_SOURCE_DIR}/src/client
-I${PROJECT_BINARY_DIR}/src_generated
${lib_sources}
DEPENDS ${lib_sources}
COMMENT "Run clang-tidy on the library")
add_dependencies(clang-tidy open62541)
set_target_properties(clang-tidy PROPERTIES FOLDER "CodeAnalysis")

add_custom_target(cpplint cpplint
${lib_sources}
Expand All @@ -28,3 +24,25 @@ add_custom_target(cpplint cpplint
${ua_architecture_headers}
${ua_architecture_sources}
COMMENT "Run cpplint code style checker on the library")
set_target_properties(cpplint PROPERTIES FOLDER "CodeAnalysis")


# adds new target "clang-format" to enforce clang-format rules
find_program(CLANG_FORMAT_EXE NAMES "clang-format")
if(CLANG_FORMAT_EXE)
file(GLOB_RECURSE FILES_TO_FORMAT
${PROJECT_SOURCE_DIR}/arch/*.c
${PROJECT_SOURCE_DIR}/plugins/*.c
${PROJECT_SOURCE_DIR}/src/*.c
${PROJECT_SOURCE_DIR}/arch/*.h
${PROJECT_SOURCE_DIR}/include/*.h
${PROJECT_SOURCE_DIR}/plugins/*.h
${PROJECT_SOURCE_DIR}/src/*.h
)
add_custom_target(
clang-format COMMAND ${CLANG_FORMAT_EXE}
-style=file
-i
${FILES_TO_FORMAT}
)
endif()

0 comments on commit 58d08d5

Please sign in to comment.