mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Running cppcheck with every build
This commit is contained in:
parent
d77d2967e0
commit
b385ffb12e
@ -26,7 +26,7 @@ add_library(uavcan SHARED ${LIBUAVCAN_CXX_FILES})
|
||||
# TODO installation rules
|
||||
|
||||
#
|
||||
# Test
|
||||
# Unit tests with gtest (optional)
|
||||
#
|
||||
find_package(GTest QUIET)
|
||||
if (GTEST_FOUND)
|
||||
@ -47,8 +47,15 @@ if (GTEST_FOUND)
|
||||
# Tests run automatically upon successful build
|
||||
# If failing tests need to be investigated with debugger, use 'make --ignore-errors'
|
||||
add_custom_command(TARGET libuavcan_test POST_BUILD
|
||||
COMMAND "./libuavcan_test"
|
||||
COMMAND ./libuavcan_test
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
else (GTEST_FOUND)
|
||||
message(">> Google test library is not found, you will not be able to run tests")
|
||||
endif (GTEST_FOUND)
|
||||
|
||||
#
|
||||
# Static analysis with cppcheck (required), both library and unit test sources
|
||||
#
|
||||
add_custom_command(TARGET uavcan PRE_BUILD
|
||||
COMMAND ./cppcheck.sh
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
10
libuavcan/cppcheck.sh
Executable file
10
libuavcan/cppcheck.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# cppcheck static analysis
|
||||
# For Debian based: apt-get install cppcheck
|
||||
#
|
||||
|
||||
# TODO: with future versions of cppcheck, add --library=glibc
|
||||
cppcheck . --error-exitcode=1 --quiet --enable=all --platform=unix64 --std=c99 --std=c++11 \
|
||||
--inconclusive --inline-suppr --force --template=gcc \
|
||||
-Iinclude $@
|
||||
@ -30,7 +30,9 @@ struct CanFrame
|
||||
CanFrame()
|
||||
: id(0)
|
||||
, dlc(0)
|
||||
{ }
|
||||
{
|
||||
std::memset(data, 0, sizeof(data));
|
||||
}
|
||||
|
||||
CanFrame(uint32_t id, const uint8_t* data, unsigned int dlc)
|
||||
: id(id)
|
||||
|
||||
@ -82,7 +82,10 @@ public:
|
||||
return 1;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
// cppcheck-suppress functionConst
|
||||
int configureFilters(const uavcan::CanFilterConfig* filter_configs, int num_configs) { return -1; }
|
||||
// cppcheck-suppress unusedFunction
|
||||
int getNumFilters() const { return 0; }
|
||||
uint64_t getNumErrors() const { return num_errors; }
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user